Spaces:
Sleeping
Sleeping
File size: 3,412 Bytes
ffba4ae | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | # InferCode: Single-Pair Interface-B Full Pipeline
This directory provides an inference entry that runs the full Interface-B pipeline on one image pair (`OCTA + wfCFP`): Step1, Step2, and Step3.
Pipeline:
1. Step1 vessel segmentation (`CARe-VesselSeg` or `Broad domain retinal vessel segmentation [ICASSP 2025]`)
2. Step2 optic-disc/fovea detection (`wfCFP + OCTA`)
3. Step3 registration (primary + retry route selection)
## Run
Activate environment first:
```bash
source "$(conda info --base)/etc/profile.d/conda.sh"
conda activate MMR
```
Then run:
```bash
cd /path/to/CAReReleaseProject/Huggingface/InferCode
bash run_interface_b_single_pair.sh
```
`run_interface_b_single_pair.sh` is configured in-script. Edit variables inside the shell script instead of appending many CLI flags.
## Key Parameters
- `SEG_MODEL={CARe-VesselSeg,Broad domain retinal vessel segmentation [ICASSP 2025]}`
- `CARe-VesselSeg`: original vessel segmentation model
- `Broad domain retinal vessel segmentation [ICASSP 2025]`: broad-domain vessel segmentation model
- `REGISTRATION_MODE={interface_b_retry,direct_no_crop}`
- `interface_b_retry`: Interface-B flow (Step2 coordinates + retry routes)
- `direct_no_crop`: skip Step2 and cropping, go Step1 -> Step3 directly (suitable for CFP-CFP)
- `QUERY_MODALITY / REFER_MODALITY={AUTO,CFP,OCTA}`
- Used when `SEG_MODEL=Broad domain retinal vessel segmentation [ICASSP 2025]`
- `AUTO`: infer from filename (`OCTA` or `_001` -> OCTA, otherwise CFP)
- Auto-switch rule:
- If `interface_b_retry` is requested but detected as `CFP-CFP`, it auto-switches to `direct_no_crop`
- `INLIER_METHOD={RANSAC,LMEDS}`: Step3 inlier filtering and polynomial fitting method
- `RETRY_FILTERED_INLIER_THRESHOLD`: trigger retry when primary filtered inliers drop below this value (default `20`)
- `DEVICE`: `auto/cuda:0/cpu` (default `auto`)
## Main Outputs
Default output root is `InferCode/Output/single_pair_<timestamp>`, including:
- `results/vessels/`
- `octa_vessel.png`
- `wfcfp_vessel.png`
- `results/keypoints/`
- `filtered_pairs_norm.txt`
- `filtered_pairs_input_space_pixels.txt`
- `filtered_pairs_restored_space_pixels.txt`
- `filtered_pairs_input_space_vis.png`
- `filtered_pairs_restored_space_vis.png`
- `results/overlays/`
- `vessel_overlay.png`
- `raw_overlay.png`
- `results/polynomial/quadratic_polynomial_params.json`
- quadratic polynomial coefficients
- `results/visualizations/summary_board.png`
- summary visualization board
- `summary.json`
- run summary (routing, metrics, and output paths)
## Weight Loading via Hugging Face Snapshot
For lightweight deployment, weights can be hosted in Hugging Face Model repos.
Recommended: separate repos for each stage.
```bash
export CARE_WEIGHT_STEP1_REPO_ID="Hongyang-Li/CARe_VesselSeg"
export CARE_WEIGHT_STEP2_REPO_ID="Hongyang-Li/CARe_OpticDiscFoveaDetection"
export CARE_WEIGHT_STEP3_REPO_ID="Hongyang-Li/CARe_Reg"
# Optional: override broad-domain vessel model repo
export CARE_WEIGHT_BROAD_REPO_ID="AIMClab-RUC/UNet_DCP_1024"
```
Optional:
- `CARE_WEIGHT_STEP1_REVISION`
- `CARE_WEIGHT_STEP2_REVISION`
- `CARE_WEIGHT_STEP3_REVISION`
- `CARE_WEIGHT_BROAD_REVISION`
- `CARE_WEIGHTS_CACHE_DIR`
- `CARE_WEIGHT_*_REL` for per-file relative path overrides
Backward-compatible single bundled repo mode is also supported through:
- `CARE_WEIGHTS_REPO_ID`
- `CARE_WEIGHTS_REVISION`
|