Feature Extraction
Transformers
Safetensors
English
minpair
text-to-motion
motion-generation
human-motion
diffusion
smpl-h
custom_code
Instructions to use lschiweck/MinPair with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lschiweck/MinPair with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="lschiweck/MinPair", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("lschiweck/MinPair", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download examples/leg_height.py from lschiweck/MinPair: direct link, hf CLI and curl.
- Browser
- Download file 2.04 kB
-
https://huggingface.co/lschiweck/MinPair/resolve/main/examples/leg_height.py
- Command line
-
hf download hf://lschiweck/MinPair/examples/leg_height.py
-
curl -L -o leg_height.py https://huggingface.co/lschiweck/MinPair/resolve/main/examples/leg_height.py
2.04 kB
| """Leg height example: one word changes, the noise stays the same, three motions. | |
| python examples/leg_height.py [--model <local folder or repo id>] [--out leg_height_output] | |
| Generates the part caption in leg_height.json with the left leg lifting to ankle, knee and hip height, saves each motion | |
| as .npz and prints how high the left foot rises above its standing level, in standing knee heights of the same body. | |
| """ | |
| import argparse | |
| import json | |
| import sys | |
| from pathlib import Path | |
| import torch | |
| from transformers import AutoModel | |
| HERE = Path(__file__).resolve().parent | |
| sys.path.insert(0, str(HERE)) | |
| from measure_foot_height import foot_height # noqa: E402 | |
| def main(): | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--model", default=str(HERE.parent), help="local folder or Hugging Face repo id") | |
| ap.add_argument("--out", default="leg_height_output") | |
| ap.add_argument("--device", default="cuda" if torch.cuda.is_available() else "cpu") | |
| a = ap.parse_args() | |
| spec = json.loads((HERE / "leg_height.json").read_text()) | |
| model = AutoModel.from_pretrained(a.model, trust_remote_code=True).to(a.device) | |
| prompts = [] | |
| for word in spec["values"]: | |
| p = json.loads(json.dumps(spec["prompt"]).replace("{}", word)) | |
| p["id"] = f"leg_{word}" | |
| prompts.append(p) | |
| motions = model.generate_motion(prompts) | |
| out = Path(a.out) | |
| out.mkdir(parents=True, exist_ok=True) | |
| m = spec["measure"] | |
| print(f"{'height word':12s} {'foot lift (cm)':>14s} {'knee heights':>12s}") | |
| results = {} | |
| for word, motion in zip(spec["values"], motions): | |
| motion.save(out / f"{motion.id}.npz") | |
| r = foot_height(motion.joints, motion.fps, m["side"], m["start"], m["end"]) | |
| results[word] = {k: round(v, 4) for k, v in r.items()} | |
| print(f"{word:12s} {100 * r['lift_m']:14.1f} {r['lift_knees']:12.2f}") | |
| (out / "foot_height.json").write_text(json.dumps(results, indent=1) + "\n") | |
| print(f"motions and measurements in {out}/") | |
| if __name__ == "__main__": | |
| main() | |