Update app.py
Browse files
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 =
|
|
|
|
| 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.
|
| 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)
|