unsloth/RLAIF-V-Dataset
Viewer • Updated • 2.49k • 40 • 7
How to use saishshinde15/VisionAI_Pro with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-text-to-text", model="saishshinde15/VisionAI_Pro")
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("saishshinde15/VisionAI_Pro")
model = AutoModelForImageTextToText.from_pretrained("saishshinde15/VisionAI_Pro")
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]:]))How to use saishshinde15/VisionAI_Pro with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "saishshinde15/VisionAI_Pro"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "saishshinde15/VisionAI_Pro",
"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 run hf.co/saishshinde15/VisionAI_Pro
How to use saishshinde15/VisionAI_Pro with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "saishshinde15/VisionAI_Pro" \
--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": "saishshinde15/VisionAI_Pro",
"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 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 "saishshinde15/VisionAI_Pro" \
--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": "saishshinde15/VisionAI_Pro",
"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"
}
}
]
}
]
}'How to use saishshinde15/VisionAI_Pro with Docker Model Runner:
docker model run hf.co/saishshinde15/VisionAI_Pro
from unsloth import FastVisionModel
from PIL import Image
import requests
from transformers import TextStreamer
# Load the model and tokenizer
model, tokenizer = FastVisionModel.from_pretrained(
model_name="saishshinde15/VisionAI", # YOUR MODEL YOU USED FOR TRAINING
load_in_4bit=False # Set to False for 16bit LoRA
)
# Enable the model for inference
FastVisionModel.for_inference(model)
# Load the image from URL
url = 'your image url'
image = Image.open(requests.get(url, stream=True).raw)
# Define the instruction and user query
instruction = (
"You are an expert in answering questions related to the image provided: "
"Answer to the questions given by the user accurately by referring to the image."
)
query = "What is this image about?"
# Create the chat message structure
messages = [
{"role": "user", "content": [
{"type": "image"},
{"type": "text", "text": instruction},
{"type": "text", "text": query}
]}
]
# Generate input text using the tokenizer's chat template
input_text = tokenizer.apply_chat_template(messages, add_generation_prompt=True)
# Tokenize the inputs
inputs = tokenizer(
image,
input_text,
add_special_tokens=False,
return_tensors="pt",
).to("cuda")
# Initialize the text streamer
text_streamer = TextStreamer(tokenizer, skip_prompt=True)
# Generate the response
_ = model.generate(
**inputs,
streamer=text_streamer,
max_new_tokens=128,
use_cache=True,
temperature=1.5,
min_p=0.1
)
Base model
meta-llama/Llama-3.2-11B-Vision-Instruct