Charansaiponnada commited on
Commit
1cc325c
Β·
verified Β·
1 Parent(s): d670614

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +105 -0
README.md CHANGED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BLIP Fine-Tuned for Traffic Navigation Captioning
2
+
3
+ Model card for the BLIP image-captioning model fine-tuned with a 3-stage progressive LoRA workflow for traffic navigation captions.
4
+
5
+ ## Model Details
6
+ - **Model name (local):** final_model
7
+ - **Base model:** Salesforce/blip-image-captioning-base (~248M parameters)
8
+ - **Fine-tuning method:** LoRA (Low-Rank Adaptation), 3-stage progressive (vision encoder β†’ text decoder β†’ joint)
9
+ - **Framework:** PyTorch + Hugging Face Transformers
10
+ - **Files in repo:** `model.safetensors`, `tokenizer.json`, `tokenizer_config.json`, `vocab.txt`, `preprocessor_config.json`, `config.json`, `generation_config.json`, `special_tokens_map.json`
11
+
12
+ ## Short Description
13
+ This model was adapted from BLIP to generate grounded, navigation-style captions for traffic scenes using a parameter-efficient, three-stage LoRA fine-tuning procedure. The approach keeps the majority of the base weights frozen while adding and training small low-rank adapters in attention and projection layers.
14
+
15
+ ## Intended Use
16
+ - Primary: Research and prototyping of image-to-text captioning for traffic/navigation scenarios.
17
+ - Secondary: Integration into navigation-assist systems, dataset analysis, or as a baseline for further fine-tuning.
18
+
19
+ ## Limitations and Risks
20
+ - Trained on a small, domain-specific dataset (427 images); may not generalize to unseen cities, weather conditions, or camera viewpoints.
21
+ - Captions are not guaranteed to be safety- or privacy-compliant; do not rely on them for life-critical navigation decisions.
22
+ - The model may hallucinate objects or spatial relations; verify with downstream modules or human oversight when used in production.
23
+
24
+ ## Training Data
25
+ - Dataset name: Traffic Navigation Caption Dataset (Vijayawada, Andhra Pradesh, India)
26
+ - Size: 427 images (341 train / 42 val / 44 test)
27
+ - Annotations: COCO-style JSON with two caption levels β€” (1) global scene description, and (2) grounded navigation captions with region references.
28
+ - Data license: Not specified here β€” include the dataset license in the repo if redistributing.
29
+
30
+ ## Fine-tuning Setup (3-stage LoRA)
31
+ - Stage 1 (Vision encoder - ViT)
32
+ - Target modules: `qkv` projections
33
+ - Rank: 16, Alpha: 32, Dropout: 0.05
34
+ - Trainable params: ~589,824 (β‰ˆ0.24%)
35
+ - Epochs: 10, LR: 5e-5
36
+
37
+ - Stage 2 (Text decoder)
38
+ - Target modules: `query`, `value`
39
+ - Rank: 32, Alpha: 64, Dropout: 0.05
40
+ - Trainable params: ~2,359,296 (β‰ˆ0.95%)
41
+ - Epochs: 8, LR: 3e-5
42
+
43
+ - Stage 3 (Joint fine-tuning)
44
+ - Target: combined adapters on both vision and text modules
45
+ - Rank: 16, Alpha: 32, Dropout: 0.05
46
+ - Trainable params: ~1,769,472 (β‰ˆ0.71%)
47
+ - Epochs: 6, LR: 1e-5
48
+
49
+ - Optimizer: AdamW
50
+ - Batch: 4 (effective 16 with gradient accumulation)
51
+ - Mixed precision: FP16 enabled
52
+ - Hardware used (report): NVIDIA Tesla T4 (15GB)
53
+
54
+ ## Evaluation
55
+ Test set: 44 held-out images
56
+
57
+ Key metrics (mean):
58
+
59
+ - BLEU-1: Base 0.01936 β†’ Fine-tuned 0.02158 (+11.45%)
60
+ - BLEU-4: Base 0.00787 β†’ Fine-tuned 0.01033 (+31.27%)
61
+ - METEOR: Base 0.069998 β†’ Fine-tuned 0.074931 (+7.05%)
62
+ - ROUGE-L: Base 0.12089 β†’ Fine-tuned 0.13612 (+12.60%)
63
+ - Semantic similarity: Base 0.11853 β†’ Fine-tuned 0.12770 (+7.74%)
64
+
65
+ Other stats (means): average caption length increased 8.86 β†’ 9.77 tokens; inference time decreased ~451.6ms β†’ ~395.0ms per image on the reported hardware.
66
+
67
+ For full metric JSON outputs see `base_metrics.json` and `finetuned_metrics.json` (included in the repository).
68
+
69
+ ## Example: Load & Inference
70
+ ```python
71
+ from PIL import Image
72
+ from transformers import BlipProcessor, BlipForConditionalGeneration
73
+
74
+ model = BlipForConditionalGeneration.from_pretrained(".")
75
+ processor = BlipProcessor.from_pretrained(".")
76
+
77
+ image = Image.open("path/to/traffic.jpg")
78
+ inputs = processor(images=image, return_tensors="pt")
79
+ outputs = model.generate(**inputs, max_new_tokens=150, num_beams=5)
80
+ caption = processor.decode(outputs[0], skip_special_tokens=True)
81
+ print(caption)
82
+ ```
83
+
84
+ ## Files
85
+ - `model.safetensors` β€” model weights
86
+ - tokenizer and vocab files β€” tokenizer.json, tokenizer_config.json, vocab.txt, special_tokens_map.json
87
+ - config files β€” `config.json`, `generation_config.json`, `preprocessor_config.json`
88
+ - evaluation outputs: `base_metrics.json`, `finetuned_metrics.json`
89
+
90
+ ## Recommended Citation
91
+ If you use this model in research, cite the BLIP paper and reference the LoRA approach. Example:
92
+
93
+ Li et al., "BLIP: Bootstrapping Language-Image Pre-training" (ICML 2022)
94
+ Hu et al., "LoRA: Low-Rank Adaptation of Large Language Models" (ICLR 2021)
95
+
96
+ You may also cite the internal project report included in the repository: `COMPLETE_METHODOLOGY_AND_RESULTS.txt`.
97
+
98
+ ## License
99
+ License for the model weights and tokenizer is not specified here. Add a `LICENSE` file to the repo with the chosen license (e.g., Apache-2.0, CC-BY-4.0, or a non-commercial license) before publishing.
100
+
101
+ ## Contact
102
+ For questions, contact the model author/maintainer (add contact info in the repo or in the Hugging Face model settings).
103
+
104
+ ---
105
+ Last updated: 2025-12-20