project-sloth/captcha-images
Viewer • Updated • 10k • 286 • 23
How to use ayoubkirouane/moondream2-image-captcha with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-text-to-text", model="ayoubkirouane/moondream2-image-captcha", trust_remote_code=True) # Load model directly
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("ayoubkirouane/moondream2-image-captcha", trust_remote_code=True, dtype="auto")How to use ayoubkirouane/moondream2-image-captcha with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "ayoubkirouane/moondream2-image-captcha"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "ayoubkirouane/moondream2-image-captcha",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/ayoubkirouane/moondream2-image-captcha
How to use ayoubkirouane/moondream2-image-captcha with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "ayoubkirouane/moondream2-image-captcha" \
--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": "ayoubkirouane/moondream2-image-captcha",
"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 "ayoubkirouane/moondream2-image-captcha" \
--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": "ayoubkirouane/moondream2-image-captcha",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use ayoubkirouane/moondream2-image-captcha with Docker Model Runner:
docker model run hf.co/ayoubkirouane/moondream2-image-captcha
from transformers import AutoModelForCausalLM, AutoTokenizer
from PIL import Image
model_id = "ayoubkirouane/moondream2-image-captcha"
model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(model_id , trust_remote_code=True)
image = Image.open('/content/test.png')
enc_image = model.encode_image(image)
print(model.answer_question(enc_image, "What does the text say?", tokenizer))