Image-Text-to-Text
Transformers
Safetensors
qwen2_5_vl
agent
computer-use
gui-grounding
vision-language
conversational
text-generation-inference
Instructions to use ServiceNow/GroundNext-7B-V0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ServiceNow/GroundNext-7B-V0 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="ServiceNow/GroundNext-7B-V0") 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("ServiceNow/GroundNext-7B-V0") model = AutoModelForImageTextToText.from_pretrained("ServiceNow/GroundNext-7B-V0") 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 ServiceNow/GroundNext-7B-V0 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ServiceNow/GroundNext-7B-V0" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ServiceNow/GroundNext-7B-V0", "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/ServiceNow/GroundNext-7B-V0
- SGLang
How to use ServiceNow/GroundNext-7B-V0 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 "ServiceNow/GroundNext-7B-V0" \ --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": "ServiceNow/GroundNext-7B-V0", "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 "ServiceNow/GroundNext-7B-V0" \ --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": "ServiceNow/GroundNext-7B-V0", "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 ServiceNow/GroundNext-7B-V0 with Docker Model Runner:
docker model run hf.co/ServiceNow/GroundNext-7B-V0
eun2ce commited on
fix: add factor=28 to smart_resize in prepare_image for Qwen VL models
Browse filesEnsure proper image resizing for Qwen VL models by passing factor=28 to smart_resize.
- groundcua.py +4 -2
groundcua.py
CHANGED
|
@@ -22,16 +22,18 @@ For each function call, return a json object with function name and arguments wi
|
|
| 22 |
# Default generation parameters
|
| 23 |
DEFAULT_TEMPERATURE = 0.0
|
| 24 |
DEFAULT_MAX_NEW_TOKENS = 64
|
|
|
|
| 25 |
MIN_PIXELS = 78_400
|
| 26 |
MAX_PIXELS = 6_000_000
|
| 27 |
|
| 28 |
|
| 29 |
-
def prepare_image(image, min_pixels=MIN_PIXELS, max_pixels=MAX_PIXELS):
|
| 30 |
"""
|
| 31 |
Resize image using smart_resize for optimal model performance.
|
| 32 |
|
| 33 |
Args:
|
| 34 |
image: PIL Image object
|
|
|
|
| 35 |
min_pixels: Minimum number of pixels (default: 78,400)
|
| 36 |
max_pixels: Maximum number of pixels (default: 6,000,000)
|
| 37 |
|
|
@@ -42,7 +44,7 @@ def prepare_image(image, min_pixels=MIN_PIXELS, max_pixels=MAX_PIXELS):
|
|
| 42 |
|
| 43 |
width, height = image.size
|
| 44 |
resized_height, resized_width = smart_resize(
|
| 45 |
-
height, width, min_pixels=min_pixels, max_pixels=max_pixels
|
| 46 |
)
|
| 47 |
resized_image = image.resize((resized_width, resized_height))
|
| 48 |
return resized_image, (resized_width, resized_height)
|
|
|
|
| 22 |
# Default generation parameters
|
| 23 |
DEFAULT_TEMPERATURE = 0.0
|
| 24 |
DEFAULT_MAX_NEW_TOKENS = 64
|
| 25 |
+
SMART_RESIZE_FACTOR = 28
|
| 26 |
MIN_PIXELS = 78_400
|
| 27 |
MAX_PIXELS = 6_000_000
|
| 28 |
|
| 29 |
|
| 30 |
+
def prepare_image(image, factor=SMART_RESIZE_FACTOR, min_pixels=MIN_PIXELS, max_pixels=MAX_PIXELS):
|
| 31 |
"""
|
| 32 |
Resize image using smart_resize for optimal model performance.
|
| 33 |
|
| 34 |
Args:
|
| 35 |
image: PIL Image object
|
| 36 |
+
factor: Resize factor for smart_resize (default: 28)
|
| 37 |
min_pixels: Minimum number of pixels (default: 78,400)
|
| 38 |
max_pixels: Maximum number of pixels (default: 6,000,000)
|
| 39 |
|
|
|
|
| 44 |
|
| 45 |
width, height = image.size
|
| 46 |
resized_height, resized_width = smart_resize(
|
| 47 |
+
height, width, factor=factor, min_pixels=min_pixels, max_pixels=max_pixels
|
| 48 |
)
|
| 49 |
resized_image = image.resize((resized_width, resized_height))
|
| 50 |
return resized_image, (resized_width, resized_height)
|