mouseland commited on
Commit
93bdd17
·
verified ·
1 Parent(s): 7513a75

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -220,13 +220,16 @@ def cellpose_segment(filepath, resize = 1000):
220
  fname_out = os.path.splitext(filepath[-1])[0]+"_outlines.png"
221
  outpix.save(fname_out) #"outlines.png")
222
 
 
 
 
223
  if len(filepath)>1:
224
  b1 = gr.DownloadButton(visible=True, value = zip_path)
225
  else:
226
  b1 = gr.DownloadButton(visible=True, value = fname_masks)
227
  b2 = gr.DownloadButton(visible=True, value = fname_out) #"outlines.png")
228
 
229
- return outpix, flows, b1, b2
230
 
231
  # Gradio Interface
232
  #iface = gr.Interface(
@@ -255,10 +258,7 @@ def update_image(filepath):
255
  for f in filepath:
256
  print(f)
257
 
258
- im1 = gr.Image(label = "Outlines", type = "pil", format = 'png', visible=False) #, width = "50vw", height = "20vw")
259
- im2 = gr.Image(label = "Cellpose flows", type = "pil", format = 'png', visible=False) #, width = "50vw", height = "20vw")
260
-
261
- return filepath[-1] , im1, im2
262
 
263
 
264
  def update_button(filepath):
@@ -268,10 +268,8 @@ 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', visible=False) #, width = "50vw", height = "20vw")
272
- im2 = gr.Image(label = "Cellpose flows", type = "pil", format = 'png', visible=False) #, 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:
@@ -300,9 +298,9 @@ with gr.Blocks(title = "Hello",
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', visible=False) #, width = "50vw", height = "20vw")
304
  #img_overlay = gr.Image(label = "Overlay", type = "pil", format = 'png') #, width = "50vw", height = "20vw")
305
- flows = gr.Image(label = "Cellpose flows", type = "pil", format = 'png', visible=False) #, width = "50vw", height = "20vw")
306
 
307
 
308
  sample_list = []
 
220
  fname_out = os.path.splitext(filepath[-1])[0]+"_outlines.png"
221
  outpix.save(fname_out) #"outlines.png")
222
 
223
+ fname_flows = os.path.splitext(filepath[-1])[0]+"_flows.png"
224
+ flows.save(fname_flows) #"outlines.png")
225
+
226
  if len(filepath)>1:
227
  b1 = gr.DownloadButton(visible=True, value = zip_path)
228
  else:
229
  b1 = gr.DownloadButton(visible=True, value = fname_masks)
230
  b2 = gr.DownloadButton(visible=True, value = fname_out) #"outlines.png")
231
 
232
+ return fname_out, fname_flows, b1, b2
233
 
234
  # Gradio Interface
235
  #iface = gr.Interface(
 
258
  for f in filepath:
259
  print(f)
260
 
261
+ return filepath[-1] , None, None
 
 
 
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
 
272
+ return [filepath] , None, None
273
 
274
  with gr.Blocks(title = "Hello",
275
  css=".gradio-container {background:purple;}") as demo:
 
298
  down_btn2 = gr.DownloadButton("Download outlines (PNG)", visible=False)
299
 
300
  with gr.Column(scale=2):
301
+ img_outlines = gr.Image(label = "Outlines", type = "filepath", format = 'png', visible=False) #, width = "50vw", height = "20vw")
302
  #img_overlay = gr.Image(label = "Overlay", type = "pil", format = 'png') #, width = "50vw", height = "20vw")
303
+ flows = gr.Image(label = "Cellpose flows", type = "filepath", format = 'png', visible=False) #, width = "50vw", height = "20vw")
304
 
305
 
306
  sample_list = []