Update app.py
Browse files
app.py
CHANGED
|
@@ -268,18 +268,28 @@ def tif_view(filepath):
|
|
| 268 |
nn = np.minimum(3, img.shape[-1])
|
| 269 |
imgi[:,:,:nn] = img[:,:,:nn]
|
| 270 |
|
| 271 |
-
filepath = fpath+'.png'
|
| 272 |
imsave(filepath, imgi)
|
| 273 |
return filepath
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
|
| 275 |
def update_image(filepath):
|
| 276 |
for f in filepath:
|
| 277 |
f = tif_view(f)
|
| 278 |
-
|
|
|
|
| 279 |
|
| 280 |
def update_button(filepath):
|
| 281 |
filepath = tif_view(filepath)
|
| 282 |
-
|
|
|
|
| 283 |
|
| 284 |
with gr.Blocks(title = "Hello",
|
| 285 |
css=".gradio-container {background:purple;}") as demo:
|
|
@@ -316,10 +326,11 @@ with gr.Blocks(title = "Hello",
|
|
| 316 |
sample_list = []
|
| 317 |
for j in range(23):
|
| 318 |
sample_list.append("samples/img%0.2d.png"%j)
|
|
|
|
| 319 |
gr.Examples(sample_list, fn = update_button, inputs=input_image, outputs = [input_image, up_btn, outlines, flows], examples_per_page=25, label = "Click on an example to try it")
|
| 320 |
-
|
| 321 |
input_image.upload(update_button, input_image, [input_image, up_btn, outlines, flows])
|
| 322 |
up_btn.upload(update_image, up_btn, [input_image, up_btn, outlines, flows])
|
|
|
|
| 323 |
send_btn.click(cellpose_segment, [up_btn, resize], [outlines, flows, down_btn, down_btn2])
|
| 324 |
|
| 325 |
#down_btn.click(download_function, None, [down_btn, down_btn2])
|
|
|
|
| 268 |
nn = np.minimum(3, img.shape[-1])
|
| 269 |
imgi[:,:,:nn] = img[:,:,:nn]
|
| 270 |
|
| 271 |
+
#filepath = fpath+'.png'
|
| 272 |
imsave(filepath, imgi)
|
| 273 |
return filepath
|
| 274 |
+
|
| 275 |
+
def norm_path(filepath):
|
| 276 |
+
img = imread(filepath)
|
| 277 |
+
img = normalize99(img)
|
| 278 |
+
fpath, fext = os.path.splitext(filepath)
|
| 279 |
+
filepath = fpath+'.png'
|
| 280 |
+
imsave(filepath, img)
|
| 281 |
+
return filepath
|
| 282 |
|
| 283 |
def update_image(filepath):
|
| 284 |
for f in filepath:
|
| 285 |
f = tif_view(f)
|
| 286 |
+
filepath_show = norm_path(filepath[-1])
|
| 287 |
+
return filepath_show, filepath, fp0, fp0
|
| 288 |
|
| 289 |
def update_button(filepath):
|
| 290 |
filepath = tif_view(filepath)
|
| 291 |
+
filepath_show = norm_path(filepath[-1])
|
| 292 |
+
return filepath_show, [filepath], fp0, fp0
|
| 293 |
|
| 294 |
with gr.Blocks(title = "Hello",
|
| 295 |
css=".gradio-container {background:purple;}") as demo:
|
|
|
|
| 326 |
sample_list = []
|
| 327 |
for j in range(23):
|
| 328 |
sample_list.append("samples/img%0.2d.png"%j)
|
| 329 |
+
|
| 330 |
gr.Examples(sample_list, fn = update_button, inputs=input_image, outputs = [input_image, up_btn, outlines, flows], examples_per_page=25, label = "Click on an example to try it")
|
|
|
|
| 331 |
input_image.upload(update_button, input_image, [input_image, up_btn, outlines, flows])
|
| 332 |
up_btn.upload(update_image, up_btn, [input_image, up_btn, outlines, flows])
|
| 333 |
+
|
| 334 |
send_btn.click(cellpose_segment, [up_btn, resize], [outlines, flows, down_btn, down_btn2])
|
| 335 |
|
| 336 |
#down_btn.click(download_function, None, [down_btn, down_btn2])
|