anmol-unitmole commited on
Commit
130d4de
·
verified ·
1 Parent(s): c3d00a5

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Model Card · RTX 5090 Vision Encoder-Decoder Image Captioning
2
+
3
+ ## System
4
+
5
+ `02-image-caption-generation-vision-encoder-decoder`
6
+
7
+ ## Status
8
+
9
+ **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.
10
+
11
+ ## Architecture
12
+
13
+ - Python checkpoint: `nlpconnect/vit-gpt2-image-captioning`
14
+ - Vision encoder: ViT
15
+ - Text decoder: GPT-2 with encoder cross-attention
16
+ - Framework: PyTorch and Hugging Face `VisionEncoderDecoderModel`
17
+ - Browser baseline: `Xenova/vit-gpt2-image-captioning`
18
+ - Browser runtime: Transformers.js and ONNX Runtime Web
19
+
20
+ ## Training method
21
+
22
+ 1. Freeze the vision encoder and adapt the decoder/cross-modal path.
23
+ 2. Unfreeze the top six vision blocks with differential learning rates.
24
+ 3. Conservatively fine-tune the full architecture.
25
+ 4. Select checkpoints using generated-caption validation metrics, with validation-loss fallback.
26
+
27
+ 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.
28
+
29
+ ## Data
30
+
31
+ Primary experiment: Flickr30k. Multiple references remain grouped for evaluation. The repository does not redistribute the complete dataset.
32
+
33
+ ## Inputs
34
+
35
+ RGB JPG, PNG, WEBP, or BMP images after safe decoding, EXIF orientation correction, and checkpoint-native image processing.
36
+
37
+ ## Outputs
38
+
39
+ - greedy caption;
40
+ - ranked beam candidates;
41
+ - concise model-generated alt-text draft;
42
+ - token transition scores where available;
43
+ - sequence score where available;
44
+ - latency and generation settings;
45
+ - optional genuine cross-attention output.
46
+
47
+ ## Evaluation
48
+
49
+ Required final evidence:
50
+
51
+ - BLEU-1 and BLEU-4;
52
+ - METEOR;
53
+ - ROUGE-L;
54
+ - CIDEr;
55
+ - CLIPScore;
56
+ - distinct-1 and distinct-2;
57
+ - unique-caption ratio and repetition rate;
58
+ - greedy-versus-beam analysis;
59
+ - model size and latency;
60
+ - quality challenge performance;
61
+ - manual failure analysis;
62
+ - PyTorch-versus-ONNX parity.
63
+
64
+ No new score is claimed until the corresponding artifact exists under `outputs/`.
65
+
66
+ ## Intended use
67
+
68
+ Education, portfolio demonstration, image-captioning experimentation, draft metadata, human-reviewed visual documentation, and quality-reporting research prototypes.
69
+
70
+ ## Prohibited or unsuitable use
71
+
72
+ 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.
73
+
74
+ ## Limitations
75
+
76
+ 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.
77
+
78
+ ## Confidence and interpretability
79
+
80
+ 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.
81
+
82
+ ## Privacy
83
+
84
+ 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.
85
+
86
+ ## Deployment
87
+
88
+ 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`.
config.json ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "VisionEncoderDecoderModel"
4
+ ],
5
+ "bos_token_id": 50256,
6
+ "decoder": {
7
+ "activation_function": "gelu_new",
8
+ "add_cross_attention": true,
9
+ "architectures": [
10
+ "GPT2LMHeadModel"
11
+ ],
12
+ "attn_pdrop": 0.1,
13
+ "decoder_start_token_id": 50256,
14
+ "dtype": "float32",
15
+ "embd_pdrop": 0.1,
16
+ "initializer_range": 0.02,
17
+ "is_decoder": true,
18
+ "layer_norm_epsilon": 1e-05,
19
+ "model_type": "gpt2",
20
+ "n_ctx": 1024,
21
+ "n_embd": 768,
22
+ "n_head": 12,
23
+ "n_inner": null,
24
+ "n_layer": 12,
25
+ "n_positions": 1024,
26
+ "pad_token_id": 50256,
27
+ "reorder_and_upcast_attn": false,
28
+ "resid_pdrop": 0.1,
29
+ "scale_attn_by_inverse_layer_idx": false,
30
+ "scale_attn_weights": true,
31
+ "summary_activation": null,
32
+ "summary_first_dropout": 0.1,
33
+ "summary_proj_to_labels": true,
34
+ "summary_type": "cls_index",
35
+ "summary_use_proj": true,
36
+ "task_specific_params": {
37
+ "text-generation": {
38
+ "do_sample": true,
39
+ "max_length": 50
40
+ }
41
+ },
42
+ "use_cache": true,
43
+ "vocab_size": 50257
44
+ },
45
+ "decoder_start_token_id": 50256,
46
+ "dtype": "float32",
47
+ "encoder": {
48
+ "architectures": [
49
+ "ViTModel"
50
+ ],
51
+ "attention_probs_dropout_prob": 0.0,
52
+ "dtype": "float32",
53
+ "encoder_stride": 16,
54
+ "hidden_act": "gelu",
55
+ "hidden_dropout_prob": 0.0,
56
+ "hidden_size": 768,
57
+ "image_size": 224,
58
+ "initializer_range": 0.02,
59
+ "intermediate_size": 3072,
60
+ "layer_norm_eps": 1e-12,
61
+ "model_type": "vit",
62
+ "num_attention_heads": 12,
63
+ "num_channels": 3,
64
+ "num_hidden_layers": 12,
65
+ "patch_size": 16,
66
+ "pooler_act": "tanh",
67
+ "pooler_output_size": 768,
68
+ "qkv_bias": true
69
+ },
70
+ "eos_token_id": 50256,
71
+ "is_encoder_decoder": true,
72
+ "model_type": "vision-encoder-decoder",
73
+ "pad_token_id": 50256,
74
+ "tie_word_embeddings": false,
75
+ "transformers_version": "4.57.6",
76
+ "use_cache": true
77
+ }
generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 50256,
4
+ "decoder_start_token_id": 50256,
5
+ "eos_token_id": 50256,
6
+ "max_length": 40,
7
+ "pad_token_id": 50256,
8
+ "transformers_version": "4.57.6"
9
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
onnx/decoder_model_merged_quantized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:36eb63aea2a27dadf5c1854bedaa28d0079ee90fe3906910d915d2a42f2aa9b7
3
+ size 613593983
onnx/decoder_model_quantized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:826c644798c966cbf8d3dd08d0fe97d2ae75ffcda200ea1af57fa93ae3a1b98d
3
+ size 154654483
onnx/decoder_with_past_model_quantized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ae65f1b6543339d67804b01e8c600dc7aa3e448070b1b3473218857129730860
3
+ size 154644876
onnx/encoder_model_quantized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:836be7c5db45e728d9146bc884145ed2d1d5c694ceff980443aa4394cf8607d9
3
+ size 86967767
preprocessor_config.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_convert_rgb": null,
3
+ "do_normalize": true,
4
+ "do_rescale": true,
5
+ "do_resize": true,
6
+ "image_mean": [
7
+ 0.5,
8
+ 0.5,
9
+ 0.5
10
+ ],
11
+ "image_processor_type": "ViTImageProcessor",
12
+ "image_std": [
13
+ 0.5,
14
+ 0.5,
15
+ 0.5
16
+ ],
17
+ "resample": 2,
18
+ "rescale_factor": 0.00392156862745098,
19
+ "size": {
20
+ "height": 224,
21
+ "width": 224
22
+ }
23
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|endoftext|>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|endoftext|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "<|endoftext|>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "unk_token": {
24
+ "content": "<|endoftext|>",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ }
30
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "50256": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ }
12
+ },
13
+ "bos_token": "<|endoftext|>",
14
+ "clean_up_tokenization_spaces": false,
15
+ "eos_token": "<|endoftext|>",
16
+ "extra_special_tokens": {},
17
+ "max_length": 32,
18
+ "model_max_length": 1024,
19
+ "pad_to_multiple_of": null,
20
+ "pad_token": "<|endoftext|>",
21
+ "pad_token_type_id": 0,
22
+ "padding_side": "right",
23
+ "stride": 0,
24
+ "tokenizer_class": "GPT2Tokenizer",
25
+ "truncation_side": "right",
26
+ "truncation_strategy": "longest_first",
27
+ "unk_token": "<|endoftext|>"
28
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff