Spaces:
Running
Running
Commit
·
ebf25c1
1
Parent(s):
c079997
feat: tweak ui
Browse files- gradio_demo.py +20 -6
gradio_demo.py
CHANGED
@@ -48,6 +48,10 @@ async def process_edit(image, instruction):
|
|
48 |
async def use_edited_image(edited_image):
|
49 |
return edited_image
|
50 |
|
|
|
|
|
|
|
|
|
51 |
# Create the Gradio interface
|
52 |
with gr.Blocks() as demo:
|
53 |
gr.Markdown("# PicEdit")
|
@@ -59,19 +63,22 @@ with gr.Blocks() as demo:
|
|
59 |
with gr.Row():
|
60 |
# Input image on the left
|
61 |
input_image = gr.Image(label="Original Image", type="filepath")
|
62 |
-
|
63 |
with gr.Column():
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
67 |
# Text input for editing instructions
|
68 |
instruction = gr.Textbox(
|
69 |
label="Editing Instructions",
|
70 |
placeholder="Describe the changes you want to make to the image..."
|
71 |
)
|
72 |
|
73 |
-
#
|
74 |
-
|
|
|
|
|
75 |
|
76 |
# Set up the event handlers
|
77 |
submit_btn.click(
|
@@ -86,6 +93,13 @@ with gr.Blocks() as demo:
|
|
86 |
outputs=[input_image]
|
87 |
)
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
if __name__ == "__main__":
|
90 |
demo.launch()
|
91 |
|
|
|
48 |
async def use_edited_image(edited_image):
|
49 |
return edited_image
|
50 |
|
51 |
+
def clear_instruction():
|
52 |
+
# Only clear the instruction text.
|
53 |
+
return ""
|
54 |
+
|
55 |
# Create the Gradio interface
|
56 |
with gr.Blocks() as demo:
|
57 |
gr.Markdown("# PicEdit")
|
|
|
63 |
with gr.Row():
|
64 |
# Input image on the left
|
65 |
input_image = gr.Image(label="Original Image", type="filepath")
|
66 |
+
|
67 |
with gr.Column():
|
68 |
+
# Output image on the right
|
69 |
+
output_image = gr.Image(label="Edited Image", type="filepath", interactive=False, scale=3)
|
70 |
+
use_edited_btn = gr.Button("👈 Use Edited Image 👈")
|
71 |
+
|
72 |
# Text input for editing instructions
|
73 |
instruction = gr.Textbox(
|
74 |
label="Editing Instructions",
|
75 |
placeholder="Describe the changes you want to make to the image..."
|
76 |
)
|
77 |
|
78 |
+
# Clear button
|
79 |
+
with gr.Row():
|
80 |
+
clear_btn = gr.Button("Clear")
|
81 |
+
submit_btn = gr.Button("Apply Edit", variant="primary")
|
82 |
|
83 |
# Set up the event handlers
|
84 |
submit_btn.click(
|
|
|
93 |
outputs=[input_image]
|
94 |
)
|
95 |
|
96 |
+
# Bind the clear button's click event to only clear the instruction textbox.
|
97 |
+
clear_btn.click(
|
98 |
+
fn=clear_instruction,
|
99 |
+
inputs=[],
|
100 |
+
outputs=[instruction]
|
101 |
+
)
|
102 |
+
|
103 |
if __name__ == "__main__":
|
104 |
demo.launch()
|
105 |
|