Skip to content

Commit 17e4549

Browse files
Updated use-case figures
1 parent a5504c7 commit 17e4549

File tree

6 files changed

+30995
-135137
lines changed

6 files changed

+30995
-135137
lines changed

case2/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,21 @@ And images of application in QuPath:
4343

4444
See the result of stardist applied in deepImageJ
4545
<img src="images/deepimagej_stardist.png" alt="drawing" width="1200"/>
46+
47+
48+
## Apply the model in stardist python
49+
50+
- `run_stardist_python.py`
51+
52+
<img src="images/stardist-python.png" alt="drawing" width="1200"/>
53+
54+
55+
## Apply the model in zero-cost
56+
57+
- Open the stardist 2d notebook: https://colab.research.google.com/github/esgomezm/ZeroCostDL4Mic/blob/master/Colab_notebooks/BioImage.io%20notebooks/StarDist_2D_ZeroCostDL4Mic_BioImageModelZoo_export.ipynb
58+
- will be on the main zero cost once https://github.com/HenriquesLab/ZeroCostDL4Mic/pull/181 is merged
59+
- Start the notebook and go to `Loading weights from a pre-trained notebook`
60+
- Select `pretrained_model_choice: BioImage Model Zoo`
61+
- Enter the doi (10.5281/zenodo.6338614) in `bioimageio_model`
62+
- Go to `Error mapping and quality metrics estimation` to run the model on data from your google drive
63+
- TODO: still need to do this, can't load the model right now because zenodo is down

case2/images/stardist-python.png

832 KB
Loading

case2/run_stardist_python.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import os
2+
from pathlib import Path
3+
4+
import imageio
5+
import stardist
6+
import napari
7+
from csbdeep.utils import normalize
8+
from stardist.models import StarDist2D
9+
10+
11+
def run_stardist(image, scale=2):
12+
13+
# download the H&E stardist model from bioimage.io
14+
model_doi = "10.5281/zenodo.6338614"
15+
model_folder = Path("./he-model-pretrained")
16+
if not os.path.exists(model_folder):
17+
stardist.import_bioimageio(model_doi, model_folder)
18+
model = StarDist2D(None, model_folder.name, model_folder.parent)
19+
20+
# prepare the image and run prediction with stardist
21+
input_ = normalize(image, 1.0, 99.8)
22+
nuclei, _ = model.predict_instances(input_, scale=2)
23+
return nuclei
24+
25+
26+
def main():
27+
input_path = "/home/pape/Work/data/lizard/train_images/consep_13.png"
28+
image = imageio.imread(input_path)
29+
nuclei = run_stardist(image)
30+
31+
v = napari.Viewer()
32+
v.add_image(image)
33+
v.add_labels(nuclei)
34+
napari.run()
35+
36+
37+
if __name__ == "__main__":
38+
main()

0 commit comments

Comments
 (0)