Ashrafb commited on
Commit
98262b5
·
1 Parent(s): f74e61c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -150,7 +150,6 @@ a {text-decoration-line: underline; font-weight: 600;}
150
  }
151
 
152
  '''
153
-
154
  with gr.Blocks() as block:
155
  with gr.Column(elem_id="col-container"):
156
  gr.HTML(title)
@@ -160,6 +159,8 @@ with gr.Blocks() as block:
160
  # Display the uploaded image from the file input
161
  upload_image = gr.Image(label="Uploaded Image", type='numpy', elem_id='uploaded-img')
162
 
 
 
163
  mode_input = gr.Radio(['classic', 'fast'], label='Select mode', value='fast')
164
  flavor_input = gr.Slider(minimum=2, maximum=24, step=2, value=4, label='best mode max flavors')
165
  submit_btn = gr.Button("Submit")
@@ -173,6 +174,14 @@ with gr.Blocks() as block:
173
 
174
  input_file.upload(display_image)
175
 
 
 
 
 
 
 
 
 
176
  # The inference function remains the same
177
  submit_btn.click(fn=inference, inputs=[input_file, mode_input, flavor_input], outputs=[output_text], api_name="clipi2")
178
 
 
150
  }
151
 
152
  '''
 
153
  with gr.Blocks() as block:
154
  with gr.Column(elem_id="col-container"):
155
  gr.HTML(title)
 
159
  # Display the uploaded image from the file input
160
  upload_image = gr.Image(label="Uploaded Image", type='numpy', elem_id='uploaded-img')
161
 
162
+ display_btn = gr.Button("Display Image") # Button to display the uploaded image
163
+
164
  mode_input = gr.Radio(['classic', 'fast'], label='Select mode', value='fast')
165
  flavor_input = gr.Slider(minimum=2, maximum=24, step=2, value=4, label='best mode max flavors')
166
  submit_btn = gr.Button("Submit")
 
174
 
175
  input_file.upload(display_image)
176
 
177
+ # Function to handle image display upon button click
178
+ def on_display_clicked():
179
+ uploaded_files = input_file.value
180
+ if uploaded_files is not None:
181
+ display_image(uploaded_files[0]["bytes"])
182
+
183
+ display_btn.click(on_display_clicked)
184
+
185
  # The inference function remains the same
186
  submit_btn.click(fn=inference, inputs=[input_file, mode_input, flavor_input], outputs=[output_text], api_name="clipi2")
187