Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -206,19 +206,19 @@ def create_label_single_pass(background_image, model_data, final_size=(520, 728)
|
|
206 |
energy_y = 472
|
207 |
|
208 |
# Capitalize only the first letter of the first word while keeping the rest as is
|
209 |
-
def
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
|
|
217 |
|
218 |
draw.text((title_x, title_y), provider_text, font=title_font, fill="black")
|
219 |
draw.text((title_x, title_y + 38), model_text, font=title_font, fill="black")
|
220 |
|
221 |
-
|
222 |
details_lines = [str(model_data['date']), str(model_data['task']), str(model_data['hardware'])]
|
223 |
for i, line in enumerate(details_lines):
|
224 |
bbox = draw.textbbox((0, 0), line, font=details_font)
|
|
|
206 |
energy_y = 472
|
207 |
|
208 |
# Capitalize only the first letter of the first word while keeping the rest as is
|
209 |
+
def smart_capitalize(text):
|
210 |
+
"""Capitalizes the first letter of a string only if it's not already capitalized."""
|
211 |
+
if not text:
|
212 |
+
return text # Return unchanged if empty
|
213 |
+
return text if text[0].isupper() else text[0].upper() + text[1:]
|
214 |
+
|
215 |
+
# Apply smart capitalization
|
216 |
+
provider_text = smart_capitalize(str(model_data['provider']))
|
217 |
+
model_text = smart_capitalize(str(model_data['model']))
|
218 |
|
219 |
draw.text((title_x, title_y), provider_text, font=title_font, fill="black")
|
220 |
draw.text((title_x, title_y + 38), model_text, font=title_font, fill="black")
|
221 |
|
|
|
222 |
details_lines = [str(model_data['date']), str(model_data['task']), str(model_data['hardware'])]
|
223 |
for i, line in enumerate(details_lines):
|
224 |
bbox = draw.textbbox((0, 0), line, font=details_font)
|