Spaces:
Sleeping
Sleeping
Georg
Claude Sonnet 4.5
commited on
Commit
·
dd44013
1
Parent(s):
d5c5d99
Fix Dockerfile build errors and always use real model
Browse filesBuild Fixes:
- Add cmake and build-essential to system dependencies
- Install PyTorch before building C++ extensions (required)
- Build only mycuda and mycpp (skip optional kaolin)
- Use proper pip install commands for C++ extensions
Always Real Mode:
- Remove USE_HF_WEIGHTS and USE_REAL_MODEL env var checks
- Always download weights from gpue/foundationpose-weights
- Set USE_REAL_MODEL=true permanently in app.py
- Update UI to show 'Real FoundationPose with GPU'
- Update README to mention Docker GPU (not ZeroGPU)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Dockerfile +13 -12
- README.md +1 -1
- app.py +4 -4
- download_weights.py +14 -20
Dockerfile
CHANGED
|
@@ -6,15 +6,16 @@ ENV CUDA_HOME=/usr/local/cuda
|
|
| 6 |
ENV PATH=${CUDA_HOME}/bin:${PATH}
|
| 7 |
ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
|
| 8 |
|
| 9 |
-
# FoundationPose configuration
|
| 10 |
ENV FOUNDATIONPOSE_MODEL_REPO=gpue/foundationpose-weights
|
| 11 |
-
ENV
|
| 12 |
-
ENV USE_REAL_MODEL=false
|
| 13 |
|
| 14 |
# Install system dependencies
|
| 15 |
RUN apt-get update && apt-get install -y \
|
| 16 |
git \
|
| 17 |
wget \
|
|
|
|
|
|
|
| 18 |
python3.10 \
|
| 19 |
python3.10-dev \
|
| 20 |
python3-pip \
|
|
@@ -36,27 +37,27 @@ RUN python3 -m pip install --upgrade pip
|
|
| 36 |
# Set working directory
|
| 37 |
WORKDIR /app
|
| 38 |
|
| 39 |
-
# Install Python dependencies first (for
|
| 40 |
COPY requirements.txt .
|
|
|
|
| 41 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 42 |
|
| 43 |
# Clone FoundationPose repository
|
| 44 |
RUN git clone https://github.com/NVlabs/FoundationPose.git /app/FoundationPose
|
| 45 |
|
| 46 |
-
# Build FoundationPose C++ extensions
|
| 47 |
WORKDIR /app/FoundationPose
|
| 48 |
-
RUN
|
|
|
|
| 49 |
|
| 50 |
# Copy application files
|
| 51 |
WORKDIR /app
|
| 52 |
-
COPY app.py client.py estimator.py
|
| 53 |
|
| 54 |
-
# Create weights directory
|
| 55 |
RUN mkdir -p weights
|
| 56 |
-
|
| 57 |
-
|
| 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
|
|
|
|
| 6 |
ENV PATH=${CUDA_HOME}/bin:${PATH}
|
| 7 |
ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
|
| 8 |
|
| 9 |
+
# FoundationPose configuration - always use real model
|
| 10 |
ENV FOUNDATIONPOSE_MODEL_REPO=gpue/foundationpose-weights
|
| 11 |
+
ENV USE_REAL_MODEL=true
|
|
|
|
| 12 |
|
| 13 |
# Install system dependencies
|
| 14 |
RUN apt-get update && apt-get install -y \
|
| 15 |
git \
|
| 16 |
wget \
|
| 17 |
+
cmake \
|
| 18 |
+
build-essential \
|
| 19 |
python3.10 \
|
| 20 |
python3.10-dev \
|
| 21 |
python3-pip \
|
|
|
|
| 37 |
# Set working directory
|
| 38 |
WORKDIR /app
|
| 39 |
|
| 40 |
+
# Install Python dependencies first (PyTorch needed for building C++ extensions)
|
| 41 |
COPY requirements.txt .
|
| 42 |
+
RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cu118
|
| 43 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 44 |
|
| 45 |
# Clone FoundationPose repository
|
| 46 |
RUN git clone https://github.com/NVlabs/FoundationPose.git /app/FoundationPose
|
| 47 |
|
| 48 |
+
# Build FoundationPose C++ extensions (skip kaolin - optional dependency)
|
| 49 |
WORKDIR /app/FoundationPose
|
| 50 |
+
RUN cd bundlesdf/mycuda && pip install -e .
|
| 51 |
+
RUN cd mycpp && python setup.py build_ext --inplace
|
| 52 |
|
| 53 |
# Copy application files
|
| 54 |
WORKDIR /app
|
| 55 |
+
COPY app.py client.py estimator.py ./
|
| 56 |
|
| 57 |
+
# Create weights directory and download model weights
|
| 58 |
RUN mkdir -p weights
|
| 59 |
+
RUN python3 -c "from huggingface_hub import snapshot_download; \
|
| 60 |
+
snapshot_download(repo_id='gpue/foundationpose-weights', local_dir='weights', repo_type='model')"
|
|
|
|
|
|
|
| 61 |
|
| 62 |
# Expose Gradio port
|
| 63 |
EXPOSE 7860
|
README.md
CHANGED
|
@@ -16,7 +16,7 @@ tags:
|
|
| 16 |
|
| 17 |
# FoundationPose Inference Server
|
| 18 |
|
| 19 |
-
This Hugging Face Space provides 6D object pose estimation using [FoundationPose](https://github.com/NVlabs/FoundationPose) with
|
| 20 |
|
| 21 |
## Features
|
| 22 |
|
|
|
|
| 16 |
|
| 17 |
# FoundationPose Inference Server
|
| 18 |
|
| 19 |
+
This Hugging Face Space provides 6D object pose estimation using [FoundationPose](https://github.com/NVlabs/FoundationPose) with GPU support via Docker.
|
| 20 |
|
| 21 |
## Features
|
| 22 |
|
app.py
CHANGED
|
@@ -22,10 +22,10 @@ logging.basicConfig(
|
|
| 22 |
)
|
| 23 |
logger = logging.getLogger(__name__)
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
USE_REAL_MODEL =
|
| 27 |
|
| 28 |
-
logger.info(
|
| 29 |
|
| 30 |
|
| 31 |
class FoundationPoseInference:
|
|
@@ -282,7 +282,7 @@ with gr.Blocks(title="FoundationPose Inference", theme=gr.themes.Soft()) as demo
|
|
| 282 |
gr.Markdown("# 🎯 FoundationPose 6D Object Pose Estimation")
|
| 283 |
|
| 284 |
mode_indicator = gr.Markdown(
|
| 285 |
-
|
| 286 |
elem_id="mode"
|
| 287 |
)
|
| 288 |
|
|
|
|
| 22 |
)
|
| 23 |
logger = logging.getLogger(__name__)
|
| 24 |
|
| 25 |
+
# Always use real FoundationPose model
|
| 26 |
+
USE_REAL_MODEL = True
|
| 27 |
|
| 28 |
+
logger.info("Starting in REAL mode with FoundationPose")
|
| 29 |
|
| 30 |
|
| 31 |
class FoundationPoseInference:
|
|
|
|
| 282 |
gr.Markdown("# 🎯 FoundationPose 6D Object Pose Estimation")
|
| 283 |
|
| 284 |
mode_indicator = gr.Markdown(
|
| 285 |
+
"**Mode:** 🟢 Real FoundationPose with GPU",
|
| 286 |
elem_id="mode"
|
| 287 |
)
|
| 288 |
|
download_weights.py
CHANGED
|
@@ -4,29 +4,23 @@
|
|
| 4 |
import os
|
| 5 |
from pathlib import Path
|
| 6 |
|
| 7 |
-
#
|
| 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 |
-
|
| 14 |
-
print(f'Downloading weights from {repo}...')
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
else:
|
| 31 |
-
print('Placeholder mode - skipping weight download')
|
| 32 |
-
print('Set USE_REAL_MODEL=true and USE_HF_WEIGHTS=true to enable')
|
|
|
|
| 4 |
import os
|
| 5 |
from pathlib import Path
|
| 6 |
|
| 7 |
+
# Always download weights from model repository
|
| 8 |
repo = os.environ.get('FOUNDATIONPOSE_MODEL_REPO', 'gpue/foundationpose-weights')
|
| 9 |
token = os.environ.get('HF_TOKEN')
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
print(f'Downloading weights from {repo}...')
|
|
|
|
| 12 |
|
| 13 |
+
try:
|
| 14 |
+
from huggingface_hub import snapshot_download
|
| 15 |
|
| 16 |
+
snapshot_download(
|
| 17 |
+
repo_id=repo,
|
| 18 |
+
local_dir='weights',
|
| 19 |
+
token=token,
|
| 20 |
+
repo_type='model'
|
| 21 |
+
)
|
| 22 |
|
| 23 |
+
print('✓ Weights downloaded successfully')
|
| 24 |
+
except Exception as e:
|
| 25 |
+
print(f'✗ Weight download failed: {e}')
|
| 26 |
+
raise
|
|
|
|
|
|
|
|
|