Skip to content

Commit f0e66ef

Browse files
Add inference example project.
1 parent 8d38bf6 commit f0e66ef

File tree

6 files changed

+1064
-4188
lines changed

6 files changed

+1064
-4188
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ Cosmos-Reason1 is included in [`transformers>=4.51.3`](https://huggingface.co/do
5959

6060
We provide example inference scripts:
6161

62-
* [Minimal example](scripts/inference_sample.py)
62+
* [Minimal example](examples/inference/inference.py)
6363

6464
```shell
65-
./scripts/inference_sample.py
65+
uv run --project examples/project examples/project/inference.py
6666
```
6767

6868
* [Full example](scripts/inference.py)

examples/inference/.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10
Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env -S uv run --script
21
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
32
# SPDX-License-Identifier: Apache-2.0
43
#
@@ -14,45 +13,14 @@
1413
# See the License for the specific language governing permissions and
1514
# limitations under the License.
1615

17-
# https://docs.astral.sh/uv/guides/scripts/#using-a-shebang-to-create-an-executable-file
18-
# /// script
19-
# requires-python = ">=3.10"
20-
# dependencies = [
21-
# "accelerate>=1.10.1",
22-
# "qwen-vl-utils>=0.0.11",
23-
# "torchcodec>=0.6.0",
24-
# "torch>=2.7.1",
25-
# "transformers>=4.51.3",
26-
# "vllm>=0.10.1.1",
27-
# ]
28-
# [tool.uv.sources]
29-
# torch = [
30-
# { index = "pytorch-cu128"},
31-
# ]
32-
# torchvision = [
33-
# { index = "pytorch-cu128"},
34-
# ]
35-
# [[tool.uv.index]]
36-
# name = "pytorch-cu128"
37-
# url = "https://download.pytorch.org/whl/cu128"
38-
# explicit = true
39-
# ///
40-
41-
"""Minimal example of inference with Cosmos-Reason1.
42-
43-
Example:
44-
45-
```shell
46-
./scripts/inference_sample.py
47-
```
48-
"""
16+
"""Minimal example of inference with Cosmos-Reason1."""
4917

5018
from pathlib import Path
5119

5220
import qwen_vl_utils
5321
import transformers
5422

55-
ROOT = Path(__file__).parents[1]
23+
ROOT = Path(__file__).parents[2]
5624
SEPARATOR = "-" * 20
5725

5826

@@ -114,4 +82,4 @@ def main():
11482

11583

11684
if __name__ == "__main__":
117-
main()
85+
main()

examples/inference/pyproject.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[project]
2+
name = "cosmos-reason1-inference"
3+
version = "0.1.0"
4+
requires-python = ">=3.10"
5+
dependencies = [
6+
"accelerate>=1.10.1",
7+
"qwen-vl-utils>=0.0.11",
8+
"torch>=2.7.1",
9+
"torchcodec>=0.6.0",
10+
"transformers>=4.51.3",
11+
]
12+
[tool.uv.sources]
13+
torch = [
14+
{ index = "pytorch-cu128"},
15+
]
16+
torchvision = [
17+
{ index = "pytorch-cu128"},
18+
]
19+
20+
[[tool.uv.index]]
21+
name = "pytorch-cu128"
22+
url = "https://download.pytorch.org/whl/cu128"
23+
explicit = true

0 commit comments

Comments
 (0)