Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,9 @@ from PIL import Image
|
|
| 7 |
import tensorflow as tf
|
| 8 |
from skimage.feature import peak_local_max
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
fp0 = np.zeros((96, 128), dtype = np.uint8)
|
| 12 |
|
|
@@ -191,8 +194,10 @@ def update_z(filepath, filepath_result, filepath_coordinates, z):
|
|
| 191 |
|
| 192 |
return (filepath_show, display_boxes), (filepath_result_show, display_boxes)
|
| 193 |
|
| 194 |
-
def detect_cells(filepath, z):
|
| 195 |
-
|
|
|
|
|
|
|
| 196 |
|
| 197 |
img = tiff.imread(filepath[-1])
|
| 198 |
|
|
@@ -324,10 +329,14 @@ with gr.Blocks(title = "Hello",
|
|
| 324 |
with gr.Row():
|
| 325 |
with gr.Column(scale=1):
|
| 326 |
with gr.Row():
|
| 327 |
-
depth = gr.
|
| 328 |
channel = gr.Number(label = 'channel (does nothing)', value = 0)
|
| 329 |
scale = gr.Number(label = 'resize (does nothing)', value = 0)
|
| 330 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
up_btn = gr.UploadButton("Upload image volume (tif/tiff)", visible=True, file_count = "multiple")
|
| 332 |
|
| 333 |
#gr.HTML("""<h4 style="color:white;"> Note2: Only the first image of a tif will display the segmentations, but you can download segmentations for all planes. </h4>""")
|
|
@@ -365,7 +374,7 @@ with gr.Blocks(title = "Hello",
|
|
| 365 |
#depth.change(update_depth, [up_btn, depth], depth)
|
| 366 |
|
| 367 |
# DO NOT RENDER OUTPUT TWICE
|
| 368 |
-
send_btn.click(detect_cells, [up_btn, depth], [down_btn, down_btn2, output_image]).then(update_z, [up_btn, down_btn, down_btn2, depth], [input_image, output_image])# flows, down_btn, down_btn2])
|
| 369 |
|
| 370 |
#down_btn.click(download_function, None, [down_btn, down_btn2])
|
| 371 |
|
|
|
|
| 7 |
import tensorflow as tf
|
| 8 |
from skimage.feature import peak_local_max
|
| 9 |
|
| 10 |
+
model_adresses = {"Intestinal organoids (0.32x0.32x2.0 um)": './model_positions',
|
| 11 |
+
"c. Elegans embryo (0.1x0.1x1.0 um)": './model_positions'}
|
| 12 |
+
|
| 13 |
|
| 14 |
fp0 = np.zeros((96, 128), dtype = np.uint8)
|
| 15 |
|
|
|
|
| 194 |
|
| 195 |
return (filepath_show, display_boxes), (filepath_result_show, display_boxes)
|
| 196 |
|
| 197 |
+
def detect_cells(filepath, z, model):
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
model = tf.keras.models.load_model(model_adresses[model], compile=False)
|
| 201 |
|
| 202 |
img = tiff.imread(filepath[-1])
|
| 203 |
|
|
|
|
| 329 |
with gr.Row():
|
| 330 |
with gr.Column(scale=1):
|
| 331 |
with gr.Row():
|
| 332 |
+
depth = gr.Slider(0, 100, step=1, label = 'z-depth', value = 10)
|
| 333 |
channel = gr.Number(label = 'channel (does nothing)', value = 0)
|
| 334 |
scale = gr.Number(label = 'resize (does nothing)', value = 0)
|
| 335 |
|
| 336 |
+
model = gr.Dropdown(
|
| 337 |
+
model_adresses.keys(), label="Detection model (with resolutions)", info="Will add more models later!"
|
| 338 |
+
)
|
| 339 |
+
|
| 340 |
up_btn = gr.UploadButton("Upload image volume (tif/tiff)", visible=True, file_count = "multiple")
|
| 341 |
|
| 342 |
#gr.HTML("""<h4 style="color:white;"> Note2: Only the first image of a tif will display the segmentations, but you can download segmentations for all planes. </h4>""")
|
|
|
|
| 374 |
#depth.change(update_depth, [up_btn, depth], depth)
|
| 375 |
|
| 376 |
# DO NOT RENDER OUTPUT TWICE
|
| 377 |
+
send_btn.click(detect_cells, [up_btn, depth, model], [down_btn, down_btn2, output_image]).then(update_z, [up_btn, down_btn, down_btn2, depth], [input_image, output_image])# flows, down_btn, down_btn2])
|
| 378 |
|
| 379 |
#down_btn.click(download_function, None, [down_btn, down_btn2])
|
| 380 |
|