Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add simpler HuggingFace repository support for lora_url #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zsxkib
Copy link
Contributor

@zsxkib zsxkib commented Mar 17, 2025

This update lets users easily use LoRA models from HuggingFace by just providing the repository name (like 'owner/repo') in the lora_url parameter.

New features:

  • Support for simple HuggingFace format ('owner/repo')
  • Smart prioritization - tries Replicate first, then HuggingFace for owner/model format
  • Clear logging when multiple model files are found
  • Better model type detection from LoRA filenames
  • Keeps working with all existing URL formats:
    • Direct URLs
    • Replicate URLs
    • Replicate delivery URLs

Key implementation details:

  • We carefully preserve backward compatibility by always checking for Replicate models FIRST
  • The 'owner/repo' format is only treated as HuggingFace after Replicate lookup fails
  • Helpful error messages show when a format is tried and falls back to another
  • Model type detection (1.3b vs 14b) checks filenames to pick the right base model
  • Zero changes to existing direct URL handling - they continue to work exactly as before

Technical additions:

  • Added HuggingFace Hub API for repository file listing
  • Strong error handling and fallbacks
  • Better documentation
  • No changes to replicate_weights.py
  • Minimal changes overall - only what's needed for the new feature

Tested with test suite:

sudo cog predict \
  -i 'model="14b"' \
  -i 'frames=17' \
  -i 'prompt="MY_SUBCONSCIOUS monster is swimming ..."' \
  -i 'lora_url="fofr/wan-14b-my-subconscious"' # replicate model

sudo cog predict \
  -i 'model="14b"' \
  -i 'frames=17' \
  -i 'prompt="MY_SUBCONSCIOUS monster is swimming ..."' \
  -i 'lora_url="https://replicate.com/fofr/wan-14b-my-subconscious"' # replicate url

sudo cog predict \
  -i 'model="14b"' \
  -i 'frames=17' \
  -i 'prompt="MY_SUBCONSCIOUS monster is swimming ..."' \
  -i 'lora_url="https://replicate.delivery/xezq/qocyf3gptqQwJqBXaeMVS8kESLBmeIjvnqrFboh1CNigawvoA/trained_model.tar"' # replicate delivery url

sudo cog predict \
  -i 'model="14b"' \
  -i 'frames=17' \
  -i 'prompt="steamboat willie style, golden era animation ..."' \
  -i 'lora_url="https://huggingface.co/benjamin-paine/wan-lora/resolve/main/steamboat-willie-14b.bf16.safetensors"' # hf url

sudo cog predict \
  -i 'model="14b"' \
  -i 'frames=17' \
  -i 'prompt="steamboat willie style, golden era animation ..."' \
  -i 'lora_url="benjamin-paine/wan-lora"' # hf repo

This update lets users easily use LoRA models from HuggingFace by just providing the repository name (like 'owner/repo') in the lora_url parameter.

New features:
- Support for simple HuggingFace format ('owner/repo')
- Smart prioritization - tries Replicate first, then HuggingFace for owner/model format
- Clear logging when multiple model files are found
- Better model type detection from LoRA filenames
- Keeps working with all existing URL formats:
  - Direct URLs
  - Replicate URLs
  - Replicate delivery URLs

Technical additions:
- Added HuggingFace Hub API for repository file listing
- Strong error handling and fallbacks
- Better documentation
- No changes to replicate_weights.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant