@@ -579,6 +579,82 @@ python -c "from samrfi.utils.model_cache import ModelCache; ModelCache().downloa
579579
580580---
581581
582+ ## HuggingFace Hub Integration
583+
584+ SAM-RFI supports seamless integration with HuggingFace Hub for sharing and downloading trained models and datasets.
585+
586+ ### Quick Start
587+
588+ ** Download and use a published model:**
589+ ``` bash
590+ # Automatically downloads model from HuggingFace Hub
591+ samrfi predict --model polarimetic/sam-rfi/large --input observation.ms
592+ ```
593+
594+ ** Publish your trained model:**
595+ ``` bash
596+ # Upload model to HuggingFace Hub
597+ samrfi publish --type model \
598+ --input ./samrfi_data/sam2_rfi_best.pth \
599+ --repo-id polarimetic/sam-rfi
600+ ```
601+
602+ ** Publish a dataset:**
603+ ``` bash
604+ # Upload training dataset
605+ samrfi publish --type dataset \
606+ --input ./datasets/train_4k/exact_masks \
607+ --repo-id polarimetic/sam-rfi-dataset
608+ ```
609+
610+ ### Features
611+
612+ - ** Automatic Model Downloads** : Models are downloaded and cached on first use
613+ - ** Smart Path Detection** : CLI accepts both local paths and HuggingFace repo IDs
614+ - ** Private Repositories** : Support for private models with token authentication
615+ - ** Model Cards** : Auto-generated documentation with training metrics
616+ - ** Latest Versioning** : Simple "latest" approach per model size
617+
618+ ### Python API
619+
620+ ``` python
621+ from samrfi.inference import RFIPredictor
622+
623+ # Initialize with HuggingFace model (auto-downloads if needed)
624+ predictor = RFIPredictor(
625+ model_path = " polarimetic/sam-rfi/large" ,
626+ device = " cuda"
627+ )
628+
629+ # Use normally
630+ flags = predictor.predict_ms(" observation.ms" )
631+ ```
632+
633+ ### Cache Management
634+
635+ Models are cached at ` ~/.cache/huggingface/hub/ ` after first download. Set custom location:
636+
637+ ``` bash
638+ export HF_HOME=/path/to/custom/cache
639+ ```
640+
641+ ### Authentication
642+
643+ For private repositories, set your HuggingFace token:
644+
645+ ``` bash
646+ export HF_TOKEN=hf_xxxxx
647+ samrfi publish --type model --input model.pth --repo-id user/private-repo --private
648+ ```
649+
650+ Get your token from: https://huggingface.co/settings/tokens
651+
652+ ### Complete Guide
653+
654+ For detailed documentation including troubleshooting, batch publishing, and advanced usage, see [ HuggingFace Integration Guide] ( docs/HuggingFace.md ) .
655+
656+ ---
657+
582658## Training
583659
584660### Resume Training
0 commit comments