Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,7 +44,7 @@ def process_image(image, outline_size, outline_color, add_outline):
|
|
| 44 |
final_img.save(output_buffer, format="PNG")
|
| 45 |
output_buffer.seek(0)
|
| 46 |
|
| 47 |
-
return final_img
|
| 48 |
|
| 49 |
# Gradio Interface
|
| 50 |
with gr.Blocks(title="Sticker Maker") as interface:
|
|
@@ -59,7 +59,6 @@ with gr.Blocks(title="Sticker Maker") as interface:
|
|
| 59 |
label="Outline Thickness", minimum=0, maximum=20, value=5, step=1
|
| 60 |
)
|
| 61 |
outline_color = gr.ColorPicker(label="Outline Color", value="#FFFFFF")
|
| 62 |
-
create_btn = gr.Button("Create Sticker", variant="primary")
|
| 63 |
|
| 64 |
with gr.Column():
|
| 65 |
output_image = gr.Image(
|
|
@@ -73,18 +72,20 @@ with gr.Blocks(title="Sticker Maker") as interface:
|
|
| 73 |
outputs=[outline_size, outline_color],
|
| 74 |
)
|
| 75 |
|
| 76 |
-
# Process image and
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
create_btn.click(
|
| 78 |
-
fn=
|
| 79 |
inputs=[image_upload, outline_size, outline_color, add_outline],
|
| 80 |
outputs=output_image,
|
| 81 |
)
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
inputs=output_image,
|
| 86 |
-
outputs=gr.File(label="Download Sticker as PNG"),
|
| 87 |
-
)
|
| 88 |
|
| 89 |
if __name__ == "__main__":
|
| 90 |
interface.launch(debug=True)
|
|
|
|
| 44 |
final_img.save(output_buffer, format="PNG")
|
| 45 |
output_buffer.seek(0)
|
| 46 |
|
| 47 |
+
return final_img
|
| 48 |
|
| 49 |
# Gradio Interface
|
| 50 |
with gr.Blocks(title="Sticker Maker") as interface:
|
|
|
|
| 59 |
label="Outline Thickness", minimum=0, maximum=20, value=5, step=1
|
| 60 |
)
|
| 61 |
outline_color = gr.ColorPicker(label="Outline Color", value="#FFFFFF")
|
|
|
|
| 62 |
|
| 63 |
with gr.Column():
|
| 64 |
output_image = gr.Image(
|
|
|
|
| 72 |
outputs=[outline_size, outline_color],
|
| 73 |
)
|
| 74 |
|
| 75 |
+
# Process image and show result in the preview pane
|
| 76 |
+
def process_and_return(image, outline_size, outline_color, add_outline):
|
| 77 |
+
processed_image = process_image(image, outline_size, outline_color, add_outline)
|
| 78 |
+
return processed_image # Return processed image for preview
|
| 79 |
+
|
| 80 |
+
create_btn = gr.Button("Create Sticker", variant="primary")
|
| 81 |
create_btn.click(
|
| 82 |
+
fn=process_and_return,
|
| 83 |
inputs=[image_upload, outline_size, outline_color, add_outline],
|
| 84 |
outputs=output_image,
|
| 85 |
)
|
| 86 |
|
| 87 |
+
# Enable PNG download directly from the preview pane
|
| 88 |
+
output_image.download(label="Download Sticker as PNG")
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
if __name__ == "__main__":
|
| 91 |
interface.launch(debug=True)
|