Instructions to use nvidia/Cosmos3-Nano-Transfer-Auto with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Cosmos
How to use nvidia/Cosmos3-Nano-Transfer-Auto with Cosmos:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Model Card: Add SGLang Instruction
#11
by kediwu0331 - opened
README.md
CHANGED
|
@@ -105,6 +105,7 @@ Our AI models are designed and/or optimized to run on NVIDIA GPU-accelerated sys
|
|
| 105 |
|
| 106 |
- [PyTorch](https://pytorch.org/)
|
| 107 |
- [vLLM-Omni](https://github.com/vllm-project/vllm-omni)
|
|
|
|
| 108 |
|
| 109 |
**Supported Hardware Microarchitecture Compatibility:**
|
| 110 |
|
|
@@ -488,7 +489,7 @@ NUM_FRAMES = 201
|
|
| 488 |
CAPTION_FOLDER = "captions_with_timestamp"
|
| 489 |
|
| 490 |
# Download the sample's WSM controls, captions, and negative prompt (about 4 MB).
|
| 491 |
-
scene = Path(snapshot_download(MODEL,
|
| 492 |
"assets/sample_data/daytime_scene/wsm/*.mp4",
|
| 493 |
f"assets/sample_data/daytime_scene/{CAPTION_FOLDER}/*.json",
|
| 494 |
"assets/sample_data/daytime_scene/captions/negative_prompt.txt",
|
|
@@ -560,6 +561,127 @@ With the daytime sample, the output looks like this, tiled as a surround view wi
|
|
| 560 |
|
| 561 |
<video src="https://huggingface.co/nvidia/Cosmos3-Nano-Transfer-Auto/resolve/main/images/cosmos3-nano-transfer-auto-quickstart.mp4" controls autoplay loop muted playsinline width="100%"></video>
|
| 562 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 563 |
## Ethical Considerations
|
| 564 |
|
| 565 |
NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications. Developers should work with their internal model team to ensure this model meets requirements for the relevant industry and use case and addresses unforeseen product misuse.
|
|
|
|
| 105 |
|
| 106 |
- [PyTorch](https://pytorch.org/)
|
| 107 |
- [vLLM-Omni](https://github.com/vllm-project/vllm-omni)
|
| 108 |
+
- [SGLang](https://github.com/sgl-project/sglang)
|
| 109 |
|
| 110 |
**Supported Hardware Microarchitecture Compatibility:**
|
| 111 |
|
|
|
|
| 489 |
CAPTION_FOLDER = "captions_with_timestamp"
|
| 490 |
|
| 491 |
# Download the sample's WSM controls, captions, and negative prompt (about 4 MB).
|
| 492 |
+
scene = Path(snapshot_download(MODEL, allow_patterns=[
|
| 493 |
"assets/sample_data/daytime_scene/wsm/*.mp4",
|
| 494 |
f"assets/sample_data/daytime_scene/{CAPTION_FOLDER}/*.json",
|
| 495 |
"assets/sample_data/daytime_scene/captions/negative_prompt.txt",
|
|
|
|
| 561 |
|
| 562 |
<video src="https://huggingface.co/nvidia/Cosmos3-Nano-Transfer-Auto/resolve/main/images/cosmos3-nano-transfer-auto-quickstart.mp4" controls autoplay loop muted playsinline width="100%"></video>
|
| 563 |
|
| 564 |
+
### Quick Start with SGLang
|
| 565 |
+
|
| 566 |
+
[SGLang](https://github.com/sgl-project/sglang) serves the same model through its OpenAI-compatible Videos API and produces the same camera-major video as the example above. Two things differ: the server reads every input from a path it can open instead of accepting uploads, so the sample is downloaded into a directory that is mounted into the container, and generation runs as an asynchronous job that the client polls. For joint camera and LiDAR generation with SGLang, see the [SGLang notebook](https://github.com/NVIDIA/cosmos-framework/blob/main/.agents/skills/cookbooks/cosmos3/simulation/auto/run_auto_with_sglang.ipynb).
|
| 567 |
+
|
| 568 |
+
#### 1. Start the server
|
| 569 |
+
|
| 570 |
+
On the same kind of host, with the published [`lmsysorg/sglang:dev`](https://hub.docker.com/r/lmsysorg/sglang/tags) image, which includes the Cosmos3 pipelines from [sgl-project/sglang#39475](https://github.com/sgl-project/sglang/pull/39475):
|
| 571 |
+
|
| 572 |
+
```bash
|
| 573 |
+
export SAMPLE_DIR="$PWD/cosmos3-daytime-sample" # Receives the inputs; the server reads them from this path.
|
| 574 |
+
export SGLANG_HF_CACHE="${SGLANG_HF_CACHE:-$HOME/.cache/sglang-huggingface}" # The container runs as root.
|
| 575 |
+
mkdir -p "$SAMPLE_DIR" "$SGLANG_HF_CACHE"
|
| 576 |
+
chmod 777 "$SGLANG_HF_CACHE"
|
| 577 |
+
docker pull lmsysorg/sglang:dev
|
| 578 |
+
docker run --init --runtime nvidia --gpus all --ipc=host \
|
| 579 |
+
-v "$SGLANG_HF_CACHE:/root/.cache/huggingface" \
|
| 580 |
+
-v "$SAMPLE_DIR:$SAMPLE_DIR" \
|
| 581 |
+
--env "HF_TOKEN=$HF_TOKEN" \
|
| 582 |
+
-p 127.0.0.1:30000:30000 \
|
| 583 |
+
lmsysorg/sglang:dev \
|
| 584 |
+
sglang serve \
|
| 585 |
+
--model-path nvidia/Cosmos3-Nano-Transfer-Auto \
|
| 586 |
+
--host 0.0.0.0 --port 30000
|
| 587 |
+
```
|
| 588 |
+
|
| 589 |
+
The container publishes the server on `127.0.0.1:30000` of the host and mounts `SAMPLE_DIR` at the same path, so the paths in the request below are valid inside it. The `dev` tag moves with SGLang's main branch, so pull it before each start. The first start downloads the checkpoint; the HTTP port opens after the weights are loaded and the warmup request finishes. With N GPUs (2, 4, or 8), add `--num-gpus N --ulysses-degree N --sp-degree N` to `sglang serve` to split the camera-major sequence across them with Ulysses sequence parallelism; `--enable-cfg-parallel` additionally runs the two guidance branches on separate GPU groups and doubles the GPUs required.
|
| 590 |
+
|
| 591 |
+
#### 2. Generate the camera videos
|
| 592 |
+
|
| 593 |
+
Run this in the same shell, so `SAMPLE_DIR` is set:
|
| 594 |
+
|
| 595 |
+
```bash
|
| 596 |
+
pip install requests huggingface_hub
|
| 597 |
+
```
|
| 598 |
+
|
| 599 |
+
```python
|
| 600 |
+
import json
|
| 601 |
+
import os
|
| 602 |
+
import time
|
| 603 |
+
from pathlib import Path
|
| 604 |
+
|
| 605 |
+
import requests
|
| 606 |
+
from huggingface_hub import snapshot_download
|
| 607 |
+
|
| 608 |
+
MODEL = "nvidia/Cosmos3-Nano-Transfer-Auto"
|
| 609 |
+
SERVER = "http://127.0.0.1:30000"
|
| 610 |
+
SAMPLE_DIR = Path(os.environ["SAMPLE_DIR"]).resolve() # Mounted into the server container at this path.
|
| 611 |
+
# The sample's seven cameras, in the checkpoint's camera order.
|
| 612 |
+
CAMERAS = [
|
| 613 |
+
"camera_front_wide_120fov",
|
| 614 |
+
"camera_cross_right_120fov",
|
| 615 |
+
"camera_rear_right_70fov",
|
| 616 |
+
"camera_rear_tele_30fov",
|
| 617 |
+
"camera_rear_left_70fov",
|
| 618 |
+
"camera_cross_left_120fov",
|
| 619 |
+
"camera_front_tele_30fov",
|
| 620 |
+
]
|
| 621 |
+
NUM_FRAMES = 201
|
| 622 |
+
# Set CAPTION_FOLDER="captions_with_timestamp" to use timestamped captions, which better match the
|
| 623 |
+
# model's training style and have empirically produced better inference results. Set it to
|
| 624 |
+
# "captions" to try the original paragraph-style captions. Both formats are supported.
|
| 625 |
+
CAPTION_FOLDER = "captions_with_timestamp"
|
| 626 |
+
|
| 627 |
+
# Download the sample's WSM controls, captions, and negative prompt (about 4 MB) into SAMPLE_DIR.
|
| 628 |
+
scene = Path(snapshot_download(MODEL, local_dir=SAMPLE_DIR, allow_patterns=[
|
| 629 |
+
"assets/sample_data/daytime_scene/wsm/*.mp4",
|
| 630 |
+
f"assets/sample_data/daytime_scene/{CAPTION_FOLDER}/*.json",
|
| 631 |
+
"assets/sample_data/daytime_scene/captions/negative_prompt.txt",
|
| 632 |
+
])) / "assets/sample_data/daytime_scene"
|
| 633 |
+
|
| 634 |
+
def caption(camera):
|
| 635 |
+
data = json.loads((scene / CAPTION_FOLDER / f"{camera}.json").read_text())
|
| 636 |
+
return data["caption_structured"]["chunk_0_300"]["caption"]
|
| 637 |
+
|
| 638 |
+
# One negative caption, applied to every camera.
|
| 639 |
+
negative_prompt = (scene / "captions" / "negative_prompt.txt").read_text().strip()
|
| 640 |
+
|
| 641 |
+
# One view per camera: its caption and the server-visible path of its WSM control.
|
| 642 |
+
views = [
|
| 643 |
+
{"camera_key": camera, "prompt": caption(camera), "control_path": str(scene / "wsm" / f"{camera}.mp4")}
|
| 644 |
+
for camera in CAMERAS
|
| 645 |
+
]
|
| 646 |
+
|
| 647 |
+
form = {
|
| 648 |
+
"model": MODEL,
|
| 649 |
+
"prompt": views[0]["prompt"], # Required by the API; generation uses each view's prompt.
|
| 650 |
+
"size": "832x480",
|
| 651 |
+
"num_frames": str(NUM_FRAMES),
|
| 652 |
+
"fps": "30",
|
| 653 |
+
"num_inference_steps": "35",
|
| 654 |
+
"guidance_scale": "3",
|
| 655 |
+
"flow_shift": "10",
|
| 656 |
+
"seed": "0",
|
| 657 |
+
"extra_params": json.dumps({
|
| 658 |
+
"wsm": {},
|
| 659 |
+
"multiview": {"views": views},
|
| 660 |
+
"per_view_negative_prompt": negative_prompt,
|
| 661 |
+
"resolution": "480",
|
| 662 |
+
"aspect_ratio": "16,9",
|
| 663 |
+
}),
|
| 664 |
+
}
|
| 665 |
+
|
| 666 |
+
# Submit the job, poll it, and download the video. Nothing is uploaded: the form carries text fields only.
|
| 667 |
+
response = requests.post(f"{SERVER}/v1/videos", files=[(key, (None, value)) for key, value in form.items()], timeout=60)
|
| 668 |
+
response.raise_for_status()
|
| 669 |
+
job = response.json()
|
| 670 |
+
deadline = time.monotonic() + 3600
|
| 671 |
+
while job["status"] not in ("completed", "failed", "cancelled"):
|
| 672 |
+
if time.monotonic() > deadline:
|
| 673 |
+
raise TimeoutError(f"Job {job['id']} did not finish in time: {job}")
|
| 674 |
+
time.sleep(10)
|
| 675 |
+
job = requests.get(f"{SERVER}/v1/videos/{job['id']}", timeout=60).json()
|
| 676 |
+
if job["status"] != "completed":
|
| 677 |
+
raise RuntimeError(json.dumps(job, indent=2))
|
| 678 |
+
video = requests.get(f"{SERVER}/v1/videos/{job['id']}/content", timeout=600)
|
| 679 |
+
video.raise_for_status()
|
| 680 |
+
Path("transfer_auto.mp4").write_bytes(video.content)
|
| 681 |
+
```
|
| 682 |
+
|
| 683 |
+
The server trims each 300-frame control to `num_frames` and resizes it to 832 × 480. Split the camera-major output as in step 3 above.
|
| 684 |
+
|
| 685 |
## Ethical Considerations
|
| 686 |
|
| 687 |
NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications. Developers should work with their internal model team to ensure this model meets requirements for the relevant industry and use case and addresses unforeseen product misuse.
|