Spaces:
Sleeping
Sleeping
Update streamlit_app.py
Browse files- streamlit_app.py +7 -1
streamlit_app.py
CHANGED
|
@@ -6,7 +6,7 @@ then displays results and provides download links.
|
|
| 6 |
"""
|
| 7 |
|
| 8 |
# imports
|
| 9 |
-
import streamlit as st, logging, shutil
|
| 10 |
from PIL import Image
|
| 11 |
from pathlib import Path
|
| 12 |
from utils.constants import *
|
|
@@ -47,6 +47,12 @@ if uploaded:
|
|
| 47 |
ImageSplitter(source_dir=PNG_IMAGES_DIR, output_dir=SPLIT_IMAGES_DIR, sub_image_width=IMG_WIDTH, sub_image_height=IMG_HEIGHT).split_all()
|
| 48 |
# generate - cellpose masks (detect step using a pre-trained model)
|
| 49 |
with st.spinner("Running Cellpose segmentation..."):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
cellpose_sam_detect_images_eval(model_path=MODEL, image_input_dir=SPLIT_IMAGES_DIR, image_output_dir=CELLPOSE_MASKS_DIR)
|
| 51 |
# generate - stitched masks (.npy files)
|
| 52 |
with st.spinner("Stitching masks..."):
|
|
|
|
| 6 |
"""
|
| 7 |
|
| 8 |
# imports
|
| 9 |
+
import streamlit as st, logging, shutil, torch
|
| 10 |
from PIL import Image
|
| 11 |
from pathlib import Path
|
| 12 |
from utils.constants import *
|
|
|
|
| 47 |
ImageSplitter(source_dir=PNG_IMAGES_DIR, output_dir=SPLIT_IMAGES_DIR, sub_image_width=IMG_WIDTH, sub_image_height=IMG_HEIGHT).split_all()
|
| 48 |
# generate - cellpose masks (detect step using a pre-trained model)
|
| 49 |
with st.spinner("Running Cellpose segmentation..."):
|
| 50 |
+
# from huggingface_hub import snapshot_download, hf_hub_download
|
| 51 |
+
# model_dir = snapshot_download(repo_id="unikill066/drg_cellpose_sam_model", cache_dir="/mnt/models_cache")
|
| 52 |
+
# # weights_path = hf_hub_download(repo_id="unikill066/drg_cellpose_sam_model",filename="model.pt")
|
| 53 |
+
# # model = torch.load(weights_path, map_location="cpu")
|
| 54 |
+
# print(model.eval())
|
| 55 |
+
# MODEL = "/mnt/models_cache/unikill066/drg_cellpose_sam_model"
|
| 56 |
cellpose_sam_detect_images_eval(model_path=MODEL, image_input_dir=SPLIT_IMAGES_DIR, image_output_dir=CELLPOSE_MASKS_DIR)
|
| 57 |
# generate - stitched masks (.npy files)
|
| 58 |
with st.spinner("Stitching masks..."):
|