Instructions to use jadechoghari/Ferret-UI-Llama8b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jadechoghari/Ferret-UI-Llama8b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="jadechoghari/Ferret-UI-Llama8b", 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 AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("jadechoghari/Ferret-UI-Llama8b", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use jadechoghari/Ferret-UI-Llama8b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "jadechoghari/Ferret-UI-Llama8b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jadechoghari/Ferret-UI-Llama8b", "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/jadechoghari/Ferret-UI-Llama8b
- SGLang
How to use jadechoghari/Ferret-UI-Llama8b 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 "jadechoghari/Ferret-UI-Llama8b" \ --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": "jadechoghari/Ferret-UI-Llama8b", "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 "jadechoghari/Ferret-UI-Llama8b" \ --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": "jadechoghari/Ferret-UI-Llama8b", "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 jadechoghari/Ferret-UI-Llama8b with Docker Model Runner:
docker model run hf.co/jadechoghari/Ferret-UI-Llama8b
Create constants.py
Browse files- constants.py +32 -0
constants.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
CONTROLLER_HEART_BEAT_EXPIRATION = 30
|
| 2 |
+
WORKER_HEART_BEAT_INTERVAL = 15
|
| 3 |
+
|
| 4 |
+
LOGDIR = "."
|
| 5 |
+
|
| 6 |
+
# Model Constants
|
| 7 |
+
IGNORE_INDEX = -100
|
| 8 |
+
IMAGE_TOKEN_INDEX = -200
|
| 9 |
+
DEFAULT_IMAGE_TOKEN = "<image>"
|
| 10 |
+
DEFAULT_IMAGE_PATCH_TOKEN = "<im_patch>"
|
| 11 |
+
DEFAULT_IM_START_TOKEN = "<im_start>"
|
| 12 |
+
DEFAULT_IM_END_TOKEN = "<im_end>"
|
| 13 |
+
IMAGE_PLACEHOLDER = "<image-placeholder>"
|
| 14 |
+
|
| 15 |
+
# Added by Ferret
|
| 16 |
+
DEFAULT_REGION_FEA_TOKEN = "<region_fea>"
|
| 17 |
+
VOCAB_IMAGE_W = 1000
|
| 18 |
+
VOCAB_IMAGE_H = 1000
|
| 19 |
+
|
| 20 |
+
# GROUNDING PROMPTS
|
| 21 |
+
GROUNDING_TEMPLATES = [
|
| 22 |
+
'\nProvide the bounding boxes of the mentioned objects.',
|
| 23 |
+
'\nInclude the coordinates for each mentioned object.',
|
| 24 |
+
'\nLocate the objects with their coordinates.',
|
| 25 |
+
'\nAnswer in [x1, y1, x2, y2] format.',
|
| 26 |
+
'\nMention the objects and their locations using the format [x1, y1, x2, y2].',
|
| 27 |
+
'\nDraw boxes around the mentioned objects.',
|
| 28 |
+
'\nUse boxes to show where each thing is.',
|
| 29 |
+
'\nTell me where the objects are with coordinates.',
|
| 30 |
+
'\nList where each object is with boxes.',
|
| 31 |
+
'\nShow me the regions with boxes.'
|
| 32 |
+
]
|