Image-Text-to-Text
Transformers
Safetensors
English
vision-encoder-decoder
text-generation
text-to-text
image-text-to-image-text
conversational
Instructions to use LeroyDyer/SpydazWeb_VisonEncoderDecoder_Project with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use LeroyDyer/SpydazWeb_VisonEncoderDecoder_Project with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="LeroyDyer/SpydazWeb_VisonEncoderDecoder_Project") 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 AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("LeroyDyer/SpydazWeb_VisonEncoderDecoder_Project") model = AutoModelForCausalLM.from_pretrained("LeroyDyer/SpydazWeb_VisonEncoderDecoder_Project") 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 = tokenizer.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(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use LeroyDyer/SpydazWeb_VisonEncoderDecoder_Project with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "LeroyDyer/SpydazWeb_VisonEncoderDecoder_Project" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "LeroyDyer/SpydazWeb_VisonEncoderDecoder_Project", "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/LeroyDyer/SpydazWeb_VisonEncoderDecoder_Project
- SGLang
How to use LeroyDyer/SpydazWeb_VisonEncoderDecoder_Project 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 "LeroyDyer/SpydazWeb_VisonEncoderDecoder_Project" \ --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": "LeroyDyer/SpydazWeb_VisonEncoderDecoder_Project", "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 "LeroyDyer/SpydazWeb_VisonEncoderDecoder_Project" \ --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": "LeroyDyer/SpydazWeb_VisonEncoderDecoder_Project", "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 LeroyDyer/SpydazWeb_VisonEncoderDecoder_Project with Docker Model Runner:
docker model run hf.co/LeroyDyer/SpydazWeb_VisonEncoderDecoder_Project
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
-
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
# Model Card for Model ID
|
|
@@ -211,7 +213,35 @@ Carbon emissions can be estimated using the [Machine Learning Impact calculator]
|
|
| 211 |
|
| 212 |
### Model Architecture and Objective
|
| 213 |
|
| 214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
|
| 216 |
### Compute Infrastructure
|
| 217 |
|
|
@@ -253,6 +283,4 @@ Carbon emissions can be estimated using the [Machine Learning Impact calculator]
|
|
| 253 |
|
| 254 |
## Model Card Contact
|
| 255 |
|
| 256 |
-
[More Information Needed]
|
| 257 |
-
|
| 258 |
-
|
|
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
language:
|
| 5 |
+
- en
|
| 6 |
---
|
| 7 |
|
| 8 |
# Model Card for Model ID
|
|
|
|
| 213 |
|
| 214 |
### Model Architecture and Objective
|
| 215 |
|
| 216 |
+
``` python
|
| 217 |
+
|
| 218 |
+
from transformers import MistralConfig, ViTConfig, VisionEncoderDecoderConfig, VisionEncoderDecoderModel
|
| 219 |
+
|
| 220 |
+
# Initializing a ViT & Mistral style configuration
|
| 221 |
+
config_encoder = ViTConfig()
|
| 222 |
+
config_decoder = MistralConfig()
|
| 223 |
+
|
| 224 |
+
config = VisionEncoderDecoderConfig.from_encoder_decoder_configs(config_encoder, config_decoder)
|
| 225 |
+
|
| 226 |
+
# Initializing a ViTBert model (with random weights) from a ViT & Mistral style configurations
|
| 227 |
+
model = VisionEncoderDecoderModel(config=config)
|
| 228 |
+
|
| 229 |
+
# Accessing the model configuration
|
| 230 |
+
config_encoder = model.config.encoder
|
| 231 |
+
config_decoder = model.config.decoder
|
| 232 |
+
# set decoder config to causal lm
|
| 233 |
+
config_decoder.is_decoder = True
|
| 234 |
+
config_decoder.add_cross_attention = True
|
| 235 |
+
|
| 236 |
+
# Saving the model, including its configuration
|
| 237 |
+
model.save_pretrained("my-model")
|
| 238 |
+
|
| 239 |
+
# loading model and config from pretrained folder
|
| 240 |
+
encoder_decoder_config = VisionEncoderDecoderConfig.from_pretrained("my-model")
|
| 241 |
+
model = VisionEncoderDecoderModel.from_pretrained("my-model", config=encoder_decoder_config)
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
```
|
| 245 |
|
| 246 |
### Compute Infrastructure
|
| 247 |
|
|
|
|
| 283 |
|
| 284 |
## Model Card Contact
|
| 285 |
|
| 286 |
+
[More Information Needed]
|
|
|
|
|
|