bgamazay commited on
Commit
cf8c749
·
verified ·
1 Parent(s): 76e48d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -202,7 +202,8 @@ def create_label_single_pass(background_image, model_data, final_size=(520, 728)
202
 
203
  title_x, title_y = 33, 150
204
  details_x, details_y = 480, 256
205
- energy_x, energy_y = 425, 472
 
206
 
207
  draw.text((title_x, title_y), str(model_data['provider']), font=title_font, fill="black")
208
  draw.text((title_x, title_y + 38), str(model_data['model']), font=title_font, fill="black")
@@ -210,12 +211,19 @@ def create_label_single_pass(background_image, model_data, final_size=(520, 728)
210
  details_lines = [str(model_data['date']), str(model_data['task']), str(model_data['hardware'])]
211
  for i, line in enumerate(details_lines):
212
  bbox = draw.textbbox((0, 0), line, font=details_font)
213
- draw.text((details_x - bbox[2], details_y + i * 47), line, font=details_font, fill="black")
 
214
 
215
- draw.text((energy_x, energy_y), str(model_data['energy']), font=energy_font, fill="black")
 
 
 
 
 
216
 
217
  return bg_resized
218
 
219
 
 
220
  if __name__ == "__main__":
221
  main()
 
202
 
203
  title_x, title_y = 33, 150
204
  details_x, details_y = 480, 256
205
+ energy_x = 480 # Right margin for the energy value
206
+ energy_y = 472
207
 
208
  draw.text((title_x, title_y), str(model_data['provider']), font=title_font, fill="black")
209
  draw.text((title_x, title_y + 38), str(model_data['model']), font=title_font, fill="black")
 
211
  details_lines = [str(model_data['date']), str(model_data['task']), str(model_data['hardware'])]
212
  for i, line in enumerate(details_lines):
213
  bbox = draw.textbbox((0, 0), line, font=details_font)
214
+ text_width = bbox[2] - bbox[0] # Get text width
215
+ draw.text((details_x - text_width, details_y + i * 47), line, font=details_font, fill="black")
216
 
217
+ # Right-align the energy text
218
+ energy_text = str(model_data['energy'])
219
+ energy_bbox = draw.textbbox((0, 0), energy_text, font=energy_font)
220
+ energy_text_width = energy_bbox[2] - energy_bbox[0]
221
+
222
+ draw.text((energy_x - energy_text_width, energy_y), energy_text, font=energy_font, fill="black")
223
 
224
  return bg_resized
225
 
226
 
227
+
228
  if __name__ == "__main__":
229
  main()