Image-to-Text
Transformers
ONNX
Transformers.js
PyTorch
English
vision-encoder-decoder
image-text-to-text
image-captioning
vision-language
onnxruntime
vit
gpt2
Run this model with HF Jobs
Run anmol-unitmole/image-caption-generation-vision-encoder-decoder-model on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/anmol-unitmole/image-caption-generation-vision-encoder-decoder-model. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/anmol-unitmole/image-caption-generation-vision-encoder-decoder-model on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use anmol-unitmole/image-caption-generation-vision-encoder-decoder-model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use anmol-unitmole/image-caption-generation-vision-encoder-decoder-model with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "image-to-text" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("image-to-text", model="anmol-unitmole/image-caption-generation-vision-encoder-decoder-model")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("anmol-unitmole/image-caption-generation-vision-encoder-decoder-model") model = AutoModelForMultimodalLM.from_pretrained("anmol-unitmole/image-caption-generation-vision-encoder-decoder-model", device_map="auto") - Transformers.js
How to use anmol-unitmole/image-caption-generation-vision-encoder-decoder-model with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('image-to-text', 'anmol-unitmole/image-caption-generation-vision-encoder-decoder-model'); - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse filesFiles changed (13)
- README.mdAdded+88
- config.jsonAdded+77
- generation_config.jsonAdded+9
- merges.txtAdded
- onnx/decoder_model_merged_quantized.onnxAdded+3
- onnx/decoder_model_quantized.onnxAdded+3
- onnx/decoder_with_past_model_quantized.onnxAdded+3
- onnx/encoder_model_quantized.onnxAdded+3
- preprocessor_config.jsonAdded+23
- special_tokens_map.jsonAdded+30
- tokenizer.jsonAdded
- tokenizer_config.jsonAdded+28
- vocab.jsonAdded
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788# Model Card · RTX 5090 Vision Encoder-Decoder Image Captioning
## System
`02-image-caption-generation-vision-encoder-decoder`
## Status
**Execution-ready, not yet result-complete.** This repository contains the complete training, evaluation, optimization, and deployment workflow. Fine-tuned weights, new metrics, ONNX parity results, and the final public URL must be generated on the target RTX 5090 system.
## Architecture
- Python checkpoint: `nlpconnect/vit-gpt2-image-captioning`- Vision encoder: ViT- Text decoder: GPT-2 with encoder cross-attention- Framework: PyTorch and Hugging Face `VisionEncoderDecoderModel`- Browser baseline: `Xenova/vit-gpt2-image-captioning`- Browser runtime: Transformers.js and ONNX Runtime Web
## Training method
1. Freeze the vision encoder and adapt the decoder/cross-modal path.2. Unfreeze the top six vision blocks with differential learning rates.3. Conservatively fine-tune the full architecture.4. Select checkpoints using generated-caption validation metrics, with validation-loss fallback.
Implemented controls include BF16/FP16 handling, TF32, fused AdamW fallback, gradient accumulation, label smoothing, warm-up, cosine decay, minimum LR floor, gradient clipping, early stopping, resumable checkpoints, environment capture, and peak GPU-memory reporting.
## Data
Primary experiment: Flickr30k. Multiple references remain grouped for evaluation. The repository does not redistribute the complete dataset.
## Inputs
RGB JPG, PNG, WEBP, or BMP images after safe decoding, EXIF orientation correction, and checkpoint-native image processing.
## Outputs
- greedy caption;- ranked beam candidates;- concise model-generated alt-text draft;- token transition scores where available;- sequence score where available;- latency and generation settings;- optional genuine cross-attention output.
## Evaluation
Required final evidence:
- BLEU-1 and BLEU-4;- METEOR;- ROUGE-L;- CIDEr;- CLIPScore;- distinct-1 and distinct-2;- unique-caption ratio and repetition rate;- greedy-versus-beam analysis;- model size and latency;- quality challenge performance;- manual failure analysis;- PyTorch-versus-ONNX parity.
No new score is claimed until the corresponding artifact exists under `outputs/`.
## Intended use
Education, portfolio demonstration, image-captioning experimentation, draft metadata, human-reviewed visual documentation, and quality-reporting research prototypes.
## Prohibited or unsuitable use
Identity recognition, surveillance, sensitive-attribute inference, accessibility-critical publishing without review, product release, official quality decisions, medical, legal, financial, hiring, insurance, security, or safety-critical decisions.
## Limitations
The model can hallucinate, omit important objects, confuse colors and counts, produce generic descriptions, repeat phrases, and fail on poor-quality or out-of-distribution images. Flickr30k is not an industrial inspection dataset. Quality challenge results measure descriptive behavior only and do not establish defect-detection competence.
## Confidence and interpretability
Generated-token probability is not calibrated correctness. The browser's structural heuristic is not presented as model confidence. Token and attention views are interpretability aids and do not prove reasoning.
## Privacy
Do not upload personal, confidential, medical, proprietary, security-sensitive, or unlicensed images to a public Space. Public samples must be synthetic, public-domain, or properly licensed.
## Deployment
The fine-tuned Python checkpoint must be converted to a Transformers.js-compatible ONNX repository and pass parity/browser checks before `fine_tuned_model_id` is enabled in `web/metadata.json`.1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677{
"architectures": [
"VisionEncoderDecoderModel"
],
"bos_token_id": 50256,
"decoder": {
"activation_function": "gelu_new",
"add_cross_attention": true,
"architectures": [
"GPT2LMHeadModel"
],
"attn_pdrop": 0.1,
"decoder_start_token_id": 50256,
"dtype": "float32",
"embd_pdrop": 0.1,
"initializer_range": 0.02,
"is_decoder": true,
"layer_norm_epsilon": 1e-05,
"model_type": "gpt2",
"n_ctx": 1024,
"n_embd": 768,
"n_head": 12,
"n_inner": null,
"n_layer": 12,
"n_positions": 1024,
"pad_token_id": 50256,
"reorder_and_upcast_attn": false,
"resid_pdrop": 0.1,
"scale_attn_by_inverse_layer_idx": false,
"scale_attn_weights": true,
"summary_activation": null,
"summary_first_dropout": 0.1,
"summary_proj_to_labels": true,
"summary_type": "cls_index",
"summary_use_proj": true,
"task_specific_params": {
"text-generation": {
"do_sample": true,
"max_length": 50
}
},
"use_cache": true,
"vocab_size": 50257
},
"decoder_start_token_id": 50256,
"dtype": "float32",
"encoder": {
"architectures": [
"ViTModel"
],
"attention_probs_dropout_prob": 0.0,
"dtype": "float32",
"encoder_stride": 16,
"hidden_act": "gelu",
"hidden_dropout_prob": 0.0,
"hidden_size": 768,
"image_size": 224,
"initializer_range": 0.02,
"intermediate_size": 3072,
"layer_norm_eps": 1e-12,
"model_type": "vit",
"num_attention_heads": 12,
"num_channels": 3,
"num_hidden_layers": 12,
"patch_size": 16,
"pooler_act": "tanh",
"pooler_output_size": 768,
"qkv_bias": true
},
"eos_token_id": 50256,
"is_encoder_decoder": true,
"model_type": "vision-encoder-decoder",
"pad_token_id": 50256,
"tie_word_embeddings": false,
"transformers_version": "4.57.6",
"use_cache": true
}123456789{
"_from_model_config": true,
"bos_token_id": 50256,
"decoder_start_token_id": 50256,
"eos_token_id": 50256,
"max_length": 40,
"pad_token_id": 50256,
"transformers_version": "4.57.6"
}123version https://git-lfs.github.com/spec/v1oid sha256:36eb63aea2a27dadf5c1854bedaa28d0079ee90fe3906910d915d2a42f2aa9b7size 613593983123version https://git-lfs.github.com/spec/v1oid sha256:826c644798c966cbf8d3dd08d0fe97d2ae75ffcda200ea1af57fa93ae3a1b98dsize 154654483123version https://git-lfs.github.com/spec/v1oid sha256:ae65f1b6543339d67804b01e8c600dc7aa3e448070b1b3473218857129730860size 154644876123version https://git-lfs.github.com/spec/v1oid sha256:836be7c5db45e728d9146bc884145ed2d1d5c694ceff980443aa4394cf8607d9size 869677671234567891011121314151617181920212223{
"do_convert_rgb": null,
"do_normalize": true,
"do_rescale": true,
"do_resize": true,
"image_mean": [
0.5,
0.5,
0.5
],
"image_processor_type": "ViTImageProcessor",
"image_std": [
0.5,
0.5,
0.5
],
"resample": 2,
"rescale_factor": 0.00392156862745098,
"size": {
"height": 224,
"width": 224
}
}123456789101112131415161718192021222324252627282930{
"bos_token": {
"content": "<|endoftext|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
},
"eos_token": {
"content": "<|endoftext|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
},
"pad_token": {
"content": "<|endoftext|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
},
"unk_token": {
"content": "<|endoftext|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
}
}12345678910111213141516171819202122232425262728{
"add_prefix_space": false,
"added_tokens_decoder": {
"50256": {
"content": "<|endoftext|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
}
},
"bos_token": "<|endoftext|>",
"clean_up_tokenization_spaces": false,
"eos_token": "<|endoftext|>",
"extra_special_tokens": {},
"max_length": 32,
"model_max_length": 1024,
"pad_to_multiple_of": null,
"pad_token": "<|endoftext|>",
"pad_token_type_id": 0,
"padding_side": "right",
"stride": 0,
"tokenizer_class": "GPT2Tokenizer",
"truncation_side": "right",
"truncation_strategy": "longest_first",
"unk_token": "<|endoftext|>"
}README.mdAdded+88
config.jsonAdded+77
generation_config.jsonAdded+9
merges.txtAdded
onnx/decoder_model_merged_quantized.onnxAdded+3
onnx/decoder_model_quantized.onnxAdded+3
onnx/decoder_with_past_model_quantized.onnxAdded+3
onnx/encoder_model_quantized.onnxAdded+3
preprocessor_config.jsonAdded+23
special_tokens_map.jsonAdded+30
tokenizer.jsonAdded
tokenizer_config.jsonAdded+28
vocab.jsonAdded