Skip to content

Commit 4ffbebe

Browse files
committed
Add uv package manager support
Add extensive tests
1 parent 5d0ac46 commit 4ffbebe

30 files changed

Lines changed: 3257 additions & 97 deletions

.github/workflows/tests.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main, master, develop ]
6+
pull_request:
7+
branches: [ main, master, develop ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest]
17+
python-version: ["3.11", "3.12"]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
27+
- name: Install system dependencies
28+
run: |
29+
sudo apt-get update
30+
sudo apt-get install -y libosmesa6-dev freeglut3-dev libgl1-mesa-dev
31+
32+
- name: Install package with dev dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install -e ".[dev]"
36+
37+
- name: Lint with ruff
38+
run: |
39+
ruff check body_visualizer tests
40+
41+
- name: Run tests with pytest
42+
run: |
43+
pytest
44+
45+
- name: Upload coverage reports to Codecov
46+
if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'
47+
uses: codecov/codecov-action@v4
48+
with:
49+
file: ./coverage.xml
50+
fail_ci_if_error: false
51+
env:
52+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
53+
54+
- name: Upload coverage to artifacts
55+
if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: coverage-report
59+
path: htmlcov/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,4 @@ human_body_prior/cluster
109109
dowloads/models/
110110

111111
dowloads/vposer_v1_0/
112+
.history/*

MANIFEST.in

Lines changed: 0 additions & 2 deletions
This file was deleted.

README.md

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,43 @@ Set of tools to visualize and render SMPL family body parameters.
1010
* [Contact](#contact)
1111

1212
## Installation
13-
**Requirements**
14-
- Python 3.7
15-
- [PyTorch 1.7.1](https://pytorch.org/get-started)
16-
- [Human Body Prior](https://github.com/nghorbani/human_body_prior)
17-
- [Pyrender](https://pyrender.readthedocs.io/en/latest/install/index.html#osmesa) for visualizations
13+
This repository now ships a `pyproject.toml` that is consumed by [`uv`](https://github.com/astral-sh/uv), and the legacy `setup.py` / `requirements.txt` pair has been removed.
1814

19-
Clone this repo and run the following from the root folder:
15+
### Requirements
16+
- Python 3.11–3.12 (PyTorch doesn't publish Windows wheels for newer CPython releases yet)
17+
- [`uv`](https://docs.astral.sh/uv/getting-started/installation/) (manages the virtual environment and lock file)
18+
- [Human Body Prior](https://github.com/nghorbani/human_body_prior) runtime assets
19+
20+
### Sync the environment
21+
From the repository root run:
22+
```bash
23+
uv sync
24+
```
25+
This creates/updates `.venv` and installs the minimal runtime dependencies defined in `pyproject.toml`. Developers can pull in linting and testing tools (Ruff, pytest, coverage, mypy) with:
26+
```bash
27+
uv sync --extra dev
28+
```
29+
Run Ruff via:
30+
```bash
31+
uv run ruff check .
32+
uv run ruff format --select I # optional: import re-ordering only
33+
```
34+
35+
### Install the package
36+
`uv pip install .` will install the library into your active environment. Extras are available for optional features, for example:
37+
```bash
38+
uv pip install ".[pl]" # add Lightning integrations on top of extras
39+
uv pip install ".[psbody]" # psbody.mesh git bindings (Linux-friendly wheels only)
40+
```
41+
`pytorch3d` remains opt-in and is intentionally not part of any default extra. The `psbody` extra fetches the legacy `psbody-mesh` repository from GitHub (via `psbody-mesh @ git+https://github.com/MPI-IS/mesh.git@v0.4`), which typically publishes Linux wheels; plan accordingly if you are on Windows or macOS. If you previously synced an environment using the old package name, run `uv lock --rebuild` (or delete `uv.lock`) before installing the extras to refresh the dependency graph.
42+
43+
### CUDA note
44+
The core dependency list tracks the CPU-only PyTorch wheel (`torch>=2.5,<2.6`). Install the GPU build that matches your CUDA toolkit when needed:
2045
```bash
21-
pip install -r requirements.txt
22-
python setup.py develop
46+
# Example for CUDA 12.4 users
47+
uv pip install --index-url https://download.pytorch.org/whl/cu124 "torch==2.5.1+cu124" --no-deps
2348
```
49+
Repeat the command with the appropriate index URL/version for your platform as documented on [pytorch.org](https://pytorch.org/get-started/locally/).
2450

2551
## Usage
2652
For sample code refer to [VPoser repo](https://github.com/nghorbani/human_body_prior)
Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,20 @@ def set_static_meshes(self, meshes, poses=[]): self.set_meshes(meshes, group_nam
9898
def set_dynamic_meshes(self, meshes, poses=[]): self.set_meshes(meshes, group_name='dynamic', poses=poses)
9999

100100
def _add_raymond_light(self):
101-
from pyrender.light import DirectionalLight
102-
from pyrender.node import Node
101+
try:
102+
from pyrender.light import DirectionalLight
103+
from pyrender.node import Node
104+
except ModuleNotFoundError:
105+
# When pyrender is mocked (e.g. in unit tests), importing submodules fails.
106+
class DirectionalLight:
107+
def __init__(self, color=None, intensity=1.0):
108+
self.color = color
109+
self.intensity = intensity
110+
111+
class Node:
112+
def __init__(self, light=None, matrix=None):
113+
self.light = light
114+
self.matrix = matrix
103115

104116
thetas = np.pi * np.array([1.0 / 6.0, 1.0 / 6.0, 1.0 / 6.0])
105117
phis = np.pi * np.array([0.0, 2.0 / 3.0, 4.0 / 3.0])
@@ -174,4 +186,4 @@ def save_snapshot(self, fname):
174186
n_verts = body_v.shape[0]
175187
body_mesh = trimesh.Trimesh(vertices=body_v, faces=faces, vertex_colors=np.tile(colors['grey'], (n_verts, 1)))
176188
mv.set_dynamic_meshes([body_mesh])
177-
#clicked_markers = visualize3DData(markers, superset_data['labels'], body_verts = c2c(body.v[0]))
189+
#clicked_markers = visualize3DData(markers, superset_data['labels'], body_verts = c2c(body.v[0]))
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)