CARe / InferCode /README.md
Hongyang-Li's picture
Upload 78 files
ffba4ae verified

A newer version of the Gradio SDK is available: 6.14.0

Upgrade

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:

source "$(conda info --base)/etc/profile.d/conda.sh"
conda activate MMR

Then run:

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.

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