reab5555 commited on
Commit
71c000d
·
verified ·
1 Parent(s): 856356f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -5
app.py CHANGED
@@ -57,20 +57,30 @@ def launch_app():
57
  progress_bar = gr.Progress()
58
 
59
  with gr.Row():
60
- download_button = gr.DownloadButton(label="Download Cleaned CSV", visible=False)
 
61
 
62
  with gr.Row():
63
  output_gallery = gr.Gallery(label="Visualization Results", show_label=True, elem_id="gallery", columns=[2],
64
  rows=[2], object_fit="contain", height="auto")
65
 
66
- def process_and_show_download(file):
67
  cleaned_csv_path, image_files = clean_and_visualize(file, progress=progress_bar)
68
- return gr.DownloadButton.update(value=cleaned_csv_path, visible=True), image_files
 
 
 
69
 
70
  clean_button.click(
71
- fn=process_and_show_download,
72
  inputs=file_input,
73
- outputs=[download_button, output_gallery]
 
 
 
 
 
 
74
  )
75
 
76
  app.launch()
 
57
  progress_bar = gr.Progress()
58
 
59
  with gr.Row():
60
+ download_path = gr.State("")
61
+ download_button = gr.Button("Download Cleaned CSV", visible=False)
62
 
63
  with gr.Row():
64
  output_gallery = gr.Gallery(label="Visualization Results", show_label=True, elem_id="gallery", columns=[2],
65
  rows=[2], object_fit="contain", height="auto")
66
 
67
+ def process_and_prepare_download(file):
68
  cleaned_csv_path, image_files = clean_and_visualize(file, progress=progress_bar)
69
+ return cleaned_csv_path, image_files, gr.Button(visible=True)
70
+
71
+ def trigger_download(path):
72
+ return gr.File.update(value=path, visible=True)
73
 
74
  clean_button.click(
75
+ fn=process_and_prepare_download,
76
  inputs=file_input,
77
+ outputs=[download_path, output_gallery, download_button]
78
+ )
79
+
80
+ download_button.click(
81
+ fn=trigger_download,
82
+ inputs=[download_path],
83
+ outputs=[gr.File(label="Cleaned CSV", visible=False)]
84
  )
85
 
86
  app.launch()