kerzel commited on
Commit
619b52c
·
1 Parent(s): 237238e

change button logic to static paths

Browse files
Files changed (1) hide show
  1. app.py +39 -6
app.py CHANGED
@@ -11,6 +11,11 @@ logging.getLogger().setLevel(logging.INFO)
11
 
12
  from tensorflow import keras
13
 
 
 
 
 
 
14
  #image_threshold = 20
15
 
16
  model1_windowsize = [250,250]
@@ -126,7 +131,15 @@ def damage_classification(SEM_image,image_threshold, model1_threshold, model2_th
126
  df.to_csv(csv_path)
127
 
128
 
129
- return image, image_path, csv_path
 
 
 
 
 
 
 
 
130
 
131
  ## ---------------------------------------------------------------------------------------------------------------
132
  ## main app interface
@@ -152,9 +165,11 @@ with gr.Blocks() as app:
152
 
153
 
154
  button = gr.Button("Classify")
155
-
156
-
157
  output_image = gr.Image()
 
 
 
 
158
  with gr.Row():
159
  download_image = gr.DownloadButton(label='Download Image')
160
  download_csv = gr.DownloadButton(label='Download Damage List')
@@ -163,9 +178,27 @@ with gr.Blocks() as app:
163
 
164
 
165
 
166
- button.click(damage_classification,
167
- inputs=[image_input, cluster_threshold_input, model1_threshold_input, model2_threshold_input],
168
- outputs=[output_image, download_image, download_csv])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
 
170
 
171
 
 
11
 
12
  from tensorflow import keras
13
 
14
+
15
+ IMAGE_PATH = 'classified_damage_sites.png'
16
+ CSV_PATH = 'classified_damage_sites.csv'
17
+
18
+
19
  #image_threshold = 20
20
 
21
  model1_windowsize = [250,250]
 
131
  df.to_csv(csv_path)
132
 
133
 
134
+ return image# , image_path, csv_path
135
+
136
+
137
+ def get_image_file():
138
+ return IMAGE_PATH
139
+
140
+ def get_csv_file():
141
+ return CSV_PATH
142
+
143
 
144
  ## ---------------------------------------------------------------------------------------------------------------
145
  ## main app interface
 
165
 
166
 
167
  button = gr.Button("Classify")
 
 
168
  output_image = gr.Image()
169
+
170
+ download_image_btn = gr.DownloadButton(label="Download Image")
171
+ download_csv_btn = gr.DownloadButton(label="Download Damage List")
172
+
173
  with gr.Row():
174
  download_image = gr.DownloadButton(label='Download Image')
175
  download_csv = gr.DownloadButton(label='Download Damage List')
 
178
 
179
 
180
 
181
+ # button.click(damage_classification,
182
+ # inputs=[image_input, cluster_threshold_input, model1_threshold_input, model2_threshold_input],
183
+ # outputs=[output_image, download_image, download_csv])
184
+
185
+ button.click(
186
+ damage_classification,
187
+ inputs=[image_input, cluster_threshold_input, model1_threshold_input, model2_threshold_input],
188
+ outputs=[output_image]
189
+ )
190
+
191
+ download_image_btn.click(
192
+ get_image_file,
193
+ inputs=[],
194
+ outputs=[download_image_btn]
195
+ )
196
+
197
+ download_csv_btn.click(
198
+ get_csv_file,
199
+ inputs=[],
200
+ outputs=[download_csv_btn]
201
+ )
202
 
203
 
204