mouseland commited on
Commit
9e13cfa
·
verified ·
1 Parent(s): a7916aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -254,7 +254,11 @@ def update_image(filepath):
254
  #b2 = gr.DownloadButton("Download outline image as PNG", visible=False)
255
  for f in filepath:
256
  print(f)
257
- return filepath[-1] #, b1, b2
 
 
 
 
258
 
259
 
260
  def update_button(filepath):
@@ -264,7 +268,10 @@ def update_button(filepath):
264
 
265
  #b1 = gr.DownloadButton("Download masks as TIFF", visible=False)
266
  #b2 = gr.DownloadButton("Download outline image as PNG", visible=False)
267
- return [filepath]#, b1, b2
 
 
 
268
 
269
  with gr.Blocks(title = "Hello",
270
  css=".gradio-container {background:purple;}") as demo:
@@ -287,15 +294,10 @@ with gr.Blocks(title = "Hello",
287
 
288
  #gr.HTML("""<h4 style="color:white;"> Note2: Only the first image of a tif will display the segmentations, but you can download segmentations for all planes. </h4>""")
289
 
290
-
291
-
292
  with gr.Column(scale=1):
293
  send_btn = gr.Button("Run Cellpose-SAM")
294
  down_btn = gr.DownloadButton("Download masks (TIF)", visible=False)
295
  down_btn2 = gr.DownloadButton("Download outlines (PNG)", visible=False)
296
-
297
-
298
-
299
 
300
  with gr.Column(scale=2):
301
  img_outlines = gr.Image(label = "Outlines", type = "pil", format = 'png') #, width = "50vw", height = "20vw")
@@ -308,8 +310,8 @@ with gr.Blocks(title = "Hello",
308
  sample_list.append("samples/img%0.2d.png"%j)
309
  gr.Examples(sample_list, fn = update_button, inputs=input_image, outputs = up_btn, examples_per_page=25, label = "Click on an example to try it")
310
 
311
- input_image.upload(update_button, input_image, up_btn)
312
- up_btn.upload(update_image, up_btn, input_image)
313
  send_btn.click(cellpose_segment, [up_btn, resize], [img_outlines, flows, down_btn, down_btn2])
314
 
315
  #down_btn.click(download_function, None, [down_btn, down_btn2])
 
254
  #b2 = gr.DownloadButton("Download outline image as PNG", visible=False)
255
  for f in filepath:
256
  print(f)
257
+
258
+ im1 = gr.Image(label = "Outlines", type = "pil", format = 'png') #, width = "50vw", height = "20vw")
259
+ im2 = gr.Image(label = "Cellpose flows", type = "pil", format = 'png') #, width = "50vw", height = "20vw")
260
+
261
+ return filepath[-1] , im1, im2
262
 
263
 
264
  def update_button(filepath):
 
268
 
269
  #b1 = gr.DownloadButton("Download masks as TIFF", visible=False)
270
  #b2 = gr.DownloadButton("Download outline image as PNG", visible=False)
271
+ im1 = gr.Image(label = "Outlines", type = "pil", format = 'png') #, width = "50vw", height = "20vw")
272
+ im2 = gr.Image(label = "Cellpose flows", type = "pil", format = 'png') #, width = "50vw", height = "20vw")
273
+
274
+ return [filepath] , im1, im2
275
 
276
  with gr.Blocks(title = "Hello",
277
  css=".gradio-container {background:purple;}") as demo:
 
294
 
295
  #gr.HTML("""<h4 style="color:white;"> Note2: Only the first image of a tif will display the segmentations, but you can download segmentations for all planes. </h4>""")
296
 
 
 
297
  with gr.Column(scale=1):
298
  send_btn = gr.Button("Run Cellpose-SAM")
299
  down_btn = gr.DownloadButton("Download masks (TIF)", visible=False)
300
  down_btn2 = gr.DownloadButton("Download outlines (PNG)", visible=False)
 
 
 
301
 
302
  with gr.Column(scale=2):
303
  img_outlines = gr.Image(label = "Outlines", type = "pil", format = 'png') #, width = "50vw", height = "20vw")
 
310
  sample_list.append("samples/img%0.2d.png"%j)
311
  gr.Examples(sample_list, fn = update_button, inputs=input_image, outputs = up_btn, examples_per_page=25, label = "Click on an example to try it")
312
 
313
+ input_image.upload(update_button, input_image, [up_btn, img_outlines, flows])
314
+ up_btn.upload(update_image, up_btn, [input_image, img_outlines, flows])
315
  send_btn.click(cellpose_segment, [up_btn, resize], [img_outlines, flows, down_btn, down_btn2])
316
 
317
  #down_btn.click(download_function, None, [down_btn, down_btn2])