mouseland commited on
Commit
0b8b42c
·
verified ·
1 Parent(s): 4397a87

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -164,8 +164,8 @@ def run_model_gpu1000(img):
164
  return masks, flows
165
 
166
  #@spaces.GPU(duration=10)
167
- def cellpose_segment(img_pil, resize = 1000):
168
- img_input = imread(img_pil)
169
  print(img_input.shape)
170
  #img_input = np.array(img_pil)
171
  img = image_resize(img_input, resize = resize)
@@ -213,8 +213,8 @@ def cellpose_segment(img_pil, resize = 1000):
213
  #pil_masks = Image.fromarray(masks.astype('int32'))
214
  #pil_masks.save(fname_mask)
215
 
216
- fname_out = os.path.splitext(img_pil)[0]+"_outlines.png"
217
- fname_masks = os.path.splitext(img_pil)[0]+"_masks.tif"
218
 
219
  imsave(fname_masks, masks)
220
 
@@ -250,7 +250,7 @@ def upload_file(filepath):
250
 
251
  #b1 = gr.DownloadButton("Download masks as TIFF", visible=False)
252
  #b2 = gr.DownloadButton("Download outline image as PNG", visible=False)
253
- return filepath #, b1, b2
254
 
255
 
256
  def update_image(filepath):
@@ -260,7 +260,7 @@ def update_image(filepath):
260
 
261
  #b1 = gr.DownloadButton("Download masks as TIFF", visible=False)
262
  #b2 = gr.DownloadButton("Download outline image as PNG", visible=False)
263
- return filepath#, b1, b2
264
 
265
  with gr.Blocks(title = "Hello",
266
  css=".gradio-container {background:purple;}") as demo:
 
164
  return masks, flows
165
 
166
  #@spaces.GPU(duration=10)
167
+ def cellpose_segment(filepath, resize = 1000):
168
+ img_input = imread(filepath[0])
169
  print(img_input.shape)
170
  #img_input = np.array(img_pil)
171
  img = image_resize(img_input, resize = resize)
 
213
  #pil_masks = Image.fromarray(masks.astype('int32'))
214
  #pil_masks.save(fname_mask)
215
 
216
+ fname_out = os.path.splitext(filepath[0])[0]+"_outlines.png"
217
+ fname_masks = os.path.splitext(filepath[0])[0]+"_masks.tif"
218
 
219
  imsave(fname_masks, masks)
220
 
 
250
 
251
  #b1 = gr.DownloadButton("Download masks as TIFF", visible=False)
252
  #b2 = gr.DownloadButton("Download outline image as PNG", visible=False)
253
+ return [filepath] #, b1, b2
254
 
255
 
256
  def update_image(filepath):
 
260
 
261
  #b1 = gr.DownloadButton("Download masks as TIFF", visible=False)
262
  #b2 = gr.DownloadButton("Download outline image as PNG", visible=False)
263
+ return filepath[0]#, b1, b2
264
 
265
  with gr.Blocks(title = "Hello",
266
  css=".gradio-container {background:purple;}") as demo: