Update app.py
Browse files
app.py
CHANGED
@@ -98,8 +98,22 @@ def update_filename(image):
|
|
98 |
return filename
|
99 |
return ""
|
100 |
|
101 |
-
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
if __name__ == '__main__':
|
105 |
demo.launch()
|
|
|
98 |
return filename
|
99 |
return ""
|
100 |
|
101 |
+
with gr.Blocks() as demo:
|
102 |
+
with gr.Row():
|
103 |
+
input_image = gr.Image(type='pil', label='input')
|
104 |
+
filename_output = gr.Textbox(label="Image Filename", interactive=False)
|
105 |
+
|
106 |
+
# Define the output
|
107 |
+
output_image = gr.Image(type='pil', label='output')
|
108 |
+
|
109 |
+
# Define the interaction flow: when the image is uploaded, update the filename
|
110 |
+
input_image.change(update_filename, inputs=input_image, outputs=filename_output)
|
111 |
+
|
112 |
+
# Set the function to process the image with the filename
|
113 |
+
input_image.submit(process_img, inputs=[input_image, filename_output], outputs=output_image)
|
114 |
+
|
115 |
+
# Provide examples
|
116 |
+
demo.examples = examples
|
117 |
|
118 |
if __name__ == '__main__':
|
119 |
demo.launch()
|