Instructions to use team-indain-image-caption/hindi-image-captioning with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use team-indain-image-caption/hindi-image-captioning with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="team-indain-image-caption/hindi-image-captioning")# Load model directly from transformers import AutoTokenizer, AutoModelForImageTextToText tokenizer = AutoTokenizer.from_pretrained("team-indain-image-caption/hindi-image-captioning") model = AutoModelForImageTextToText.from_pretrained("team-indain-image-caption/hindi-image-captioning") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use team-indain-image-caption/hindi-image-captioning with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "team-indain-image-caption/hindi-image-captioning" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "team-indain-image-caption/hindi-image-captioning", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/team-indain-image-caption/hindi-image-captioning
- SGLang
How to use team-indain-image-caption/hindi-image-captioning 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 "team-indain-image-caption/hindi-image-captioning" \ --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": "team-indain-image-caption/hindi-image-captioning", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "team-indain-image-caption/hindi-image-captioning" \ --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": "team-indain-image-caption/hindi-image-captioning", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use team-indain-image-caption/hindi-image-captioning with Docker Model Runner:
docker model run hf.co/team-indain-image-caption/hindi-image-captioning
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Hindi Image Captioning Model
This is an encoder-decoder image captioning model made with VIT encoder and GPT2-Hindi as a decoder. This is a first attempt at using ViT + GPT2-Hindi for image captioning task. We used the Flickr8k Hindi Dataset available on kaggle to train the model.
This model was trained using HuggingFace course community week, organized by Huggingface.
How to use
Here is how to use this model to caption an image of the Flickr8k dataset:
import torch
import requests
from PIL import Image
from transformers import ViTFeatureExtractor, AutoTokenizer, \
VisionEncoderDecoderModel
if torch.cuda.is_available():
device = 'cuda'
else:
device = 'cpu'
url = 'https://shorturl.at/fvxEQ'
image = Image.open(requests.get(url, stream=True).raw)
encoder_checkpoint = 'google/vit-base-patch16-224'
decoder_checkpoint = 'surajp/gpt2-hindi'
model_checkpoint = 'team-indain-image-caption/hindi-image-captioning'
feature_extractor = ViTFeatureExtractor.from_pretrained(encoder_checkpoint)
tokenizer = AutoTokenizer.from_pretrained(decoder_checkpoint)
model = VisionEncoderDecoderModel.from_pretrained(model_checkpoint).to(device)
#Inference
sample = feature_extractor(image, return_tensors="pt").pixel_values.to(device)
clean_text = lambda x: x.replace('<|endoftext|>','').split('\n')[0]
caption_ids = model.generate(sample, max_length = 50)[0]
caption_text = clean_text(tokenizer.decode(caption_ids))
print(caption_text)
Training data
We used the Flickr8k Hindi Dataset, which is the translated version of the original Flickr8k Dataset, available on Kaggle to train the model.
Training procedure
This model was trained during HuggingFace course community week, organized by Huggingface. The training was done on Kaggle GPU.
Training Parameters
- epochs = 8,
- batch_size = 8,
- Mixed Precision Enabled
Team Members
- Downloads last month
- 8