Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,7 +10,7 @@ def add_label_to_image(image, label):
|
|
| 10 |
draw = ImageDraw.Draw(image)
|
| 11 |
|
| 12 |
# Calculate the size and position of the text
|
| 13 |
-
text_bbox = draw.textbbox((0, 0), label
|
| 14 |
text_width, text_height = text_bbox[2] - text_bbox[0], text_bbox[3] - text_bbox[1]
|
| 15 |
position = ((image.width - text_width) // 2, image.height - text_height - 10) # Centered at the bottom
|
| 16 |
|
|
@@ -23,7 +23,7 @@ def add_label_to_image(image, label):
|
|
| 23 |
position[1] + text_height + rect_margin,
|
| 24 |
]
|
| 25 |
draw.rectangle(rect_position, fill=(0, 0, 0, 128)) # Semi-transparent black
|
| 26 |
-
draw.text(position, label, fill="white"
|
| 27 |
return image
|
| 28 |
|
| 29 |
# Function to plot, label, and save an image
|
|
|
|
| 10 |
draw = ImageDraw.Draw(image)
|
| 11 |
|
| 12 |
# Calculate the size and position of the text
|
| 13 |
+
text_bbox = draw.textbbox((0, 0), label)
|
| 14 |
text_width, text_height = text_bbox[2] - text_bbox[0], text_bbox[3] - text_bbox[1]
|
| 15 |
position = ((image.width - text_width) // 2, image.height - text_height - 10) # Centered at the bottom
|
| 16 |
|
|
|
|
| 23 |
position[1] + text_height + rect_margin,
|
| 24 |
]
|
| 25 |
draw.rectangle(rect_position, fill=(0, 0, 0, 128)) # Semi-transparent black
|
| 26 |
+
draw.text(position, label, fill="white")
|
| 27 |
return image
|
| 28 |
|
| 29 |
# Function to plot, label, and save an image
|