File size: 2,519 Bytes
18b382b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
# Copyright (c) Delanoe Pirard / Aedelon
# Licensed under the Apache License, Version 2.0
#
# Deploy to HuggingFace Spaces with LFS for binary files
# This script temporarily enables LFS, pushes to HF, then restores normal state

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
cd "$PROJECT_ROOT"

# HuggingFace Spaces YAML front matter
HF_YAML='---
title: Awesome Depth Anything 3
emoji: 🌊
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.50.0
app_file: app.py
pinned: false
license: apache-2.0
short_description: Metric 3D reconstruction from images/video
---

'

echo "=== HuggingFace Deployment Script ==="

# Save current HEAD
CURRENT_SHA=$(git rev-parse HEAD)
echo "Current commit: $CURRENT_SHA"

# Step 1: Configure LFS for binary files
echo ""
echo "Step 1: Configuring Git LFS..."
cat > .gitattributes << 'EOF'
*.png filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.jpeg filter=lfs diff=lfs merge=lfs -text
*.gif filter=lfs diff=lfs merge=lfs -text
*.mp4 filter=lfs diff=lfs merge=lfs -text
*.webm filter=lfs diff=lfs merge=lfs -text
EOF

# Step 2: Create deployment branch
echo ""
echo "Step 2: Creating deployment branch..."
git checkout --orphan hf-deploy-temp 2>/dev/null || git checkout hf-deploy-temp

# Reset to get clean state
git reset

# Step 3: Add YAML to README
echo ""
echo "Step 3: Adding YAML front matter to README..."
cp README.md README.md.original
echo "$HF_YAML$(cat README.md.original)" > README.md

# Step 4: Stage all files (LFS will handle binaries)
echo ""
echo "Step 4: Staging files with LFS..."
git add .gitattributes
git add -A

# Step 5: Commit
echo ""
echo "Step 5: Committing..."
git commit -m "Deploy to HuggingFace Spaces" --no-verify || true

# Step 6: Push to HuggingFace
echo ""
echo "Step 6: Pushing to HuggingFace Spaces..."
git push huggingface hf-deploy-temp:main --force

# Step 7: Cleanup - return to main branch
echo ""
echo "Step 7: Cleaning up..."
git checkout main --force
git branch -D hf-deploy-temp 2>/dev/null || true

# Restore original .gitattributes (no LFS)
cat > .gitattributes << 'EOF'
*.png !text !filter !merge !diff
*.jpg !text !filter !merge !diff
*.jpeg !text !filter !merge !diff
*.gif !text !filter !merge !diff
*.mp4 !text !filter !merge !diff
*.webm !text !filter !merge !diff
EOF

echo ""
echo "=== Done! ==="
echo "HuggingFace updated with YAML metadata and LFS binaries."
echo "Local repo restored to normal state (no LFS)."