Update app.py
Browse files
app.py
CHANGED
|
@@ -237,11 +237,20 @@ def upload_file(filepath):
|
|
| 237 |
b2 = gr.DownloadButton("Download outline image as PNG", visible=False)
|
| 238 |
return img, filepath, b1, b2
|
| 239 |
|
| 240 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
|
| 242 |
with gr.Blocks(title = "Hello",
|
| 243 |
css=".gradio-container {background:purple;}") as demo:
|
| 244 |
|
|
|
|
| 245 |
with gr.Row():
|
| 246 |
with gr.Column(scale=2):
|
| 247 |
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>""")
|
|
@@ -273,10 +282,11 @@ with gr.Blocks(title = "Hello",
|
|
| 273 |
sample_list = []
|
| 274 |
for j in range(23):
|
| 275 |
sample_list.append("samples/img%0.2d.png"%j)
|
| 276 |
-
gr.Examples(sample_list, inputs=
|
| 277 |
|
| 278 |
-
|
| 279 |
-
|
|
|
|
| 280 |
|
| 281 |
#down_btn.click(download_function, None, [down_btn, down_btn2])
|
| 282 |
|
|
|
|
| 237 |
b2 = gr.DownloadButton("Download outline image as PNG", visible=False)
|
| 238 |
return img, filepath, b1, b2
|
| 239 |
|
| 240 |
+
|
| 241 |
+
def update_image(filepath):
|
| 242 |
+
img = imread(filepath)
|
| 243 |
+
img = normalize99(img)
|
| 244 |
+
img = np.clip(img, 0, 1)
|
| 245 |
+
|
| 246 |
+
#b1 = gr.DownloadButton("Download masks as TIFF", visible=False)
|
| 247 |
+
#b2 = gr.DownloadButton("Download outline image as PNG", visible=False)
|
| 248 |
+
return input_image, filepath#, b1, b2
|
| 249 |
|
| 250 |
with gr.Blocks(title = "Hello",
|
| 251 |
css=".gradio-container {background:purple;}") as demo:
|
| 252 |
|
| 253 |
+
filepath = ""
|
| 254 |
with gr.Row():
|
| 255 |
with gr.Column(scale=2):
|
| 256 |
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>""")
|
|
|
|
| 282 |
sample_list = []
|
| 283 |
for j in range(23):
|
| 284 |
sample_list.append("samples/img%0.2d.png"%j)
|
| 285 |
+
gr.Examples(sample_list, inputs=input_image, examples_per_page=25)
|
| 286 |
|
| 287 |
+
input_image.change(update_image, input_image, [input_image, filepath])
|
| 288 |
+
#up_btn.upload(upload_file, up_btn, [input_image, up_btn, down_btn, down_btn2])
|
| 289 |
+
send_btn.click(cellpose_segment, [filepath, resize], [img_outlines, img_overlay, flows, down_btn, down_btn2])
|
| 290 |
|
| 291 |
#down_btn.click(download_function, None, [down_btn, down_btn2])
|
| 292 |
|