Finished docker container for preprocessing and prediction
Browse files- README.md +25 -2
- docker/predict.Dockerfile +1 -1
- docker/preprocess_and_predict.Dockerfile +15 -27
- pyproject.toml +2 -2
README.md
CHANGED
|
@@ -95,7 +95,28 @@ python tutorials/download_ixi.py
|
|
| 95 |
## Generate predictions
|
| 96 |
|
| 97 |
<details>
|
| 98 |
-
<summary> Preprocess and predict
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
Preprocessing and predicting manually relies on using the scripts provided in this repository to generate predictions via two steps
|
| 101 |
|
|
@@ -140,7 +161,7 @@ python scripts/predict_from_fastsurfer_folder.py ~/data/ixi/preprocessed -d ~/da
|
|
| 140 |
</details>
|
| 141 |
|
| 142 |
<details>
|
| 143 |
-
<summary> Preprocess and predict in two steps
|
| 144 |
Preprocessing and predicting in two steps via docker requires using the two prebuilt docker containers for the two steps independently.
|
| 145 |
|
| 146 |
### Preprocessing
|
|
@@ -150,6 +171,7 @@ Running the container for preprocessing requires mounting three volumes:
|
|
| 150 |
- Licenses: A folder containing the freesurfer license. The file must be named freesurfer.txt
|
| 151 |
```
|
| 152 |
mkdir -p ~/data/ixi/outputs
|
|
|
|
| 153 |
docker run --rm \
|
| 154 |
--user $(id -u):$(id -g) \
|
| 155 |
--volume $HOME/data/ixi/images:/input \
|
|
@@ -164,6 +186,7 @@ Running the container for predictions requires two volumes:
|
|
| 164 |
- Fastsurfer: The folder containing fastsurfer-processed images
|
| 165 |
- Outputs: The folder where the predictions are written
|
| 166 |
```
|
|
|
|
| 167 |
docker run --rm -it \
|
| 168 |
--user $(id -u):$(id -g) \
|
| 169 |
--volume $HOME/data/ixi/outputs/fastsurfer:/fastsurfer \
|
|
|
|
| 95 |
## Generate predictions
|
| 96 |
|
| 97 |
<details>
|
| 98 |
+
<summary> Preprocess and predict with Docker </summary>
|
| 99 |
+
|
| 100 |
+
Preprocessing and predicting with Docker relies on running the docker container that first runs FastSurfer preprocessing over all raw input images and then runs the model on the resulting preprocessed images. The docker-container will result in both a folder with preprocessed images, and a file predictions.csv containing all predictions.
|
| 101 |
+
|
| 102 |
+
Running the container relies on mounting three volumes:
|
| 103 |
+
- Inputs: A folder containing input data. All nifti-files detected in this folder or one of its subfolders will be processed
|
| 104 |
+
- Outputs: A folder where the preprocessed images and predictions will be written. This must be created prior to running the container
|
| 105 |
+
- Licenses: A folder containing the freesurfer license. The file must be named freesurfer.txt
|
| 106 |
+
```
|
| 107 |
+
mkdir -p ~/data/ixi/outputs
|
| 108 |
+
docker pull estenhl/pyment-preprocess-and-predict:1.0.0
|
| 109 |
+
docker run --rm -it \
|
| 110 |
+
--user $(id -u):$(id -g) \
|
| 111 |
+
--volume $HOME/data/ixi/images:/input \
|
| 112 |
+
--volume $HOME/data/ixi/outputs:/output \
|
| 113 |
+
--volume $HOME/licenses:/licenses \
|
| 114 |
+
--gpus all \
|
| 115 |
+
estenhl/pyment-preprocess-and-predict:1.0.0
|
| 116 |
+
```
|
| 117 |
+
</details>
|
| 118 |
+
<details>
|
| 119 |
+
<summary> Preprocess and predict in Python </summary>
|
| 120 |
|
| 121 |
Preprocessing and predicting manually relies on using the scripts provided in this repository to generate predictions via two steps
|
| 122 |
|
|
|
|
| 161 |
</details>
|
| 162 |
|
| 163 |
<details>
|
| 164 |
+
<summary> Preprocess and predict in two steps with docker </summary>
|
| 165 |
Preprocessing and predicting in two steps via docker requires using the two prebuilt docker containers for the two steps independently.
|
| 166 |
|
| 167 |
### Preprocessing
|
|
|
|
| 171 |
- Licenses: A folder containing the freesurfer license. The file must be named freesurfer.txt
|
| 172 |
```
|
| 173 |
mkdir -p ~/data/ixi/outputs
|
| 174 |
+
docker pull estenhl/pyment-preprocessing:1.0.0
|
| 175 |
docker run --rm \
|
| 176 |
--user $(id -u):$(id -g) \
|
| 177 |
--volume $HOME/data/ixi/images:/input \
|
|
|
|
| 186 |
- Fastsurfer: The folder containing fastsurfer-processed images
|
| 187 |
- Outputs: The folder where the predictions are written
|
| 188 |
```
|
| 189 |
+
docker pull estenhl/pyment-predict:1.0.0
|
| 190 |
docker run --rm -it \
|
| 191 |
--user $(id -u):$(id -g) \
|
| 192 |
--volume $HOME/data/ixi/outputs/fastsurfer:/fastsurfer \
|
docker/predict.Dockerfile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
FROM python:3.10.
|
| 2 |
|
| 3 |
RUN mkdir -p /repos/pyment
|
| 4 |
|
|
|
|
| 1 |
+
FROM python:3.10.2-slim
|
| 2 |
|
| 3 |
RUN mkdir -p /repos/pyment
|
| 4 |
|
docker/preprocess_and_predict.Dockerfile
CHANGED
|
@@ -1,23 +1,5 @@
|
|
| 1 |
FROM estenhl/pyment-preprocessing:1.0.0
|
| 2 |
|
| 3 |
-
RUN apt-get update && apt-get install -y \
|
| 4 |
-
make build-essential libssl-dev zlib1g-dev \
|
| 5 |
-
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
|
| 6 |
-
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev \
|
| 7 |
-
libffi-dev liblzma-dev git \
|
| 8 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
-
|
| 10 |
-
ENV PYENV_ROOT=/root/.pyenv
|
| 11 |
-
ENV PATH="$PYENV_ROOT/bin:$PATH"
|
| 12 |
-
RUN curl https://pyenv.run | bash && \
|
| 13 |
-
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
|
| 14 |
-
|
| 15 |
-
RUN eval "$(pyenv init -)" && \
|
| 16 |
-
pyenv install 3.10.4
|
| 17 |
-
|
| 18 |
-
RUN mkdir -p /envs && \
|
| 19 |
-
$PYENV_ROOT/versions/3.10.4/bin/python -m venv /envs/pyment
|
| 20 |
-
|
| 21 |
RUN mkdir -p /repos/pyment
|
| 22 |
|
| 23 |
COPY scripts /repos/pyment/scripts
|
|
@@ -26,16 +8,22 @@ COPY pyproject.toml /repos/pyment/
|
|
| 26 |
COPY README.md /repos/pyment/
|
| 27 |
COPY LICENSE.md /repos/pyment/
|
| 28 |
|
|
|
|
| 29 |
RUN /envs/pyment/bin/pip install --upgrade pip poetry-core build && \
|
| 30 |
cd /repos/pyment && \
|
| 31 |
/envs/pyment/bin/pip install --no-cache-dir .
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
FROM estenhl/pyment-preprocessing:1.0.0
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
RUN mkdir -p /repos/pyment
|
| 4 |
|
| 5 |
COPY scripts /repos/pyment/scripts
|
|
|
|
| 8 |
COPY README.md /repos/pyment/
|
| 9 |
COPY LICENSE.md /repos/pyment/
|
| 10 |
|
| 11 |
+
RUN python -m venv /envs/pyment
|
| 12 |
RUN /envs/pyment/bin/pip install --upgrade pip poetry-core build && \
|
| 13 |
cd /repos/pyment && \
|
| 14 |
/envs/pyment/bin/pip install --no-cache-dir .
|
| 15 |
|
| 16 |
+
RUN mkdir -p /.pyment/weights && \
|
| 17 |
+
chmod -R 1777 /.pyment
|
| 18 |
+
COPY checkpoints/pyment /.pyment/weights
|
| 19 |
+
|
| 20 |
+
CMD ["/bin/sh", "-c", "\
|
| 21 |
+
mkdir -p /output/fastsurfer && \
|
| 22 |
+
/scripts/preprocess.sh \
|
| 23 |
+
--license /licenses/freesurfer.txt \
|
| 24 |
+
--python /envs/fastsurfer/bin/python \
|
| 25 |
+
/input /output/fastsurfer && \
|
| 26 |
+
/envs/pyment/bin/python /repos/pyment/scripts/predict_from_fastsurfer_folder.py \
|
| 27 |
+
/output/fastsurfer \
|
| 28 |
+
-d /output/predictions.csv \
|
| 29 |
+
"]
|
pyproject.toml
CHANGED
|
@@ -10,7 +10,7 @@ license-files = [
|
|
| 10 |
"LICENSE.md"
|
| 11 |
]
|
| 12 |
readme = "README.md"
|
| 13 |
-
requires-python = "=
|
| 14 |
|
| 15 |
[tool.poetry]
|
| 16 |
packages = [{include = "pyment"}]
|
|
@@ -19,7 +19,7 @@ include = [
|
|
| 19 |
]
|
| 20 |
|
| 21 |
[tool.poetry.dependencies]
|
| 22 |
-
python = "3.10.
|
| 23 |
tensorflow-macos = { version = "2.11", markers = "platform_system == 'Darwin'" }
|
| 24 |
tensorflow-metal = { version = "0.7", markers = "platform_system == 'Darwin'" }
|
| 25 |
tensorflow = { version = "2.11", markers = "platform_system != 'Darwin'" }
|
|
|
|
| 10 |
"LICENSE.md"
|
| 11 |
]
|
| 12 |
readme = "README.md"
|
| 13 |
+
requires-python = ">=3.10,<3.11"
|
| 14 |
|
| 15 |
[tool.poetry]
|
| 16 |
packages = [{include = "pyment"}]
|
|
|
|
| 19 |
]
|
| 20 |
|
| 21 |
[tool.poetry.dependencies]
|
| 22 |
+
python = ">=3.10,<3.11"
|
| 23 |
tensorflow-macos = { version = "2.11", markers = "platform_system == 'Darwin'" }
|
| 24 |
tensorflow-metal = { version = "0.7", markers = "platform_system == 'Darwin'" }
|
| 25 |
tensorflow = { version = "2.11", markers = "platform_system != 'Darwin'" }
|