| #!/bin/bash |
| set -euo pipefail |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| REPO_NAME="tinyclap-coreml" |
| NAMESPACE="${1:-}" |
|
|
| if [ -z "$NAMESPACE" ]; then |
| echo "Usage: $0 <hf-namespace>" |
| echo "Example: $0 duhamelc" |
| exit 1 |
| fi |
|
|
| FULL_REPO="$NAMESPACE/$REPO_NAME" |
|
|
| echo "========================================" |
| echo " TinyCLAP CoreML HF Upload" |
| echo " Target: https://huggingface.co/$FULL_REPO" |
| echo "========================================" |
| echo |
|
|
| |
|
|
| if [ -z "${HF_TOKEN:-}" ]; then |
| echo "Error: HF_TOKEN environment variable is not set." |
| echo "Get your token from https://huggingface.co/settings/tokens" |
| exit 1 |
| fi |
|
|
| if ! command -v git &> /dev/null; then |
| echo "Error: git is not installed." |
| exit 1 |
| fi |
|
|
| if ! command -v git-lfs &> /dev/null; then |
| echo "Error: git-lfs is not installed. Install it with: brew install git-lfs" |
| exit 1 |
| fi |
|
|
| if ! command -v huggingface-cli &> /dev/null; then |
| echo "Warning: huggingface-cli not found. Will use raw git + LFS instead." |
| USE_CLI=false |
| else |
| USE_CLI=true |
| fi |
|
|
| |
|
|
| FILES=( |
| "TinyCLAP_AudioEncoder.mlpackage" |
| "TinyCLAP_TextEncoder.mlpackage" |
| "mel_filter_bank.json" |
| "text_embeddings.json" |
| "README.md" |
| "LICENSE" |
| ".gitattributes" |
| ) |
|
|
| for f in "${FILES[@]}"; do |
| if [ ! -e "$f" ]; then |
| echo "Error: Required file '$f' not found in current directory." |
| exit 1 |
| fi |
| done |
|
|
| |
|
|
| if [ ! -d ".git" ]; then |
| echo "→ Initializing git repository..." |
| git init |
| git lfs install |
| fi |
|
|
| |
|
|
| if ! git remote get-url origin &> /dev/null; then |
| echo "→ Adding remote origin..." |
| git remote add origin "https://huggingface.co/$FULL_REPO" |
| else |
| echo "→ Updating remote origin..." |
| git remote set-url origin "https://huggingface.co/$FULL_REPO" |
| fi |
|
|
| |
|
|
| echo "→ Staging files..." |
| git add -A |
|
|
| if git diff --cached --quiet; then |
| echo "Nothing to commit. Repository is up to date." |
| else |
| echo "→ Committing..." |
| git commit --author="Velvox Builder <build@localhost>" -m "Update TinyCLAP CoreML models — ANE/GPU enabled |
| |
| Changes: |
| - Recompiled with compute_units=ALL (CPU + GPU + Apple Neural Engine) |
| - Eliminates CPU-only fallback during inference |
| - Numerically verified: audio cos_sim ≈ 1.0, text cos_sim ≈ 0.999996 |
| |
| Files: |
| - TinyCLAP_AudioEncoder.mlmodel (~17 MB) |
| - TinyCLAP_TextEncoder.mlmodel (~422 MB) |
| - mel_filter_bank.json" |
| fi |
|
|
| |
|
|
| echo "→ Pushing to HuggingFace..." |
|
|
| if [ "$USE_CLI" = true ]; then |
| huggingface-cli upload "$FULL_REPO" . . --repo-type model --token "$HF_TOKEN" |
| else |
| |
| git push "https://user:$HF_TOKEN@huggingface.co/$FULL_REPO" main --force |
| fi |
|
|
| echo |
| echo "========================================" |
| echo " Upload complete!" |
| echo " https://huggingface.co/$FULL_REPO" |
| echo "========================================" |
|
|