zero-canary / predictor.py
Angelou0516's picture
Add universal zero-predictor for the leaderboard E2E canary
ccd95a9 verified
Raw
History Blame Contribute Delete
1 kB
# Universal zero-predictor for the leaderboard E2E canary.
#
# This is the SOURCE OF TRUTH for the toy model's predictor.py. Upload it to the HF repo
# the canary submits (default MedOtter/zero-canary), at the repo ROOT as `predictor.py`:
#
# huggingface-cli upload MedOtter/zero-canary \
# scripts/e2e/zero-canary-predictor.py predictor.py --repo-type model
#
# It returns an all-background label map for ANY (C, Z, Y, X) volume, so it satisfies every
# segmentation benchmark's contract (glioma MRI, abdominal CT, canary_tiny, …) with no
# weights and no GPU. A full-task run therefore finishes fast. Scores are near-zero; the
# canary only asserts the pipeline RAN, not that the model scored well.
import numpy as np
class _ZeroPredictor:
def predict(self, volume):
# volume: (C, Z, Y, X). The label map is spatial only -> drop the channel dim.
z, y, x = volume.shape[-3:]
return np.zeros((z, y, x), dtype=np.uint8)
def load():
return _ZeroPredictor()