Spaces:
Sleeping
Sleeping
Commit History
-
fix: nnUNet models disappearing from dropdown on HF Spaces
Three bugs fixed: 1. _ensure_nnunet_from_hub: final success check only verified plans.json but not the .pth weight file. Now checks both. 2. model_registry.py: register_nnunet() failures were logged at debug level (invisible). Changed to warning with exc_info=True so the actual download error is visible in HF Spaces logs. 3. orchestrator.py: get_available_models() checked cfg.checkpoint_path directly from the stale NNUNET_MODELS config (still None before download). Now uses is_model_registered() which triggers _ensure_models_registered() -> register_nnunet() -> HF Hub download, so checkpoint_path is populated by the time we check.e2c3db1 -
fix: _nnunet_path_or_none now checks .pth weight file, not just plans.json
Root cause: plans.json/dataset.json are tracked in git and deployed to HF Spaces, but the large .pth weight files are gitignored. The old _nnunet_path_or_none only checked for plans.json, returning a 'valid' checkpoint_path that caused register_nnunet() to skip the HF Hub download. nnUNet then crashed on the missing .pth file. Changes: - _nnunet_path_or_none now requires at least one fold_*/checkpoint.pth - Added local_dir field to nnUNetConfig so register_nnunet downloads into the original directory (where plans.json already exists from git) rather than a separate model_id-based directoryc049516 -
feat: auto-download nnUNet checkpoints from HF Hub when local files missing
- Uploaded nnUNet DWI weights to maregu2023/nnunet-isles2022-dwi - Uploaded nnUNet Multi weights to maregu2023/nnunet-isles2022-multi - Added hf_hub_repo field to nnUNetConfig dataclass - Added _ensure_nnunet_from_hub() to download plans.json, dataset.json, and fold_0/checkpoint_best.pth from HF Hub into local dir structure - Updated register_nnunet() to try HF Hub download when local path is None - Fixes: Model weights not found for nnunet-isles-dwi on HF Spaces0369b1a -
fix: sanitize OMP_NUM_THREADS at 3 levels to prevent libgomp crash on HF Spaces
HF Spaces Kubernetes injects OMP_NUM_THREADS=3500m (millicores string) which crashes libgomp when PyTorch is imported, causing /models to return 500. Three layers of defense: 1. entrypoint.sh: export OMP_NUM_THREADS=4 before starting uvicorn 2. api.py: sanitize env vars at module top before any torch import 3. settings.py: sanitize right before 'import torch' (belt-and-suspenders) Also: /models endpoint now has try/except returning SAM as fallback instead of crashing with unhandled 500 HTML error.8d0d76d -
fix: override OMP_NUM_THREADS to fix libgomp crash on HF Spaces
HF Spaces injects OMP_NUM_THREADS=3500m (Kubernetes resource limit string) which libgomp cannot parse, causing PyTorch/nnUNet to crash. Override with OMP_NUM_THREADS=4 and MKL_NUM_THREADS=4.f25a18c -
deploy: add suggested_hardware t4-small, fix Dockerfile CUDA assertion
- Add suggested_hardware: t4-small to README frontmatter for GPU tier - Remove CUDA assertion from Dockerfile verification step (no GPU at build time)17c82aa -
fix: remove CUDA assertion from Docker build verification
The assert 'cu' in torch.__version__ check fails during docker build because no GPU is available at build time (only at runtime). Keep the import checks but remove the CUDA assertion.a017646 -
fix: split nnunetv2 install to preserve CUDA PyTorch in Docker
- Install all deps except nnunetv2 first (keeps base image CUDA torch) - Install nnunetv2 deps separately, then nnunetv2 with --no-deps - Add system dev packages for C compilation (SimpleITK, blosc2, etc.) - Add build verification step to fail loudly if nnunetv2 missingc7efece -
fix: enable nnunetv2 in requirements.txt, use CUDA base image in Dockerfile
- Uncomment nnunetv2>=2.2 (now the primary segmentation backend) - Switch Dockerfile from python:3.10-slim to pytorch/pytorch:2.1.0-cuda11.8-cudnn8-runtime - Comment out torch/torchvision in requirements.txt (provided by base image) - Add fastapi, uvicorn, python-multipart for backend serving4aa9277 -
fix: repeat single channel instead of zero-padding for multi-channel nnUNet
When the model expects multiple channels (e.g. DWI+ADC+FLAIR) but only a single-channel volume is uploaded, repeat the input across all channel slots. This gives the model plausible intensity values everywhere rather than zeros in the missing channels.e727a30 -
fix: zero-pad missing channels for multi-channel nnUNet models
The ISLES 2022 model was trained on 3 channels (DWI+ADC+FLAIR) but inference uses single-channel DWI only. preprocess() now reads the expected channel count from dataset.json at load time and zero-pads missing channels (input placed in channel 0, rest zeroed).9d251a7 -
fix: resolve NameError in nnUNetWrapper.load() — use self.config.preprocessing
b8f801b -
feat: wire real checkpoints (nnUNet ISLES + DWI, SAM-Med3D), remove placeholder models
- Add checkpoints/ directory with nnUNet configs (plans.json, dataset.json) - Auto-detect nnUNet checkpoints from checkpoints/nnunet/ on startup - Register two nnUNet variants: nnunet-isles (default), nnunet-isles-dwi - SAM-Med3D uses local checkpoints/sam_med3d/ with HF Hub fallback - Remove fake MONAIAuto3DSeg placeholder models from registry - Update orchestrator: brain_lesion task defaults to nnunet-isles - Update VTK.js slicer and FastAPI to use real model IDs - Exclude training artifacts (*.png, logs) from gitfa27688 -
Fixing three bugs from nnUNetv2 wrapper, such as pacing extraction: (x,y,z) → (z,y,x) to match project convention
5fcd2a4 -
feat: add HF Spaces Docker deployment
- Dockerfile: Python 3.10-slim, non-root user, uvicorn on port 7860 - api.py: serve static VTK.js frontend from FastAPI, add HF CORS origin - api-client.js: use window.location.origin for same-origin API calls - README.md: update frontmatter to sdk: docker, app_port: 7860 - .dockerignore: exclude __pycache__, .git, docs, test filesda9126b
-
Add a markdown note for HF deployment
ba67644 -
feat: Add nnUNet integration, Dice metrics, and split INFO panel with overlap viewer
- Add nnUNet v2 wrapper (nnunet_wrapper.py) for brain lesion segmentation - Register nnUNet and fix unet3d-brain-tumor model in registry - Add Dice score, IoU, sensitivity, precision metrics computation - Add GT upload endpoint and metrics API endpoints - Split INFO panel: left (metrics), right (mask comparison viewer) - Overlap viewer shows TP (green), FP (red), FN (blue) visualization - Add scroll-based slice navigation for overlap viewer - Set 3D U-Net (Baseline) as default model selection - Reset mask/metrics/overlap when uploading new volume - Update README with local run instructionsd2c2086
-
Update README.md with the steps on how to run both the Gradio and API based web apps
cf575e8
-
Phase 12: Canvas2D slicer frontend with FastAPI backend
- Replaced VTK.js with pure Canvas2D MPR viewer (no CDN dependency) - Fixed OpenMP duplicate library error for Windows - Fixed Windows file locking issue in volume upload - Added auto window/level calculation from image data - Fixed prompt coordinate mapping for MRI data (X,Y,Z orientation) - Swapped axial/sagittal view mappings for correct display - Added SAM support with empty mask for first inference - Added debug logging throughout frontend - Fixed API prompt format (prompt_type, coordinates wrapper) - Added root endpoint with API info98c4545 -
Add Phase 12: VTK.js slicer frontend for medical imaging
- Create seg_app/ui_slicer/ directory with complete frontend - Implement MPR viewer with axial, sagittal, coronal views - Add smooth mouse-wheel slice scrolling via VTK.js - Support positive/negative point prompts with click-to-place - Integrate with backend API for volume upload and segmentation - Add window/level controls and mask overlay rendering - Include keyboard shortcuts (P/N/C/R/Esc) - Add development server script (serve_frontend.py) - Update backend API with raw data endpoints for VTK.js - Extend CORS for local development servers - Gradio UI remains untouched6876abc -
Add Phase 11: FastAPI backend for slicer-grade frontend support
f05ab78 -
Swap the order of models in the dropdown for models
458f770 -
Trigger HF Spaces rebuild
3104c60 -
Fix: Add weights_only=False for PyTorch 2.6+ compatibility with SAM-Med3D checkpoints
568e0f2 -
Fix: Monkey-patch Gradio schema bug for HF Spaces compatibility
0dee6ca -
Remove ssr parameter in launch() function
cfbb33f -
Fix root cause: Remove gr.update() to prevent Gradio schema serialization bug
1b1a58d -
Fix: Upgrade to Gradio 5.12.0 and disable SSR to fix schema bug
3803722 -
Fix: Remove all type annotations from Gradio handlers to prevent schema bug
45e6dd0 -
Fix: Correct type annotation causing Gradio schema serialization bug
3846302 -
Fix: Use gr.update() instead of gr.Slider() to avoid JSON schema bug
ae8a3d6 -
Upgrade to Gradio 5.x to fix JSON schema serialization bug
14c06ea -
Fix: simplify load_volume to avoid gr.State and chained handlers
da7786d -
Fix: replace gr.JSON with gr.Textbox to fix schema serialization bug
dd12647 -
Fix: call launch() on HF Spaces with correct server settings
16cace9 -
Fix: use Gradio 4.31.0, remove manual launch on HF Spaces
3314249 -
Fix version compatibility for HF spaces
0f21683 -
Deploy brain lesion segmentation web app
1bb9695
-
UI: Compact slicer-style layout, improved placeholder inference
d0bd346 -
Initial commit: Medical image segmentation app
eecd79d