Image-Text-to-Text
Transformers
Safetensors
English
qwen3_vl
visual-grounding
multimodal
qwen3-vl
reinforcement-learning
grpo
conversational
Instructions to use nvidia/EGM-8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/EGM-8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="nvidia/EGM-8B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("nvidia/EGM-8B") model = AutoModelForImageTextToText.from_pretrained("nvidia/EGM-8B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use nvidia/EGM-8B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nvidia/EGM-8B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nvidia/EGM-8B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/nvidia/EGM-8B
- SGLang
How to use nvidia/EGM-8B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "nvidia/EGM-8B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nvidia/EGM-8B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "nvidia/EGM-8B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nvidia/EGM-8B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use nvidia/EGM-8B with Docker Model Runner:
docker model run hf.co/nvidia/EGM-8B
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -66,32 +66,47 @@ pip install -U huggingface_hub
|
|
| 66 |
huggingface-cli download nvidia/EGM-8B --local-dir ./models/EGM-8B
|
| 67 |
```
|
| 68 |
|
| 69 |
-
###
|
| 70 |
|
| 71 |
-
|
| 72 |
-
pip install sglang==0.5.5
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
export DATA_JSON="${BASE_DIR}/data/EGM_Datasets/metadata/eval/refcoco+_testA.jsonl"
|
| 77 |
-
export OUTPUT_DIR="${BASE_DIR}/result/"
|
| 78 |
-
export BASE_IMG_DIR="${BASE_DIR}"
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
| 82 |
```
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
```
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
```
|
| 96 |
|
| 97 |
## Model Architecture
|
|
|
|
| 66 |
huggingface-cli download nvidia/EGM-8B --local-dir ./models/EGM-8B
|
| 67 |
```
|
| 68 |
|
| 69 |
+
### Inference with SGLang
|
| 70 |
|
| 71 |
+
Launch the server:
|
|
|
|
| 72 |
|
| 73 |
+
```bash
|
| 74 |
+
pip install "sglang[all]>=0.5.5"
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
+
python -m sglang.launch_server \
|
| 77 |
+
--model-path nvidia/EGM-8B \
|
| 78 |
+
--chat-template=qwen3-vl \
|
| 79 |
+
--port 30000
|
| 80 |
```
|
| 81 |
|
| 82 |
+
Send a visual grounding request:
|
| 83 |
+
|
| 84 |
+
```python
|
| 85 |
+
import openai
|
| 86 |
+
import base64
|
| 87 |
+
|
| 88 |
+
client = openai.Client(base_url="http://127.0.0.1:30000/v1", api_key="EMPTY")
|
| 89 |
+
|
| 90 |
+
# Load a local image as base64
|
| 91 |
+
with open("example.jpg", "rb") as f:
|
| 92 |
+
image_base64 = base64.b64encode(f.read()).decode("utf-8")
|
| 93 |
+
|
| 94 |
+
response = client.chat.completions.create(
|
| 95 |
+
model="nvidia/EGM-8B",
|
| 96 |
+
messages=[
|
| 97 |
+
{
|
| 98 |
+
"role": "user",
|
| 99 |
+
"content": [
|
| 100 |
+
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{image_base64}"}},
|
| 101 |
+
{"type": "text", "text": "Please provide the bounding box coordinate of the region this sentence describes: the person on the left."},
|
| 102 |
+
],
|
| 103 |
+
}
|
| 104 |
+
],
|
| 105 |
+
temperature=0.6,
|
| 106 |
+
top_p=0.95,
|
| 107 |
+
max_tokens=8192,
|
| 108 |
+
)
|
| 109 |
+
print(response.choices[0].message.content)
|
| 110 |
```
|
| 111 |
|
| 112 |
## Model Architecture
|