Skip to content

Commit d6b121b

Browse files
authored
Merge pull request #23 from C-Achard/model-implementation
Model implementation
2 parents 096361d + b2d31a0 commit d6b121b

File tree

90 files changed

+5952
-1998
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+5952
-1998
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.pth filter=lfs diff=lfs merge=lfs -text
2+
*.tif filter=lfs diff=lfs merge=lfs -text
Lines changed: 91 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,91 @@
1-
# This workflows will upload a Python Package using Twine when a release is created
2-
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3-
4-
name: tests
5-
6-
on:
7-
push:
8-
branches:
9-
- main
10-
- npe2
11-
tags:
12-
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
13-
pull_request:
14-
branches:
15-
- main
16-
- npe2
17-
workflow_dispatch:
18-
19-
jobs:
20-
test:
21-
name: ${{ matrix.platform }} py${{ matrix.python-version }}
22-
runs-on: ${{ matrix.platform }}
23-
strategy:
24-
matrix:
25-
platform: [ubuntu-latest, windows-latest, macos-latest]
26-
python-version: [3.8, 3.9, '3.10']
27-
28-
steps:
29-
- uses: actions/checkout@v2
30-
31-
- name: Set up Python ${{ matrix.python-version }}
32-
uses: actions/setup-python@v2
33-
with:
34-
python-version: ${{ matrix.python-version }}
35-
36-
# these libraries enable testing on Qt on linux
37-
- uses: tlambert03/setup-qt-libs@v1
38-
39-
# strategy borrowed from vispy for installing opengl libs on windows
40-
- name: Install Windows OpenGL
41-
if: runner.os == 'Windows'
42-
run: |
43-
git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git
44-
powershell gl-ci-helpers/appveyor/install_opengl.ps1
45-
46-
# note: if you need dependencies from conda, considering using
47-
# setup-miniconda: https://github.com/conda-incubator/setup-miniconda
48-
# and
49-
# tox-conda: https://github.com/tox-dev/tox-conda
50-
- name: Install dependencies
51-
run: |
52-
python -m pip install --upgrade pip
53-
python -m pip install setuptools tox tox-gh-actions
54-
55-
# this runs the platform-specific tests declared in tox.ini
56-
- name: Test with tox
57-
uses: GabrielBB/xvfb-action@v1
58-
with:
59-
run: python -m tox
60-
env:
61-
PLATFORM: ${{ matrix.platform }}
62-
63-
- name: Coverage
64-
uses: codecov/codecov-action@v2
65-
66-
deploy:
67-
# this will run when you have tagged a commit, starting with "v*"
68-
# and requires that you have put your twine API key in your
69-
# github secrets (see readme for details)
70-
needs: [test]
71-
runs-on: ubuntu-latest
72-
if: contains(github.ref, 'tags')
73-
steps:
74-
- uses: actions/checkout@v2
75-
- name: Set up Python
76-
uses: actions/setup-python@v2
77-
with:
78-
python-version: "3.x"
79-
- name: Install dependencies
80-
run: |
81-
python -m pip install --upgrade pip
82-
pip install -U setuptools setuptools_scm wheel twine build
83-
- name: Build and publish
84-
env:
85-
TWINE_USERNAME: __token__
86-
TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
87-
run: |
88-
git tag
89-
python -m build .
90-
twine upload dist/*
91-
1+
## This workflows will upload a Python Package using Twine when a release is created
2+
## For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
#
4+
#name: tests
5+
#
6+
#on:
7+
# push:
8+
# branches:
9+
# - main
10+
# - npe2
11+
# tags:
12+
# - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
13+
# pull_request:
14+
# branches:
15+
# - main
16+
# - npe2
17+
# workflow_dispatch:
18+
#
19+
#jobs:
20+
# test:
21+
# name: ${{ matrix.platform }} py${{ matrix.python-version }}
22+
# runs-on: ${{ matrix.platform }}
23+
# strategy:
24+
# matrix:
25+
# platform: [windows-latest, macos-latest, ubuntu-latest]
26+
# python-version: [3.9]
27+
#
28+
# steps:
29+
# - uses: actions/checkout@v2
30+
#
31+
# - name: Set up Python ${{ matrix.python-version }}
32+
# uses: actions/setup-python@v2
33+
# with:
34+
# python-version: ${{ matrix.python-version }}
35+
#
36+
# # these libraries enable testing on Qt on linux
37+
# - uses: tlambert03/setup-qt-libs@v1
38+
#
39+
# # strategy borrowed from vispy for installing opengl libs on windows
40+
# - name: Install Windows OpenGL
41+
# if: runner.os == 'Windows'
42+
# run: |
43+
# git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git
44+
# powershell gl-ci-helpers/appveyor/install_opengl.ps1
45+
#
46+
# # note: if you need dependencies from conda, considering using
47+
# # setup-miniconda: https://github.com/conda-incubator/setup-miniconda
48+
# # and
49+
# # tox-conda: https://github.com/tox-dev/tox-conda
50+
# - name: Install dependencies
51+
# run: |
52+
# python -m pip install --upgrade pip
53+
# python -m pip install setuptools tox tox-gh-actions
54+
#
55+
# # this runs the platform-specific tests declared in tox.ini
56+
# - name: Test with tox
57+
# uses: GabrielBB/xvfb-action@v1
58+
# with:
59+
# run: python -m tox
60+
# env:
61+
# PLATFORM: ${{ matrix.platform }}
62+
#
63+
# - name: Coverage
64+
# uses: codecov/codecov-action@v2
65+
#
66+
# deploy:
67+
# # this will run when you have tagged a commit, starting with "v*"
68+
# # and requires that you have put your twine API key in your
69+
# # github secrets (see readme for details)
70+
# needs: [test]
71+
# runs-on: ubuntu-latest
72+
# if: contains(github.ref, 'tags')
73+
# steps:
74+
# - uses: actions/checkout@v2
75+
# - name: Set up Python
76+
# uses: actions/setup-python@v2
77+
# with:
78+
# python-version: "3.8"
79+
# - name: Install dependencies
80+
# run: |
81+
# python -m pip install --upgrade pip
82+
# pip install -U setuptools setuptools_scm wheel twine build
83+
# - name: Build and publish
84+
# env:
85+
# TWINE_USERNAME: __token__
86+
# TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
87+
# run: |
88+
# git tag
89+
# python -m build .
90+
# twine upload dist/*
91+
#

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ __pycache__/
66
# C extensions
77
*.so
88

9+
# unwanted results files
10+
*.csv
11+
912
# Distribution / packaging
1013
.Python
1114
env/
@@ -83,3 +86,10 @@ venv/
8386
# written by setuptools_scm
8487
**/_version.py
8588

