Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,7 @@ import matplotlib.pyplot as plt
|
|
| 8 |
import os, io, base64
|
| 9 |
from PIL import Image
|
| 10 |
from cellpose.io import imread, imsave
|
|
|
|
| 11 |
|
| 12 |
# @title Data retrieval
|
| 13 |
def download_weights():
|
|
@@ -223,6 +224,8 @@ def download_function():
|
|
| 223 |
|
| 224 |
def upload_file(filepath):
|
| 225 |
img = imread(filepath)
|
|
|
|
|
|
|
| 226 |
|
| 227 |
return img
|
| 228 |
|
|
@@ -238,8 +241,9 @@ with gr.Blocks(title = "Hello",
|
|
| 238 |
input_image = gr.Image(label = "Input image", type = "numpy")
|
| 239 |
|
| 240 |
with gr.Row():
|
| 241 |
-
|
| 242 |
-
|
|
|
|
| 243 |
|
| 244 |
with gr.Column():
|
| 245 |
send_btn = gr.Button("Run Cellpose-SAM")
|
|
@@ -262,7 +266,7 @@ with gr.Blocks(title = "Hello",
|
|
| 262 |
gr.Examples(sample_list, inputs=input_image, examples_per_page=25)
|
| 263 |
|
| 264 |
up_btn.upload(upload_file, up_btn, input_image)
|
| 265 |
-
send_btn.click(
|
| 266 |
|
| 267 |
#down_btn.click(download_function, None, [down_btn, down_btn2])
|
| 268 |
|
|
|
|
| 8 |
import os, io, base64
|
| 9 |
from PIL import Image
|
| 10 |
from cellpose.io import imread, imsave
|
| 11 |
+
from cellpose.transforms import normalize_img
|
| 12 |
|
| 13 |
# @title Data retrieval
|
| 14 |
def download_weights():
|
|
|
|
| 224 |
|
| 225 |
def upload_file(filepath):
|
| 226 |
img = imread(filepath)
|
| 227 |
+
img = normalize_img(img)
|
| 228 |
+
img = np.clip(img, 0, 1)
|
| 229 |
|
| 230 |
return img
|
| 231 |
|
|
|
|
| 241 |
input_image = gr.Image(label = "Input image", type = "numpy")
|
| 242 |
|
| 243 |
with gr.Row():
|
| 244 |
+
with gr.Column():
|
| 245 |
+
up_btn = gr.UploadButton("Upload (png, jpg, tif etc)", visible=True, file_count = "single")
|
| 246 |
+
resize = gr.Number(label = 'max resize', value = 1000)
|
| 247 |
|
| 248 |
with gr.Column():
|
| 249 |
send_btn = gr.Button("Run Cellpose-SAM")
|
|
|
|
| 266 |
gr.Examples(sample_list, inputs=input_image, examples_per_page=25)
|
| 267 |
|
| 268 |
up_btn.upload(upload_file, up_btn, input_image)
|
| 269 |
+
send_btn.click(cellpose_segment, [up_btn, resize], [img_outlines, img_overlay, flows, down_btn, down_btn2])
|
| 270 |
|
| 271 |
#down_btn.click(download_function, None, [down_btn, down_btn2])
|
| 272 |
|