Christen Millerdurai commited on
Commit
8d91b30
·
1 Parent(s): 553060c
.dockerignore ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ .git
2
+ __pycache__/
3
+ *.pyc
4
+ *.pyo
5
+ *.pyd
6
+ .DS_Store
Dockerfile ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM nvidia/cuda:12.6.3-cudnn-devel-ubuntu22.04
2
+
3
+ ARG DEBIAN_FRONTEND=noninteractive
4
+ ARG PYTHON_VERSION=3.10
5
+ ARG EGOFORCE_REPO_URL=https://github.com/Chris10M/EgoForce.git
6
+ ARG EGOFORCE_REF=main
7
+
8
+ ENV HOME=/home/user \
9
+ APP_HOME=/home/user/app \
10
+ EGOFORCE_ROOT=/home/user/app/EgoForce \
11
+ PATH=/home/user/.local/bin:/home/user/.venv/bin:$PATH \
12
+ PYTHONUNBUFFERED=1 \
13
+ PIP_NO_CACHE_DIR=1 \
14
+ PIP_DISABLE_PIP_VERSION_CHECK=1 \
15
+ CUDA_HOME=/usr/local/cuda \
16
+ FORCE_CUDA=1 \
17
+ TORCH_CUDA_ARCH_LIST="7.5;8.0;8.6;8.9" \
18
+ NVIDIA_VISIBLE_DEVICES=all \
19
+ NVIDIA_DRIVER_CAPABILITIES=compute,utility,graphics \
20
+ PYOPENGL_PLATFORM=egl \
21
+ MPLBACKEND=Agg
22
+
23
+ RUN apt-get update && apt-get install -y --no-install-recommends \
24
+ python3.10 \
25
+ python3.10-dev \
26
+ python3-pip \
27
+ python3.10-venv \
28
+ git \
29
+ curl \
30
+ ca-certificates \
31
+ ffmpeg \
32
+ build-essential \
33
+ cmake \
34
+ ninja-build \
35
+ pkg-config \
36
+ libglib2.0-0 \
37
+ libsm6 \
38
+ libxext6 \
39
+ libxrender1 \
40
+ libgl1 \
41
+ libglvnd0 \
42
+ libegl1 \
43
+ libglu1-mesa \
44
+ libgl1-mesa-dev \
45
+ libegl1-mesa-dev \
46
+ libgles2-mesa-dev \
47
+ libgl1-mesa-dri \
48
+ && rm -rf /var/lib/apt/lists/*
49
+
50
+ RUN ln -sf /usr/bin/python3.10 /usr/local/bin/python && \
51
+ ln -sf /usr/bin/pip3 /usr/local/bin/pip
52
+
53
+ RUN useradd -m -u 1000 user
54
+ USER user
55
+
56
+ WORKDIR $APP_HOME
57
+
58
+ RUN python -m venv /home/user/.venv
59
+
60
+ COPY --chown=user scripts/ $APP_HOME/scripts/
61
+
62
+ RUN chmod +x $APP_HOME/scripts/install_egoforce.sh $APP_HOME/scripts/start.sh
63
+
64
+ RUN git clone --depth 1 --branch "${EGOFORCE_REF}" "${EGOFORCE_REPO_URL}" "$EGOFORCE_ROOT"
65
+
66
+ RUN bash $APP_HOME/scripts/install_egoforce.sh
67
+
68
+ WORKDIR $EGOFORCE_ROOT
69
+
70
+ EXPOSE 7860
71
+
72
+ CMD ["bash", "/home/user/app/scripts/start.sh"]
README.md CHANGED
@@ -3,12 +3,20 @@ title: EgoForce
3
  emoji: 🐠
4
  colorFrom: gray
5
  colorTo: purple
6
- sdk: gradio
7
- sdk_version: 6.9.0
8
- app_file: app.py
9
  pinned: false
10
  license: cc-by-nc-4.0
11
- short_description: 'Forearm-Guided Camera-Space 3D Hand Pose '
 
 
12
  ---
13
 
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
3
  emoji: 🐠
4
  colorFrom: gray
5
  colorTo: purple
6
+ sdk: docker
7
+ app_port: 7860
 
8
  pinned: false
9
  license: cc-by-nc-4.0
10
+ short_description: Forearm-Guided Camera-Space 3D Hand Pose
11
+ suggested_hardware: a10g-small
12
+ startup_duration_timeout: 1h
13
  ---
14
 
15
+ This Space builds a Docker image that:
16
+
17
+ - Clones `EgoForce` Repo.
18
+ - Installs the CUDA-enabled Python and system dependencies required by the demo
19
+ - Downloads the `_DATA` model assets from `chris10/EgoForce` on the Hugging Face Hub
20
+ - Launches `demo/run_app.py` on port `7860`
21
+
22
+ The runtime is Docker-based because the EgoForce demo depends on CUDA, Torch-TensorRT, MMCV, ffmpeg, and headless rendering support.
scripts/__pycache__/download_egoforce_data.cpython-313.pyc ADDED
Binary file (1.77 kB). View file
 
scripts/download_egoforce_data.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import shutil
5
+ from pathlib import Path
6
+
7
+ from huggingface_hub import snapshot_download
8
+
9
+
10
+ def main() -> None:
11
+ repo_root = Path(os.environ["EGOFORCE_ROOT"]).resolve()
12
+ target_data_dir = repo_root / "_DATA"
13
+ cache_root = repo_root / ".hf-download"
14
+
15
+ if target_data_dir.exists():
16
+ print(f"Using existing EgoForce assets at {target_data_dir}")
17
+ return
18
+
19
+ if cache_root.exists():
20
+ shutil.rmtree(cache_root)
21
+
22
+ snapshot_path = Path(
23
+ snapshot_download(
24
+ repo_id=os.environ.get("EGOFORCE_ASSETS_REPO_ID", "chris10/EgoForce"),
25
+ repo_type="model",
26
+ allow_patterns=["_DATA/**"],
27
+ local_dir=cache_root,
28
+ )
29
+ )
30
+ source_data_dir = snapshot_path / "_DATA"
31
+
32
+ if not source_data_dir.exists():
33
+ raise SystemExit(f"Downloaded snapshot did not contain {source_data_dir}")
34
+
35
+ shutil.copytree(source_data_dir, target_data_dir)
36
+ shutil.rmtree(cache_root, ignore_errors=True)
37
+ print(f"Downloaded EgoForce assets to {target_data_dir}")
38
+
39
+
40
+ if __name__ == "__main__":
41
+ main()
scripts/install_egoforce.sh ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euxo pipefail
3
+
4
+ : "${EGOFORCE_ROOT:?EGOFORCE_ROOT must be set}"
5
+
6
+ cd "$EGOFORCE_ROOT"
7
+
8
+ python -m pip install --upgrade pip setuptools==81.0.0 wheel cython pybind11
9
+ python -m pip install torch==2.8.0 torchvision==0.23.0 --index-url https://download.pytorch.org/whl/cu126
10
+ python -m pip install torch_tensorrt==2.8.0+cu126 --find-links https://download.pytorch.org/whl/torch-tensorrt
11
+ python -m pip install -r scripts/requirements.txt
12
+ python -m pip install mmcv==2.1.0 --no-build-isolation
13
+
14
+ python -m pip install git+https://github.com/javrtg/AnyCalib.git --no-build-isolation
15
+ python -m pip install git+https://github.com/mattloper/chumpy.git --no-build-isolation
16
+ python -m pip install git+https://github.com/facebookresearch/pytorch3d.git --no-build-isolation
17
+
18
+ python -m pip install ./thirdparty/datapipes
19
+ python -m pip install ./thirdparty/mmdetection --no-build-isolation
20
+
21
+ python -m pip install projectaria_client_sdk==1.1.0 --no-cache-dir
22
+ python -m pip install huggingface_hub hf_xet
23
+
24
+ python /home/user/app/scripts/download_egoforce_data.py
25
+
26
+ python - <<'PY'
27
+ from pathlib import Path
28
+
29
+ repo_root = Path.cwd()
30
+ required_paths = [
31
+ repo_root / "_DATA" / "model_weights.pth",
32
+ repo_root / "_DATA" / "epoch_460.pth",
33
+ repo_root / "_DATA" / "detector.torchscript",
34
+ repo_root / "_DATA" / "mano",
35
+ ]
36
+
37
+ missing = [str(path) for path in required_paths if not path.exists()]
38
+ if missing:
39
+ raise SystemExit(f"Missing required EgoForce assets after download: {missing}")
40
+
41
+ print("Verified EgoForce assets in", repo_root / "_DATA")
42
+ PY
43
+
44
+ python -m pip install numpy==1.26.4
scripts/start.sh ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ : "${EGOFORCE_ROOT:?EGOFORCE_ROOT must be set}"
5
+
6
+ cd "$EGOFORCE_ROOT"
7
+
8
+ if [[ ! -f demo/run_app.py ]]; then
9
+ echo "EgoForce demo entrypoint not found at $EGOFORCE_ROOT/demo/run_app.py" >&2
10
+ exit 1
11
+ fi
12
+
13
+ if [[ ! -d _DATA ]]; then
14
+ echo "EgoForce _DATA directory is missing at $EGOFORCE_ROOT/_DATA" >&2
15
+ exit 1
16
+ fi
17
+
18
+ exec python demo/run_app.py \
19
+ --server-name 0.0.0.0 \
20
+ --server-port "${PORT:-7860}"