89+
90+
91+
########
92+
#project specific
93+
#dataset
94+
/src/napari_cellseg_annotator/models/dataset/
95+
/src/napari_cellseg_annotator/models/saved_weights/

.isort.cfg

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[settings]
2+
force_single_line = True
3+
force_sort_within_sections = False
4+
lexicographical = True
5+
single_line_exclusions = ('typing',)
6+
order_by_type = False
7+
group_by_package = True
8+
skip=__init__.py

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
The MIT License (MIT)
33

4-
Copyright (c) 2022 Cyril Achard
4+
Copyright (c) 2022 Cyril Achard, Maxime Vidal
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy
77
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,51 @@ and review the napari docs for plugin developers:
2121
https://napari.org/plugins/stable/index.html
2222
-->
2323

24+
## Requirements
25+
26+
Requires manual installation of pytorch and MONAI.
27+
For Pytorch, please see [PyTorch]'s website for installation instructions.
28+
A CUDA-capable GPU is not needed but very strongly recommended, especially for training.
29+
30+
If you get errors from MONAI regarding missing readers, please see [MONAI's optional dependencies] page for instructions on getting the readers required by your images.
31+
32+
2433
## Installation
2534

2635
You can install `napari-cellseg-annotator` via [pip]:
2736

2837
pip install napari-cellseg-annotator
2938

39+
For local installation, please run:
40+
41+
```
42+
pip install -e .
43+
```
44+
45+
## Documentation
3046

47+
You can generate docs by running ``make html`` in the docs folder
3148

49+
## Usage
50+
51+
To use the plugin, please run:
52+
```
53+
napari
54+
```
55+
Then go into Plugins > napari-cellseg-annotator, and choose which tool to use.
56+
57+
- **Review**: This module allows you to review your labels, from predictions or manual labeling, and correct them if needed. It then saves the status of each file in a csv, for easier monitoring.
58+
- **Infer**: This module allows you to use pre-trained segmentation algorithms on volumes to automatically label cells.
59+
- **Train**: This module allows you to train segmentation algorithms from labeled volumes.
60+
- **Crop utility**: This module allows you to crop your volumes and labels dynamically, by selecting a fixed size volume and moving it around the image.
61+
62+
## Testing
63+
64+
To run tests locally:
65+
66+
- Locally : run ``pytest`` in the plugin folder
67+
- Locally with coverage : In the plugin folder, run ``coverage run --source=src -m pytest`` then ``coverage.xml`` to generate a .xml coverage file.
68+
- With tox : run ``tox`` in the plugin folder (will simulate tests with several python and OS configs, requires substantial storage space)
3269

3370
## Contributing
3471

@@ -59,3 +96,6 @@ If you encounter any problems, please [file an issue] along with a detailed desc
5996
[tox]: https://tox.readthedocs.io/en/latest/
6097
[pip]: https://pypi.org/project/pip/
6198
[PyPI]: https://pypi.org/
99+
100+
[PyTorch]: https://pytorch.org/get-started/locally/
101+
[MONAI's optional dependencies]: https://docs.monai.io/en/stable/installation.html#installing-the-recommended-dependencies

dev.requirements.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
black
2+
coverage
3+
isort
24
pytest
35
pytest-qt
4-
tox
56
sphinx
67
sphinx-autodoc-typehints
78
sphinx-rtd-theme
9+
tox
10+
twine

docs/conf.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
# All configuration values have a default; values that are commented out
1313
# serve to show the default.
1414

15-
import sys
1615
import os
17-
import shlex
16+
import sys
1817

1918
# If extensions (or modules to document with autodoc) are in another directory,
2019
# add these directories to sys.path here. If the directory is relative to the
@@ -53,8 +52,8 @@
5352

5453
# General information about the project.
5554
project = "napari-cellseg-annotator"
56-
copyright = "2022, Cyril Achard"
57-
author = "Cyril Achard"
55+
copyright = "2022, Cyril Achard, Maxime Vidal"
56+
author = "Cyril Achard, Maxime Vidal"
5857

5958
# The version info for the project you're documenting, acts as replacement for
6059
# |version| and |release|, also used in various other places throughout the

docs/index.rst

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,28 @@ Welcome to napari-cellseg-annotator's documentation!
66
:caption: User guide:
77

88
res/welcome
9-
res/loader_module_guide
9+
res/review_module_guide
10+
res/inference_module_guide
11+
res/training_module_guide
12+
res/cropping_module_guide
13+
res/custom_model_template
1014

1115

1216
.. toctree::
1317
:maxdepth: 1
1418
:caption: Source files:
1519

16-
17-
res/plugin_loader
20+
res/interface
21+
res/plugin_base
22+
res/plugin_review
23+
res/plugin_dock
24+
res/plugin_crop
1825
res/launch_review
19-
res/dock
26+
res/model_framework
27+
res/model_workers
28+
res/model_instance_seg
29+
res/plugin_model_inference
30+
res/plugin_model_training
2031
res/utils
2132

2233

0 commit comments

Comments
 (0)