Update app.py
Browse files
app.py
CHANGED
|
@@ -11,6 +11,10 @@ from cellpose.io import imread, imsave
|
|
| 11 |
|
| 12 |
from huggingface_hub import hf_hub_download
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
# @title Data retrieval
|
| 15 |
def download_weights():
|
| 16 |
return hf_hub_download(repo_id="mouseland/cellpose-sam", filename="cpsam")
|
|
@@ -258,7 +262,7 @@ def update_image(filepath):
|
|
| 258 |
for f in filepath:
|
| 259 |
print(f)
|
| 260 |
|
| 261 |
-
return filepath[-1]
|
| 262 |
|
| 263 |
|
| 264 |
def update_button(filepath):
|
|
@@ -269,7 +273,7 @@ def update_button(filepath):
|
|
| 269 |
#b1 = gr.DownloadButton("Download masks as TIFF", visible=False)
|
| 270 |
#b2 = gr.DownloadButton("Download outline image as PNG", visible=False)
|
| 271 |
|
| 272 |
-
return [filepath]
|
| 273 |
|
| 274 |
with gr.Blocks(title = "Hello",
|
| 275 |
css=".gradio-container {background:purple;}") as demo:
|
|
@@ -298,19 +302,19 @@ with gr.Blocks(title = "Hello",
|
|
| 298 |
down_btn2 = gr.DownloadButton("Download outlines (PNG)", visible=False)
|
| 299 |
|
| 300 |
with gr.Column(scale=2):
|
| 301 |
-
|
| 302 |
#img_overlay = gr.Image(label = "Overlay", type = "pil", format = 'png') #, width = "50vw", height = "20vw")
|
| 303 |
-
flows = gr.Image(label = "Cellpose flows", type = "filepath", format = 'png') #, width = "50vw", height = "20vw")
|
| 304 |
|
| 305 |
|
| 306 |
sample_list = []
|
| 307 |
for j in range(23):
|
| 308 |
sample_list.append("samples/img%0.2d.png"%j)
|
| 309 |
-
gr.Examples(sample_list, fn = update_button, inputs=input_image, outputs = [up_btn], examples_per_page=25, label = "Click on an example to try it")
|
| 310 |
|
| 311 |
-
input_image.upload(update_button, input_image, [up_btn])
|
| 312 |
-
up_btn.upload(update_image, up_btn, [input_image])
|
| 313 |
-
send_btn.click(cellpose_segment, [up_btn, resize], [
|
| 314 |
|
| 315 |
#down_btn.click(download_function, None, [down_btn, down_btn2])
|
| 316 |
|
|
|
|
| 11 |
|
| 12 |
from huggingface_hub import hf_hub_download
|
| 13 |
|
| 14 |
+
img = np.zeros((384, 512))
|
| 15 |
+
fp0 = "0.png"
|
| 16 |
+
imsave(fp0, img)
|
| 17 |
+
|
| 18 |
# @title Data retrieval
|
| 19 |
def download_weights():
|
| 20 |
return hf_hub_download(repo_id="mouseland/cellpose-sam", filename="cpsam")
|
|
|
|
| 262 |
for f in filepath:
|
| 263 |
print(f)
|
| 264 |
|
| 265 |
+
return filepath[-1], fp0, fp0
|
| 266 |
|
| 267 |
|
| 268 |
def update_button(filepath):
|
|
|
|
| 273 |
#b1 = gr.DownloadButton("Download masks as TIFF", visible=False)
|
| 274 |
#b2 = gr.DownloadButton("Download outline image as PNG", visible=False)
|
| 275 |
|
| 276 |
+
return [filepath], fp0, fp0
|
| 277 |
|
| 278 |
with gr.Blocks(title = "Hello",
|
| 279 |
css=".gradio-container {background:purple;}") as demo:
|
|
|
|
| 302 |
down_btn2 = gr.DownloadButton("Download outlines (PNG)", visible=False)
|
| 303 |
|
| 304 |
with gr.Column(scale=2):
|
| 305 |
+
outlines = gr.Image(label = "Outlines", type = "filepath", format = 'png', value = fp0) #, width = "50vw", height = "20vw")
|
| 306 |
#img_overlay = gr.Image(label = "Overlay", type = "pil", format = 'png') #, width = "50vw", height = "20vw")
|
| 307 |
+
flows = gr.Image(label = "Cellpose flows", type = "filepath", format = 'png', value = fp0) #, width = "50vw", height = "20vw")
|
| 308 |
|
| 309 |
|
| 310 |
sample_list = []
|
| 311 |
for j in range(23):
|
| 312 |
sample_list.append("samples/img%0.2d.png"%j)
|
| 313 |
+
gr.Examples(sample_list, fn = update_button, inputs=input_image, outputs = [up_btn, outlines, flows], examples_per_page=25, label = "Click on an example to try it")
|
| 314 |
|
| 315 |
+
input_image.upload(update_button, input_image, [up_btn, outlines, flows])
|
| 316 |
+
up_btn.upload(update_image, up_btn, [input_image, outlines, flows])
|
| 317 |
+
send_btn.click(cellpose_segment, [up_btn, resize], [outlines, flows, down_btn, down_btn2])
|
| 318 |
|
| 319 |
#down_btn.click(download_function, None, [down_btn, down_btn2])
|
| 320 |
|