mouseland commited on
Commit
86bfbdc
·
verified ·
1 Parent(s): bce0fa8

Update app.py

Browse files

PIL image test

Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -92,14 +92,15 @@ def image_resize(img, resize=400):
92
  return img
93
 
94
 
95
- @spaces.GPU(duration=10)
96
- def run_model_gpu(model, img):
97
- masks, flows, _ = model.eval(img, channels=[0,0])
98
- return masks, flows
99
 
100
  def cellpose_segment(img_input):
101
  img = image_resize(img_input)
102
- masks, flows = run_model_gpu(model, img)
 
103
  flows = flows[0]
104
  # masks = np.zeros(img.shape[:2])
105
  # flows = np.zeros_like(img)
@@ -111,7 +112,7 @@ def cellpose_segment(img_input):
111
 
112
  outpix = plot_outlines(img_input, masks)
113
  overlay = plot_overlay(img_input, masks)
114
- return outpix, overlay, flows, masks
115
 
116
  # Gradio Interface
117
  iface = gr.Interface(
 
92
  return img
93
 
94
 
95
+ #@spaces.GPU(duration=10)
96
+ #def run_model_gpu(model, img):
97
+ # masks, flows, _ = model.eval(img, channels=[0,0])
98
+ # return masks, flows
99
 
100
  def cellpose_segment(img_input):
101
  img = image_resize(img_input)
102
+ #masks, flows = run_model_gpu(model, img)
103
+ masks, flows, _ = model.eval(img, channels=[0,0])
104
  flows = flows[0]
105
  # masks = np.zeros(img.shape[:2])
106
  # flows = np.zeros_like(img)
 
112
 
113
  outpix = plot_outlines(img_input, masks)
114
  overlay = plot_overlay(img_input, masks)
115
+ return outpix, overlay, flows, Image.fromarray(masks )
116
 
117
  # Gradio Interface
118
  iface = gr.Interface(