File size: 3,250 Bytes
77dc9d8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83071f4
77dc9d8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c28ea41
77dc9d8
 
 
 
 
 
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
---
language:
- en
license: other
license_name: nvidia-open-model-license
license_link: https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license/
base_model:
- nvidia/GEM-X
- PekingU/rtdetr_r101vd_coco_o365
library_name: diffusers
tags:
- gem-x
- modular-diffusers
- motion-capture
- pose-estimation
- video
- soma
---

# GEM-X SOMA Diffusers

<video controls autoplay loop muted playsinline src="https://huggingface.co/datasets/OzzyGT/diffusers-examples/resolve/main/gem-x/gemx_soma_karate_foot_lock_v2.mp4"></video>

*Left: the camera-space skeleton and 2D keypoints. Right: the world motion. The clip is AI-generated, the first frame with MiniMax-H3-Image and the video with MiniMax-H3.*

A Diffusers conversion of the native77 body model of [nvidia/GEM-X](https://huggingface.co/nvidia/GEM-X), which reconstructs the 3D motion of one person in a video. This repository holds the weights, configs and model code: the RT-DETR person detector, GEM-X's keypoint model, pose encoder and motion transformer, and Kimodo's neutral SOMA77 skeleton.

For model details, see the [original model card](https://huggingface.co/nvidia/GEM-X) and the [GEM-X repository](https://github.com/NVlabs/GEM-X).

## Usage

Install PyTorch for your GPU, then:

```bash
pip install "diffusers>=0.41.0" "transformers>=5.3.0" "torchvision>=0.25" "opencv-python-headless>=4.10" "scipy>=1.11" imageio imageio-ffmpeg
```

The model runs with the [GEM-X SOMA Modular Diffusers](https://huggingface.co/OzzyGT/gemx_soma_custom_blocks) blocks.

> **Note:** `trust_remote_code=True` runs the code of the blocks repository and `trust_components_code=True` the model code in this one, both downloaded from the Hub. Only use them with repositories you trust.

```python
import numpy as np
import torch
from diffusers import ModularPipelineBlocks
from diffusers.utils import load_video


blocks = ModularPipelineBlocks.from_pretrained(
    "OzzyGT/gemx_soma_custom_blocks",
    trust_remote_code=True,
    components_repo="OzzyGT/gemx_soma_diffusers",
    trust_components_code=True,
)
pipe = blocks.init_pipeline()
pipe.load_components(dtype=torch.float32)
pipe.to("cuda")

video = load_video("clip_30fps.mp4")
motion = pipe(video=video, output="motion")
np.savez_compressed("motion.npz", **{key: value.cpu().numpy() for key, value in motion.items()})
```

The clip must be at 30 FPS. The result is a SOMA77 motion in meters, +Y up, with Kimodo's joint order and rotation convention; the blocks can also return the SOMA body parameters. The feet are locked in place while they touch the floor; pass `foot_lock=False` for GEM-X's raw prediction. Use float32, which matches GEM-X. See the [blocks](https://huggingface.co/OzzyGT/gemx_soma_custom_blocks) for the inputs and outputs.

## Licenses

- GEM-X weights: [NVIDIA Open Model License](https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license/), from [nvidia/GEM-X](https://huggingface.co/nvidia/GEM-X). See [NOTICE](NOTICE).
- Person detector: Apache-2.0, from [PekingU/rtdetr_r101vd_coco_o365](https://huggingface.co/PekingU/rtdetr_r101vd_coco_o365), unchanged.
- Model code and the skeleton from [NVIDIA Kimodo](https://github.com/nv-tlabs/kimodo): [Apache-2.0](LICENSE).