Image-Text-to-Text
Transformers
Safetensors
nemotron_parse_tc
feature-extraction
nvidia
VLM
OCR
conversational
custom_code
Instructions to use nvidia/NVIDIA-Nemotron-Parse-v1.1-TC 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-TC 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-TC", 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-TC", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use nvidia/NVIDIA-Nemotron-Parse-v1.1-TC 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-TC" # 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-TC", "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-TC
- SGLang
How to use nvidia/NVIDIA-Nemotron-Parse-v1.1-TC 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-TC" \ --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-TC", "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-TC" \ --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-TC", "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-TC with Docker Model Runner:
docker model run hf.co/nvidia/NVIDIA-Nemotron-Parse-v1.1-TC
Download example.py from nvidia/NVIDIA-Nemotron-Parse-v1.1-TC: direct link, hf CLI and curl.
- Browser
- Download file 2.04 kB
-
https://huggingface.co/nvidia/NVIDIA-Nemotron-Parse-v1.1-TC/resolve/bcb28c72b6e0c2e78be74505597f9037bb1720c8/example.py
- Command line
-
hf download hf://nvidia/NVIDIA-Nemotron-Parse-v1.1-TC@bcb28c72b6e0c2e78be74505597f9037bb1720c8/example.py
-
curl -L -o example.py https://huggingface.co/nvidia/NVIDIA-Nemotron-Parse-v1.1-TC/resolve/bcb28c72b6e0c2e78be74505597f9037bb1720c8/example.py
2.04 kB
| import torch | |
| from PIL import Image, ImageDraw | |
| from transformers import AutoModel, AutoProcessor, AutoTokenizer, AutoConfig, AutoImageProcessor, GenerationConfig | |
| from postprocessing import extract_classes_bboxes, transform_bbox_to_original, postprocess_text | |
| # Load model and processor | |
| model_path = "nvidia/NVIDIA-Nemotron-Parse-v1.1-Light" # Or use a local path | |
| device = "cuda:0" | |
| model = AutoModel.from_pretrained( | |
| model_path, | |
| trust_remote_code=True, | |
| torch_dtype=torch.bfloat16 | |
| ).to(device).eval() | |
| tokenizer = AutoTokenizer.from_pretrained(model_path) | |
| processor = AutoProcessor.from_pretrained(model_path, trust_remote_code=True) | |
| # Load image | |
| image = Image.open("path/to/your/image.jpg") | |
| task_prompt = "</s><s><predict_bbox><predict_classes><output_markdown>" | |
| # Process image | |
| inputs = processor(images=[image], text=task_prompt, return_tensors="pt").to(device) | |
| prompt_ids = processor.tokenizer.encode(task_prompt, return_tensors="pt", add_special_tokens=False).cuda() | |
| generation_config = GenerationConfig.from_pretrained(model_path, trust_remote_code=True) | |
| # Generate text | |
| outputs = model.generate(**inputs, generation_config=generation_config) | |
| # Decode the generated text | |
| generated_text = processor.batch_decode(outputs, skip_special_tokens=True)[0] | |
| classes, bboxes, texts = extract_classes_bboxes(generated_text) | |
| bboxes = [transform_bbox_to_original(bbox, image.width, image.height) for bbox in bboxes] | |
| # Specify output formats for postprocessing | |
| table_format = 'latex' # latex | HTML | markdown | |
| text_format = 'markdown' # markdown | plain | |
| blank_text_in_figures = False # remove text inside 'Picture' class | |
| texts = [postprocess_text(text, cls = cls, table_format=table_format, text_format=text_format, blank_text_in_figures=blank_text_in_figures) for text, cls in zip(texts, classes)] | |
| for cl, bb, txt in zip(classes, bboxes, texts): | |
| print(cl, ': ', txt) | |
| # OPTIONAL - Draw bounding boxes | |
| draw = ImageDraw.Draw(image) | |
| for bbox in bboxes: | |
| draw.rectangle((bbox[0], bbox[1], bbox[2], bbox[3]), outline="red") | |