Skip to content

[Chore/ML] Move Model Weights from Git to Hugging Face Model Hub #174

Description

@jpdevhub

Problem

The Models/species_mobilenetv3.pth file (6.0 MB) was committed directly to the Git repository using git add -f. While 6 MB is manageable today, as we add more models (freshness model, YOLO, etc.) the repository will become too large to clone.

Goal

Host all model weights on the Hugging Face Model Hub and download them at runtime, keeping Git for code only.

Acceptance Criteria

  • Create a public model repo at https://huggingface.co/jpdevhub/freshscan-models
  • Upload species_mobilenetv3.pth to the HF Model Hub
  • Create backend/download_models.py script that uses huggingface_hub to download weights to a local Models/ directory if not already present
  • backend/startup.sh updated to call python download_models.py before starting uvicorn
  • Models/ directory added to .gitignore
  • Models/species_mobilenetv3.pth removed from Git history using git filter-repo or git-lfs migrate (or BFG Repo Cleaner)
  • CONTRIBUTING.md updated with a note: 'Never commit .pth / .onnx / .bin model weights to Git'
  • README.md updated with model download instructions

Commands Reference

pip install huggingface_hub
python -c "from huggingface_hub import hf_hub_download; hf_hub_download('jpdevhub/freshscan-models', 'species_mobilenetv3.pth', local_dir='Models/')"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions