Image-Text-to-Text
Transformers
Safetensors
nemotron_parse
feature-extraction
nvidia
VLM
OCR
conversational
custom_code
Instructions to use nvidia/NVIDIA-Nemotron-Parse-v1.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/NVIDIA-Nemotron-Parse-v1.1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="nvidia/NVIDIA-Nemotron-Parse-v1.1", trust_remote_code=True) 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 AutoModel model = AutoModel.from_pretrained("nvidia/NVIDIA-Nemotron-Parse-v1.1", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use nvidia/NVIDIA-Nemotron-Parse-v1.1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nvidia/NVIDIA-Nemotron-Parse-v1.1" # 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/NVIDIA-Nemotron-Parse-v1.1", "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/NVIDIA-Nemotron-Parse-v1.1
- SGLang
How to use nvidia/NVIDIA-Nemotron-Parse-v1.1 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/NVIDIA-Nemotron-Parse-v1.1" \ --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/NVIDIA-Nemotron-Parse-v1.1", "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/NVIDIA-Nemotron-Parse-v1.1" \ --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/NVIDIA-Nemotron-Parse-v1.1", "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/NVIDIA-Nemotron-Parse-v1.1 with Docker Model Runner:
docker model run hf.co/nvidia/NVIDIA-Nemotron-Parse-v1.1
Upload folder using huggingface_hub
Browse files- example.py +2 -12
- model.safetensors +2 -2
example.py
CHANGED
|
@@ -3,18 +3,8 @@ from PIL import Image, ImageDraw
|
|
| 3 |
from transformers import AutoModel, AutoProcessor, AutoTokenizer, AutoConfig, AutoImageProcessor, GenerationConfig
|
| 4 |
from postprocessing import extract_classes_bboxes, transform_bbox_to_original, postprocess_text
|
| 5 |
|
| 6 |
-
from hf_nemotron_parse_config import NemotronParseConfig
|
| 7 |
-
from hf_nemotron_parse_modeling import NemotronParseForConditionalGeneration
|
| 8 |
-
from hf_nemotron_parse_processor import NemotronParseProcessor, NemotronParseImageProcessor
|
| 9 |
-
|
| 10 |
-
AutoConfig.register("nemotron_parse", NemotronParseConfig)
|
| 11 |
-
AutoModel.register(NemotronParseConfig, NemotronParseForConditionalGeneration)
|
| 12 |
-
AutoProcessor.register("nemotron_parse", NemotronParseProcessor)
|
| 13 |
-
AutoImageProcessor.register("nemotron_parse", NemotronParseImageProcessor)
|
| 14 |
-
|
| 15 |
-
|
| 16 |
# Load model and processor
|
| 17 |
-
model_path = "
|
| 18 |
device = "cuda:0"
|
| 19 |
|
| 20 |
model = AutoModel.from_pretrained(
|
|
@@ -26,7 +16,7 @@ tokenizer = AutoTokenizer.from_pretrained(model_path)
|
|
| 26 |
processor = AutoProcessor.from_pretrained(model_path, trust_remote_code=True)
|
| 27 |
|
| 28 |
# Load image
|
| 29 |
-
image = Image.open("
|
| 30 |
task_prompt = "</s><s><predict_bbox><predict_classes><output_markdown>"
|
| 31 |
|
| 32 |
# Process image
|
|
|
|
| 3 |
from transformers import AutoModel, AutoProcessor, AutoTokenizer, AutoConfig, AutoImageProcessor, GenerationConfig
|
| 4 |
from postprocessing import extract_classes_bboxes, transform_bbox_to_original, postprocess_text
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# Load model and processor
|
| 7 |
+
model_path = "nvidia/NVIDIA-Nemotron-Parse-v1.1" # Or use a local path
|
| 8 |
device = "cuda:0"
|
| 9 |
|
| 10 |
model = AutoModel.from_pretrained(
|
|
|
|
| 16 |
processor = AutoProcessor.from_pretrained(model_path, trust_remote_code=True)
|
| 17 |
|
| 18 |
# Load image
|
| 19 |
+
image = Image.open("path/to/your/image.jpg")
|
| 20 |
task_prompt = "</s><s><predict_bbox><predict_classes><output_markdown>"
|
| 21 |
|
| 22 |
# Process image
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7469048899485bd828486142c8ac8d4ddd3f3411e9cf6bcc686a73098d403477
|
| 3 |
+
size 3827116472
|