Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,7 +37,7 @@ def inference(image, model_path, **model_params):
|
|
| 37 |
img = image
|
| 38 |
|
| 39 |
model_inference = models.CellposeModel(gpu=False, pretrained_model=model_path)
|
| 40 |
-
preds, flows, _ = model_inference.eval(img, **model_params)
|
| 41 |
|
| 42 |
print(preds.shape)
|
| 43 |
return preds, flows
|
|
@@ -48,11 +48,11 @@ if __name__ == "__main__":
|
|
| 48 |
st.title("Sartorius Cell Segmentation")
|
| 49 |
|
| 50 |
uploaded_img = st.file_uploader(label="Upload neuronal cell image")
|
|
|
|
| 51 |
segment = st.button("Perform segmentation")
|
| 52 |
if uploaded_img is not None and segment:
|
| 53 |
img = Image.open(uploaded_img)
|
| 54 |
img = np.array(img)
|
| 55 |
-
st.image(img)
|
| 56 |
|
| 57 |
model_params = {
|
| 58 |
"diameter": 19.0,
|
|
@@ -60,10 +60,11 @@ if __name__ == "__main__":
|
|
| 60 |
"augment": True,
|
| 61 |
"resample": True,
|
| 62 |
}
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
|
|
|
| 68 |
|
| 69 |
print(preds)
|
|
|
|
| 37 |
img = image
|
| 38 |
|
| 39 |
model_inference = models.CellposeModel(gpu=False, pretrained_model=model_path)
|
| 40 |
+
preds, flows, _ = model_inference.eval([img], **model_params)
|
| 41 |
|
| 42 |
print(preds.shape)
|
| 43 |
return preds, flows
|
|
|
|
| 48 |
st.title("Sartorius Cell Segmentation")
|
| 49 |
|
| 50 |
uploaded_img = st.file_uploader(label="Upload neuronal cell image")
|
| 51 |
+
st.image(uploaded_img)
|
| 52 |
segment = st.button("Perform segmentation")
|
| 53 |
if uploaded_img is not None and segment:
|
| 54 |
img = Image.open(uploaded_img)
|
| 55 |
img = np.array(img)
|
|
|
|
| 56 |
|
| 57 |
model_params = {
|
| 58 |
"diameter": 19.0,
|
|
|
|
| 60 |
"augment": True,
|
| 61 |
"resample": True,
|
| 62 |
}
|
| 63 |
+
with st.spinner("Performing segmentation. This might take a while..."):
|
| 64 |
+
preds, flows = inference(
|
| 65 |
+
image=img,
|
| 66 |
+
model_path="./cellpose_residual_on_style_on_concatenation_off_fold1_ep_649_cv_0.2834",
|
| 67 |
+
**model_params
|
| 68 |
+
)
|
| 69 |
|
| 70 |
print(preds)
|