Dharini Baskaran commited on
Commit
4bb5406
·
1 Parent(s): f8b59fe
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -42,6 +42,10 @@ sys.path.append(MODEL_DIR)
42
  from rcnn_model.scripts.rcnn_run import main, write_config
43
 
44
  cfg = write_config()
 
 
 
 
45
 
46
  def predict(uploaded_file_path):
47
  if uploaded_file_path is None:
@@ -99,6 +103,12 @@ with gr.Blocks() as demo:
99
 
100
  error_output = gr.Textbox(label="Error Message", visible=False)
101
 
 
 
 
 
 
 
102
  run_button.click(
103
  lambda x: (x, gr.update(interactive=False)),
104
  inputs=[uploaded_file],
 
42
  from rcnn_model.scripts.rcnn_run import main, write_config
43
 
44
  cfg = write_config()
45
+ def clear_outputs_on_upload(uploaded_file_path):
46
+ if uploaded_file_path is None:
47
+ return None, None, None, None, None
48
+ return gr.update(value=uploaded_file_path), None, None, None, None
49
 
50
  def predict(uploaded_file_path):
51
  if uploaded_file_path is None:
 
103
 
104
  error_output = gr.Textbox(label="Error Message", visible=False)
105
 
106
+ uploaded_file.change(
107
+ clear_outputs_on_upload,
108
+ inputs=[uploaded_file],
109
+ outputs=[uploaded_file, output_image, output_json, download_button, uploaded_image_display]
110
+ )
111
+
112
  run_button.click(
113
  lambda x: (x, gr.update(interactive=False)),
114
  inputs=[uploaded_file],