Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -90,13 +90,13 @@ def create_label_single_pass(background_image, model_data, final_size=(520, 728)
|
|
90 |
# 3. Place your text.
|
91 |
# You may need to experiment with x/y coordinates or font sizes
|
92 |
# to make it look right in 520×728.
|
93 |
-
title_x, title_y = 32,
|
94 |
details_x, details_y = 480, 256
|
95 |
energy_x, energy_y = 460, 472
|
96 |
|
97 |
# Text 1 (title)
|
98 |
draw.text((title_x, title_y), str(model_data['model']), font=title_font, fill="black")
|
99 |
-
draw.text((title_x, title_y +
|
100 |
|
101 |
# Text 2 (details)
|
102 |
details_lines = [
|
@@ -108,14 +108,14 @@ def create_label_single_pass(background_image, model_data, final_size=(520, 728)
|
|
108 |
bbox = draw.textbbox((0, 0), line, font=details_font)
|
109 |
text_width = bbox[2] - bbox[0]
|
110 |
# Right-justify the details text at details_x
|
111 |
-
draw.text((details_x - text_width, details_y + i*
|
112 |
|
113 |
# Text 3 (energy)
|
114 |
energy_text = str(model_data['energy'])
|
115 |
bbox = draw.textbbox((0, 0), energy_text, font=energy_font)
|
116 |
energy_text_width = bbox[2] - bbox[0]
|
117 |
-
#
|
118 |
-
draw.text((energy_x - energy_text_width
|
119 |
|
120 |
return bg_resized
|
121 |
|
|
|
90 |
# 3. Place your text.
|
91 |
# You may need to experiment with x/y coordinates or font sizes
|
92 |
# to make it look right in 520×728.
|
93 |
+
title_x, title_y = 32, 148
|
94 |
details_x, details_y = 480, 256
|
95 |
energy_x, energy_y = 460, 472
|
96 |
|
97 |
# Text 1 (title)
|
98 |
draw.text((title_x, title_y), str(model_data['model']), font=title_font, fill="black")
|
99 |
+
draw.text((title_x, title_y + 38), str(model_data['provider']), font=title_font, fill="black")
|
100 |
|
101 |
# Text 2 (details)
|
102 |
details_lines = [
|
|
|
108 |
bbox = draw.textbbox((0, 0), line, font=details_font)
|
109 |
text_width = bbox[2] - bbox[0]
|
110 |
# Right-justify the details text at details_x
|
111 |
+
draw.text((details_x - text_width, details_y + i*47), line, font=details_font, fill="black")
|
112 |
|
113 |
# Text 3 (energy)
|
114 |
energy_text = str(model_data['energy'])
|
115 |
bbox = draw.textbbox((0, 0), energy_text, font=energy_font)
|
116 |
energy_text_width = bbox[2] - bbox[0]
|
117 |
+
# Right-align the energy text at energy_x
|
118 |
+
draw.text((energy_x - energy_text_width, energy_y), energy_text, font=energy_font, fill="black")
|
119 |
|
120 |
return bg_resized
|
121 |
|