Skip to content

Commit 4331abc

Browse files
merge
1 parent a2d258f commit 4331abc

5 files changed

Lines changed: 10 additions & 28 deletions

File tree

src/baseline/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ RUN pip install --no-cache-dir --break-system-packages -r requirements.txt
1313
# Copy code
1414
# -----------------------------
1515

16-
COPY weights weights
16+
COPY outputs .
1717
COPY predict.py .
1818
COPY unet.py .
1919
COPY dataset.py .
2020
# -----------------------------
2121
# Run inference
2222
# -----------------------------
23-
ENTRYPOINT ["python", "predict.py", "/data/features", "/data/output/ct.nii.gz"]
23+
ENTRYPOINT ["python", "predict.py", "--features_dir", "/data/features", "--output_ct", "/data/output/ct.nii.gz"]

src/baseline/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Run with Docker:
2020

2121
```bash
2222
docker run --rm \
23-
--memory 120g \
23+
--memory 128g \
2424
-v /path/to/sub-000/features:/data/features:ro \
2525
-v /path/to/output:/data/output \
2626
ghcr.io/bic-mac-challenge/baseline
@@ -33,6 +33,9 @@ pip install -r requirements.txt
3333
python predict.py --features_dir /path/to/sub-000/features --output_ct pseudo-ct.nii.gz
3434
```
3535

36+
Weights are loaded from `outputs/checkpoints/best_model.pth`
37+
38+
3639
## Training
3740

3841
Edit `config.yaml` to set your data path, then:
@@ -43,8 +46,6 @@ python train.py
4346

4447
Weights are saved to `outputs/checkpoints/best_model.pth` (lowest validation loss).
4548

46-
Move new weights to `weights/best_model.pth` and build the image:
47-
4849
```bash
4950
docker build -t my-baseline .
5051
```

src/baseline/dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
def get_subject_features(features_dir):
66
"""Return all available model inputs for a subject: NAC-PET, topogram, combined and chunked
77
DIXON MRI (in/out-phase), MRI face mask, and metadata (sex, age, height, weight).
8-
These are everything a participant model may use to predict the pseudo-CT."""
8+
These are everything a your model may use to predict the pseudo-CT."""
99
paths = {
1010
"nacpet": os.path.join(features_dir, "nacpet.nii.gz"),
1111
"topogram": os.path.join(features_dir, "topogram.nii.gz"),

src/baseline/predict.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
from dataset import get_subject_features
1818

1919

20-
MODEL_PATH = Path(__file__).parent / "weights/best_model.pth"
21-
MODEL_PATH = Path("/sonne/hinge/Projects/challenge-codebase/src/baseline/outputs4/checkpoints/best_model.pth")
20+
MODEL_PATH = Path(__file__).parent / "outputs/best_model.pth"
2221
PATCH_SIZE = (192, 192, 192)
2322
SW_BATCH = 2
2423
OVERLAP = 0.5
@@ -51,6 +50,7 @@ def predict(features_dir, out_path):
5150
overlap=OVERLAP, mode="gaussian", progress=True,
5251
)
5352

53+
# Apply inverse of normalization to get HU
5454
pred_hu = pred.cpu().numpy()[0, 0] * 3000 - 1000
5555
affine = data["nacpet"].meta["affine"].numpy()
5656

src/baseline/transforms.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
#NOTE: The baseline uses only the NAC-PET as input
5-
# however, your model may use all images and metadata available
5+
# however, your model may use all the images and metadata available
66
# under the /features folder
77

88
def get_transforms(patch_size, num_samples=2):
@@ -44,25 +44,6 @@ def get_transforms(patch_size, num_samples=2):
4444
random_size=False,
4545
num_samples=num_samples
4646
),
47-
48-
#RandGaussianNoised(keys=["input"], prob=0.5, mean=0.0, std=0.05),
49-
#RandScaleIntensityd(keys=["input"], factors=0.1, prob=0.5),
50-
#RandShiftIntensityd(keys=["input"], offsets=0.1, prob=0.5),
51-
#RandGaussianSmoothd(
52-
# keys=["input"],
53-
# sigma_x=(0.5, 1.0), sigma_y=(0.5, 1.0), sigma_z=(0.5, 1.0),
54-
# prob=0.3,
55-
#),
56-
57-
# RandAffined(
58-
# keys=["input", "ct", "prediction_mask"],
59-
# prob=0.5,
60-
# rotate_range=(0.087, 0.087, 0.087), # ±5°
61-
# scale_range=(0.05, 0.05, 0.05), # ±5%
62-
# mode=("bilinear", "bilinear", "nearest"),
63-
# padding_mode="border",
64-
# ),
65-
6647
EnsureTyped(keys=["input", "ct", "prediction_mask"]),
6748

6849
]

0 commit comments

Comments
 (0)