mouseland commited on
Commit
980a5f7
·
verified ·
1 Parent(s): 0b3906f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -11
app.py CHANGED
@@ -13,8 +13,9 @@ import glob
13
  from huggingface_hub import hf_hub_download
14
 
15
  img = np.zeros((96, 128))
16
- fp0 = "0.png"
17
- imsave(fp0, img)
 
18
 
19
  # data retrieval
20
  def download_weights():
@@ -224,13 +225,8 @@ def cellpose_segment(filepath, resize = 1000,max_iter = 250):
224
  flows = flows.resize((Lx, Ly), resample = Image.BICUBIC)
225
 
226
  fname_out = os.path.splitext(filepath[-1])[0]+"_outlines.png"
227
- try:
228
- os.remove(fname_out)
229
- except:
230
- print('not there')
231
  outpix.save(fname_out) #"outlines.png")
232
- print(fname_out)
233
-
234
  fname_flows = os.path.splitext(filepath[-1])[0]+"_flows.png"
235
  flows.save(fname_flows) #"outlines.png")
236
 
@@ -240,7 +236,7 @@ def cellpose_segment(filepath, resize = 1000,max_iter = 250):
240
  b1 = gr.DownloadButton(visible=True, value = fname_masks)
241
  b2 = gr.DownloadButton(visible=True, value = fname_out) #"outlines.png")
242
 
243
- return fname_out, fname_flows, b1, b2
244
 
245
  # Gradio Interface
246
  #iface = gr.Interface(
@@ -330,9 +326,9 @@ with gr.Blocks(title = "Hello",
330
  down_btn2 = gr.DownloadButton("Download outlines (PNG)", visible=False)
331
 
332
  with gr.Column(scale=2):
333
- outlines = gr.Image(label = "Outlines", type = "filepath", format = 'png', value = fp0) #, width = "50vw", height = "20vw")
334
  #img_overlay = gr.Image(label = "Overlay", type = "pil", format = 'png') #, width = "50vw", height = "20vw")
335
- flows = gr.Image(label = "Cellpose flows", type = "filepath", format = 'png', value = fp0) #, width = "50vw", height = "20vw")
336
 
337
 
338
 
 
13
  from huggingface_hub import hf_hub_download
14
 
15
  img = np.zeros((96, 128))
16
+ fp0 = Image.fromarray(img)
17
+ #fp0 = "0.png"
18
+ #imsave(fp0, img)
19
 
20
  # data retrieval
21
  def download_weights():
 
225
  flows = flows.resize((Lx, Ly), resample = Image.BICUBIC)
226
 
227
  fname_out = os.path.splitext(filepath[-1])[0]+"_outlines.png"
 
 
 
 
228
  outpix.save(fname_out) #"outlines.png")
229
+
 
230
  fname_flows = os.path.splitext(filepath[-1])[0]+"_flows.png"
231
  flows.save(fname_flows) #"outlines.png")
232
 
 
236
  b1 = gr.DownloadButton(visible=True, value = fname_masks)
237
  b2 = gr.DownloadButton(visible=True, value = fname_out) #"outlines.png")
238
 
239
+ return outpix, flows, b1, b2
240
 
241
  # Gradio Interface
242
  #iface = gr.Interface(
 
326
  down_btn2 = gr.DownloadButton("Download outlines (PNG)", visible=False)
327
 
328
  with gr.Column(scale=2):
329
+ outlines = gr.Image(label = "Outlines", type = "pil", format = 'png', value = fp0) #, width = "50vw", height = "20vw")
330
  #img_overlay = gr.Image(label = "Overlay", type = "pil", format = 'png') #, width = "50vw", height = "20vw")
331
+ flows = gr.Image(label = "Cellpose flows", type = "pil", format = 'png', value = fp0) #, width = "50vw", height = "20vw")
332
 
333
 
334