Update app.py
Browse files
app.py
CHANGED
@@ -9,16 +9,8 @@ def add_label_to_image(image, label):
|
|
9 |
# Create a drawing context
|
10 |
draw = ImageDraw.Draw(image)
|
11 |
|
12 |
-
# Define font size and color (adjust font path for your environment)
|
13 |
-
font_path = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf" # Example font path
|
14 |
-
font_size = 40
|
15 |
-
try:
|
16 |
-
font = ImageFont.truetype(font_path, font_size)
|
17 |
-
except:
|
18 |
-
font = ImageFont.load_default()
|
19 |
-
|
20 |
# Get the text size and position
|
21 |
-
text_size = draw.textsize(label
|
22 |
position = ((image.width - text_size[0]) // 2, image.height - text_size[1] - 10) # Centered at the bottom
|
23 |
|
24 |
# Add a semi-transparent rectangle behind the text for better visibility
|
@@ -148,10 +140,10 @@ def create_gradio_interface():
|
|
148 |
generate_button = gr.Button("Generate Evolution")
|
149 |
|
150 |
# Gradio Gallery component to display the images
|
151 |
-
image_gallery = gr.Gallery(label="Generated Images", show_label=True, columns=3, rows=1)
|
152 |
|
153 |
# Output for the generated GIF
|
154 |
-
gif_output = gr.Image(label="Generated GIF", show_label=True)
|
155 |
|
156 |
# Set the action when the button is clicked
|
157 |
generate_button.click(fn=generate_object_history, inputs=[object_name_input], outputs=[image_gallery, gif_output])
|
|
|
9 |
# Create a drawing context
|
10 |
draw = ImageDraw.Draw(image)
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
# Get the text size and position
|
13 |
+
text_size = draw.textsize(label)
|
14 |
position = ((image.width - text_size[0]) // 2, image.height - text_size[1] - 10) # Centered at the bottom
|
15 |
|
16 |
# Add a semi-transparent rectangle behind the text for better visibility
|
|
|
140 |
generate_button = gr.Button("Generate Evolution")
|
141 |
|
142 |
# Gradio Gallery component to display the images
|
143 |
+
image_gallery = gr.Gallery(label="Generated Images", show_label=True, columns=3, rows=1, value=default_images)
|
144 |
|
145 |
# Output for the generated GIF
|
146 |
+
gif_output = gr.Image(label="Generated GIF", show_label=True, value=default_gif_path)
|
147 |
|
148 |
# Set the action when the button is clicked
|
149 |
generate_button.click(fn=generate_object_history, inputs=[object_name_input], outputs=[image_gallery, gif_output])
|