mouseland commited on
Commit
8742230
·
verified ·
1 Parent(s): e5fd1c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -7,7 +7,7 @@ from matplotlib.colors import hsv_to_rgb
7
  import matplotlib.pyplot as plt
8
  import os, io, base64
9
  from PIL import Image
10
-
11
 
12
  # @title Data retrieval
13
  def download_weights():
@@ -133,7 +133,8 @@ def run_model_gpu(img):
133
 
134
  #@spaces.GPU(duration=10)
135
  def cellpose_segment(img_pil):
136
- img_input = np.array(img_pil)
 
137
  img = image_resize(img_input)
138
  masks, flows = run_model_gpu(img)
139
  #masks, flows, _ = model.eval(img, channels=[0,0])
@@ -199,7 +200,7 @@ with gr.Blocks(title = "Hello",
199
  gr.HTML("""<h4 style="color:white;">You may need to refresh/login for 5 minutes of free GPU compute time/day. </h4>""")
200
  gr.HTML("""<h4 style="color:white;">"pip install cellpose" for full functionality. </h4>""")
201
 
202
- input_image = gr.ImageEditor(label = "Input image")#, type = "pil")
203
  send_btn = gr.Button("Run Cellpose-SAM")
204
  with gr.Row():
205
  down_btn = gr.DownloadButton("Download masks (TIFF)", visible=False)
 
7
  import matplotlib.pyplot as plt
8
  import os, io, base64
9
  from PIL import Image
10
+ from cellpose.io import imread
11
 
12
  # @title Data retrieval
13
  def download_weights():
 
133
 
134
  #@spaces.GPU(duration=10)
135
  def cellpose_segment(img_pil):
136
+ img_input = imread(img_pil)
137
+ #img_input = np.array(img_pil)
138
  img = image_resize(img_input)
139
  masks, flows = run_model_gpu(img)
140
  #masks, flows, _ = model.eval(img, channels=[0,0])
 
200
  gr.HTML("""<h4 style="color:white;">You may need to refresh/login for 5 minutes of free GPU compute time/day. </h4>""")
201
  gr.HTML("""<h4 style="color:white;">"pip install cellpose" for full functionality. </h4>""")
202
 
203
+ input_image = gr.Image(label = "Input image", type = "str")
204
  send_btn = gr.Button("Run Cellpose-SAM")
205
  with gr.Row():
206
  down_btn = gr.DownloadButton("Download masks (TIFF)", visible=False)