tomg-group-umd/pixelprose
Viewer • Updated • 15.6M • 975 • 179
How to use gokaygokay/PaliGemma-PixelProse with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-text-to-text", model="gokaygokay/PaliGemma-PixelProse") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoProcessor, AutoModelForMultimodalLM
processor = AutoProcessor.from_pretrained("gokaygokay/PaliGemma-PixelProse")
model = AutoModelForMultimodalLM.from_pretrained("gokaygokay/PaliGemma-PixelProse", device_map="auto")How to use gokaygokay/PaliGemma-PixelProse with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "gokaygokay/PaliGemma-PixelProse"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "gokaygokay/PaliGemma-PixelProse",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/gokaygokay/PaliGemma-PixelProse
How to use gokaygokay/PaliGemma-PixelProse with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "gokaygokay/PaliGemma-PixelProse" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "gokaygokay/PaliGemma-PixelProse",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "gokaygokay/PaliGemma-PixelProse" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "gokaygokay/PaliGemma-PixelProse",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use gokaygokay/PaliGemma-PixelProse with Docker Model Runner:
docker model run hf.co/gokaygokay/PaliGemma-PixelProse
Fine-tuned version of PaliGemma 224x224 on 7500 random examples from PixelProse dataset.
pip install git+https://github.com/huggingface/transformers
from transformers import AutoProcessor, PaliGemmaForConditionalGeneration
from PIL import Image
import requests
import torch
model_id = "gokaygokay/PaliGemma-PixelProse"
url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
image = Image.open(requests.get(url, stream=True).raw)
model = PaliGemmaForConditionalGeneration.from_pretrained(model_id).to('cuda').eval()
processor = AutoProcessor.from_pretrained(model_id)
## prefix
prompt = "caption en"
model_inputs = processor(text=prompt, images=image, return_tensors="pt").to('cuda')
input_len = model_inputs["input_ids"].shape[-1]
with torch.inference_mode():
generation = model.generate(**model_inputs, repetition_penalty=1.05, max_new_tokens=512, do_sample=False)
generation = generation[0][input_len:]
decoded = processor.decode(generation, skip_special_tokens=True)
print(decoded)
This model release is maintained by Gökay Aydoğan. If you reference this repository in academic work, please cite it as follows and also cite the upstream models, datasets, or projects it builds upon.
@software{aydogan2024paligemma_pixelprose,
author = {Aydoğan, Gökay},
title = {{PaliGemma-PixelProse}},
year = {2024},
publisher = {Hugging Face},
url = {https://huggingface.co/gokaygokay/PaliGemma-PixelProse},
note = {Model repository; cite the base model and upstream datasets as required.}
}