Spaces:
Sleeping
Sleeping
Georg Claude Sonnet 4.5 commited on
Commit ·
d5c5d99
1
Parent(s): 2df2c23
Fix Dockerfile Python one-liner syntax error
Browse files- Create download_weights.py script instead of inline Python
- Update Dockerfile to use script (cleaner and avoids syntax errors)
- Copy estimator.py in Dockerfile
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Dockerfile +2 -14
- download_weights.py +32 -0
Dockerfile
CHANGED
|
@@ -49,26 +49,14 @@ RUN bash build_all.sh || echo "⚠️ Build completed with warnings"
|
|
| 49 |
|
| 50 |
# Copy application files
|
| 51 |
WORKDIR /app
|
| 52 |
-
COPY app.py client.py ./
|
| 53 |
|
| 54 |
# Create weights directory
|
| 55 |
RUN mkdir -p weights
|
| 56 |
|
| 57 |
# Download weights if USE_HF_WEIGHTS=true (optional at build time)
|
| 58 |
# Weights can also be downloaded at runtime
|
| 59 |
-
RUN python3
|
| 60 |
-
from pathlib import Path; \
|
| 61 |
-
from huggingface_hub import snapshot_download; \
|
| 62 |
-
repo = os.environ.get('FOUNDATIONPOSE_MODEL_REPO', 'gpue/foundationpose-weights'); \
|
| 63 |
-
token = os.environ.get('HF_TOKEN'); \
|
| 64 |
-
use_hf = os.environ.get('USE_HF_WEIGHTS', 'false').lower() == 'true'; \
|
| 65 |
-
use_real = os.environ.get('USE_REAL_MODEL', 'false').lower() == 'true'; \
|
| 66 |
-
if use_hf and use_real: \
|
| 67 |
-
print(f'Downloading weights from {repo}...'); \
|
| 68 |
-
snapshot_download(repo_id=repo, local_dir='weights', token=token, repo_type='model'); \
|
| 69 |
-
print('✓ Weights downloaded'); \
|
| 70 |
-
else: \
|
| 71 |
-
print('Placeholder mode - skipping weights')" || echo "⚠️ Weight download skipped"
|
| 72 |
|
| 73 |
# Expose Gradio port
|
| 74 |
EXPOSE 7860
|
|
|
|
| 49 |
|
| 50 |
# Copy application files
|
| 51 |
WORKDIR /app
|
| 52 |
+
COPY app.py client.py estimator.py download_weights.py ./
|
| 53 |
|
| 54 |
# Create weights directory
|
| 55 |
RUN mkdir -p weights
|
| 56 |
|
| 57 |
# Download weights if USE_HF_WEIGHTS=true (optional at build time)
|
| 58 |
# Weights can also be downloaded at runtime
|
| 59 |
+
RUN python3 download_weights.py || echo "⚠️ Weight download skipped"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
# Expose Gradio port
|
| 62 |
EXPOSE 7860
|
download_weights.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Download model weights from HuggingFace model repository."""
|
| 3 |
+
|
| 4 |
+
import os
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
# Check environment variables
|
| 8 |
+
repo = os.environ.get('FOUNDATIONPOSE_MODEL_REPO', 'gpue/foundationpose-weights')
|
| 9 |
+
token = os.environ.get('HF_TOKEN')
|
| 10 |
+
use_hf = os.environ.get('USE_HF_WEIGHTS', 'false').lower() == 'true'
|
| 11 |
+
use_real = os.environ.get('USE_REAL_MODEL', 'false').lower() == 'true'
|
| 12 |
+
|
| 13 |
+
if use_hf and use_real:
|
| 14 |
+
print(f'Downloading weights from {repo}...')
|
| 15 |
+
|
| 16 |
+
try:
|
| 17 |
+
from huggingface_hub import snapshot_download
|
| 18 |
+
|
| 19 |
+
snapshot_download(
|
| 20 |
+
repo_id=repo,
|
| 21 |
+
local_dir='weights',
|
| 22 |
+
token=token,
|
| 23 |
+
repo_type='model'
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
print('✓ Weights downloaded successfully')
|
| 27 |
+
except Exception as e:
|
| 28 |
+
print(f'⚠️ Weight download failed: {e}')
|
| 29 |
+
print('Space will run in placeholder mode')
|
| 30 |
+
else:
|
| 31 |
+
print('Placeholder mode - skipping weight download')
|
| 32 |
+
print('Set USE_REAL_MODEL=true and USE_HF_WEIGHTS=true to enable')
|