Instructions to use nvidia/Cosmos3-Edge with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Cosmos
How to use nvidia/Cosmos3-Edge 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
Usage: switch reasnor examples to vLLM
#48
by xuanli1 - opened
README.md
CHANGED
|
@@ -622,9 +622,31 @@ The predicted per-frame relative poses are integrated into an absolute camera tr
|
|
| 622 |
|
| 623 |
<img width="1280" src="assets/edge_action_id_av_1_output.png">
|
| 624 |
|
| 625 |
-
###
|
| 626 |
|
| 627 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 628 |
|
| 629 |
Image input:
|
| 630 |
|
|
@@ -636,29 +658,47 @@ User prompt:
|
|
| 636 |
The task is to put flower into the red bottle. Generate a plan consisting of subtasks for accomplish the task.
|
| 637 |
```
|
| 638 |
|
| 639 |
-
```
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
"prompt": "The task is to put flower into the red bottle. Generate a plan consisting of subtasks for accomplish the task.",
|
| 644 |
-
"vision_path": "https://huggingface.co/nvidia/Cosmos3-Edge/resolve/main/assets/example_reasoning_input.png"
|
| 645 |
-
}
|
| 646 |
-
JSON
|
| 647 |
|
| 648 |
-
|
| 649 |
-
--parallelism-preset=latency \
|
| 650 |
-
-i reasoner_edge.json \
|
| 651 |
-
-o outputs/reasoner_edge \
|
| 652 |
-
--checkpoint-path Cosmos3-Edge \
|
| 653 |
-
--seed 0
|
| 654 |
-
```
|
| 655 |
|
| 656 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 657 |
|
| 658 |
Example output:
|
| 659 |
|
| 660 |
```text
|
| 661 |
-
<think>
|
| 662 |
Got it, let's try to figure out how to put the flower into the red bottle. First, I need to identify the objects: the flower is the green one with the red center, and the red bottle is the red container. So the steps would involve moving the flower to the red bottle.
|
| 663 |
|
| 664 |
First, the robot arm needs to locate the flower. Then, grasp the flower. After grasping, lift it, then move it towards the red bottle. Then, position the flower over the red bottle's opening, and finally release it into the bottle. Wait, but maybe I need to check if the red bottle has an opening that can accept the flower. Assuming the red bottle is a container with an opening, so the steps would be: move to flower, grasp, lift, move to red bottle, position over opening, release. Let me make sure each step is clear.
|
|
@@ -676,9 +716,11 @@ To accomplish the task of putting the flower into the red bottle, the plan shoul
|
|
| 676 |
Each step ensures the flower is picked up, transported, and placed into the red bottle in a controlled manner.
|
| 677 |
```
|
| 678 |
|
| 679 |
-
Thinking is enabled by default.
|
| 680 |
|
| 681 |
-
|
|
|
|
|
|
|
| 682 |
|
| 683 |
## Limitations
|
| 684 |
|
|
|
|
| 622 |
|
| 623 |
<img width="1280" src="assets/edge_action_id_av_1_output.png">
|
| 624 |
|
| 625 |
+
### vLLM
|
| 626 |
|
| 627 |
+
#### Container
|
| 628 |
+
|
| 629 |
+
```bash
|
| 630 |
+
docker pull vllm/vllm-openai:cosmos3
|
| 631 |
+
```
|
| 632 |
+
|
| 633 |
+
#### General Invocation
|
| 634 |
+
|
| 635 |
+
You can use the `vllm` package to deploy the Cosmos3-Edge reasoner as an OpenAI-compatible API endpoint. The recommended vLLM serving configuration for `nvidia/Cosmos3-Edge` on a single GPU is:
|
| 636 |
+
|
| 637 |
+
```bash
|
| 638 |
+
vllm serve nvidia/Cosmos3-Edge \
|
| 639 |
+
--host 0.0.0.0 \
|
| 640 |
+
--port 8000 \
|
| 641 |
+
--max-model-len 131072 \
|
| 642 |
+
--allowed-local-media-path / \
|
| 643 |
+
--mm-processor-kwargs '{"do_resize": true, "min_pixels": 4096, "max_pixels": 16777216}' \
|
| 644 |
+
--media-io-kwargs '{"video": {"fps": -1, "num_frames": 256}}'
|
| 645 |
+
```
|
| 646 |
+
|
| 647 |
+
#### Examples
|
| 648 |
+
|
| 649 |
+
##### Reasoning
|
| 650 |
|
| 651 |
Image input:
|
| 652 |
|
|
|
|
| 658 |
The task is to put flower into the red bottle. Generate a plan consisting of subtasks for accomplish the task.
|
| 659 |
```
|
| 660 |
|
| 661 |
+
```python
|
| 662 |
+
import base64
|
| 663 |
+
import json
|
| 664 |
+
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
|
|
|
| 665 |
|
| 666 |
+
import openai
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 667 |
|
| 668 |
+
# 1. Read the image reasoning prompt
|
| 669 |
+
example = json.load(open("assets/example_reasoning_prompt.json"))
|
| 670 |
+
image_path = Path("assets/example_reasoning_input.png").resolve()
|
| 671 |
+
image_url = (
|
| 672 |
+
"data:image/png;base64," + base64.b64encode(image_path.read_bytes()).decode()
|
| 673 |
+
)
|
| 674 |
+
|
| 675 |
+
# 2. Query the OpenAI-compatible vLLM server
|
| 676 |
+
client = openai.OpenAI(
|
| 677 |
+
api_key="EMPTY",
|
| 678 |
+
base_url="http://localhost:8000/v1",
|
| 679 |
+
)
|
| 680 |
+
|
| 681 |
+
response = client.chat.completions.create(
|
| 682 |
+
model=client.models.list().data[0].id,
|
| 683 |
+
messages=[
|
| 684 |
+
{
|
| 685 |
+
"role": "user",
|
| 686 |
+
"content": [
|
| 687 |
+
{"type": "image_url", "image_url": {"url": image_url}},
|
| 688 |
+
{"type": "text", "text": example["prompt"]},
|
| 689 |
+
],
|
| 690 |
+
},
|
| 691 |
+
],
|
| 692 |
+
max_tokens=example["max_tokens"],
|
| 693 |
+
)
|
| 694 |
+
|
| 695 |
+
# 3. Print the default response (thinking is enabled)
|
| 696 |
+
print(response.choices[0].message.content)
|
| 697 |
+
```
|
| 698 |
|
| 699 |
Example output:
|
| 700 |
|
| 701 |
```text
|
|
|
|
| 702 |
Got it, let's try to figure out how to put the flower into the red bottle. First, I need to identify the objects: the flower is the green one with the red center, and the red bottle is the red container. So the steps would involve moving the flower to the red bottle.
|
| 703 |
|
| 704 |
First, the robot arm needs to locate the flower. Then, grasp the flower. After grasping, lift it, then move it towards the red bottle. Then, position the flower over the red bottle's opening, and finally release it into the bottle. Wait, but maybe I need to check if the red bottle has an opening that can accept the flower. Assuming the red bottle is a container with an opening, so the steps would be: move to flower, grasp, lift, move to red bottle, position over opening, release. Let me make sure each step is clear.
|
|
|
|
| 716 |
Each step ensures the flower is picked up, transported, and placed into the red bottle in a controlled manner.
|
| 717 |
```
|
| 718 |
|
| 719 |
+
Thinking is enabled by default. To disable it, add the following argument to the `client.chat.completions.create(...)` call:
|
| 720 |
|
| 721 |
+
```python
|
| 722 |
+
extra_body={"chat_template_kwargs": {"enable_thinking": False}}
|
| 723 |
+
```
|
| 724 |
|
| 725 |
## Limitations
|
| 726 |
|