Update app.py
Browse files
app.py
CHANGED
|
@@ -132,7 +132,8 @@ def run_model_gpu(img):
|
|
| 132 |
return masks, flows
|
| 133 |
|
| 134 |
#@spaces.GPU(duration=10)
|
| 135 |
-
def cellpose_segment(
|
|
|
|
| 136 |
img = image_resize(img_input)
|
| 137 |
masks, flows = run_model_gpu(img)
|
| 138 |
#masks, flows, _ = model.eval(img, channels=[0,0])
|
|
@@ -166,8 +167,9 @@ def cellpose_segment(img_input):
|
|
| 166 |
|
| 167 |
pil_masks = Image.fromarray(masks.astype('int32'))
|
| 168 |
pil_masks.save("masks.tiff")
|
|
|
|
| 169 |
|
| 170 |
-
outpix.save("outlines.png")
|
| 171 |
|
| 172 |
b1 = gr.DownloadButton(visible=True, value = "masks.tiff")
|
| 173 |
b2 = gr.DownloadButton(visible=True, value = "outlines.png")
|
|
@@ -197,7 +199,7 @@ with gr.Blocks(title = "Hello",
|
|
| 197 |
gr.HTML("""<h4 style="color:white;">You may need to refresh/login for 5 minutes of free GPU compute time/day. </h4>""")
|
| 198 |
gr.HTML("""<h4 style="color:white;">"pip install cellpose" for full functionality. </h4>""")
|
| 199 |
|
| 200 |
-
input_image = gr.Image(label = "Input image", type = "
|
| 201 |
send_btn = gr.Button("Run Cellpose-SAM")
|
| 202 |
with gr.Row():
|
| 203 |
down_btn = gr.DownloadButton("Download masks (TIFF)", visible=False)
|
|
|
|
| 132 |
return masks, flows
|
| 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])
|
|
|
|
| 167 |
|
| 168 |
pil_masks = Image.fromarray(masks.astype('int32'))
|
| 169 |
pil_masks.save("masks.tiff")
|
| 170 |
+
|
| 171 |
|
| 172 |
+
outpix.save(img_pil.filename) #"outlines.png")
|
| 173 |
|
| 174 |
b1 = gr.DownloadButton(visible=True, value = "masks.tiff")
|
| 175 |
b2 = gr.DownloadButton(visible=True, value = "outlines.png")
|
|
|
|
| 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.Image(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)
|