bgamazay commited on
Commit
f9dd218
·
verified ·
1 Parent(s): dbb7425

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
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 capitalize_first_word(text):
210
- words = text.split()
211
- if words:
212
- words[0] = words[0].capitalize()
213
- return " ".join(words)
214
-
215
- provider_text = capitalize_first_word(str(model_data['provider']))
216
- model_text = capitalize_first_word(str(model_data['model']))
 
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)