Update app.py
Browse files
app.py
CHANGED
|
@@ -31,8 +31,8 @@ def download_weights():
|
|
| 31 |
fid.write(r.content)
|
| 32 |
|
| 33 |
try:
|
| 34 |
-
|
| 35 |
-
model = models.CellposeModel(gpu=True, pretrained_model="
|
| 36 |
except Exception as e:
|
| 37 |
print(f"Error loading model: {e}")
|
| 38 |
exit(1)
|
|
@@ -128,22 +128,22 @@ def image_resize(img, resize=400):
|
|
| 128 |
|
| 129 |
@spaces.GPU(duration=10)
|
| 130 |
def run_model_gpu(img):
|
| 131 |
-
masks, flows, _ = model.eval(img
|
| 132 |
return masks, flows
|
| 133 |
|
| 134 |
@spaces.GPU(duration=60)
|
| 135 |
def run_model_gpu60(img):
|
| 136 |
-
masks, flows, _ = model.eval(img
|
| 137 |
return masks, flows
|
| 138 |
|
| 139 |
@spaces.GPU(duration=240)
|
| 140 |
def run_model_gpu240(img):
|
| 141 |
-
masks, flows, _ = model.eval(img
|
| 142 |
return masks, flows
|
| 143 |
|
| 144 |
@spaces.GPU(duration=1000)
|
| 145 |
def run_model_gpu1000(img):
|
| 146 |
-
masks, flows, _ = model.eval(img
|
| 147 |
return masks, flows
|
| 148 |
|
| 149 |
#@spaces.GPU(duration=10)
|
|
@@ -227,7 +227,7 @@ with gr.Blocks(title = "Hello",
|
|
| 227 |
with gr.Row():
|
| 228 |
with gr.Column(scale=2):
|
| 229 |
gr.HTML("""<div style="font-family:'Times New Roman', 'Serif'; font-size:16pt; font-weight:bold; text-align:center; color:white;">Cellpose-SAM for cellular segmentation</div>""")
|
| 230 |
-
gr.HTML("""<h4 style="color:white;">You may need to refresh/login for 5 minutes of free GPU compute
|
| 231 |
gr.HTML("""<h4 style="color:white;">"pip install cellpose" for full functionality. </h4>""")
|
| 232 |
|
| 233 |
input_image = gr.Image(label = "Input image", type = "filepath")
|
|
|
|
| 31 |
fid.write(r.content)
|
| 32 |
|
| 33 |
try:
|
| 34 |
+
download_weights()
|
| 35 |
+
model = models.CellposeModel(gpu=True, pretrained_model="cpsam")
|
| 36 |
except Exception as e:
|
| 37 |
print(f"Error loading model: {e}")
|
| 38 |
exit(1)
|
|
|
|
| 128 |
|
| 129 |
@spaces.GPU(duration=10)
|
| 130 |
def run_model_gpu(img):
|
| 131 |
+
masks, flows, _ = model.eval(img)#, channels = [0,0])
|
| 132 |
return masks, flows
|
| 133 |
|
| 134 |
@spaces.GPU(duration=60)
|
| 135 |
def run_model_gpu60(img):
|
| 136 |
+
masks, flows, _ = model.eval(img)#, channels = [0,0])
|
| 137 |
return masks, flows
|
| 138 |
|
| 139 |
@spaces.GPU(duration=240)
|
| 140 |
def run_model_gpu240(img):
|
| 141 |
+
masks, flows, _ = model.eval(img)#, channels = [0,0])
|
| 142 |
return masks, flows
|
| 143 |
|
| 144 |
@spaces.GPU(duration=1000)
|
| 145 |
def run_model_gpu1000(img):
|
| 146 |
+
masks, flows, _ = model.eval(img)#, channels = [0,0])
|
| 147 |
return masks, flows
|
| 148 |
|
| 149 |
#@spaces.GPU(duration=10)
|
|
|
|
| 227 |
with gr.Row():
|
| 228 |
with gr.Column(scale=2):
|
| 229 |
gr.HTML("""<div style="font-family:'Times New Roman', 'Serif'; font-size:16pt; font-weight:bold; text-align:center; color:white;">Cellpose-SAM for cellular segmentation</div>""")
|
| 230 |
+
gr.HTML("""<h4 style="color:white;">You may need to refresh/login for 5 minutes of free GPU compute/day. </h4>""")
|
| 231 |
gr.HTML("""<h4 style="color:white;">"pip install cellpose" for full functionality. </h4>""")
|
| 232 |
|
| 233 |
input_image = gr.Image(label = "Input image", type = "filepath")
|