pavanpraneeth commited on
Commit
290f366
·
verified ·
1 Parent(s): 678d1bf

Upload folder using huggingface_hub

Browse files
DEPLOY_GUIDE.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Deployment Guide for CaptionIQ
2
+
3
+ This document explains how to deploy your Image Captioning application to the public.
4
+
5
+ ## 1. Hugging Face Spaces (Streamlit SDK)
6
+
7
+ Hugging Face Spaces allows you to quickly host Machine Learning demos. I have prepared an automated script to deploy it.
8
+
9
+ ### Automatic Method (Recommended)
10
+ You can deploy directly from your local terminal using the script provided:
11
+ ```bash
12
+ python3 deploy_hf.py --token YOUR_HUGGING_FACE_TOKEN --repo-name CaptionIQ
13
+ ```
14
+ *Note: Make sure your token has **Write** permissions. You can generate one at [huggingface.co/settings/tokens](https://huggingface.co/settings/tokens).*
15
+
16
+ The script will:
17
+ 1. Automatically create a Streamlit Space named `CaptionIQ` on your Hugging Face account.
18
+ 2. Filter out unnecessary large files (like dataset images in `data/Images`).
19
+ 3. Upload your models and code.
20
+ 4. Set up Git LFS (Large File Storage) for your `.h5` model files automatically.
21
+
22
+ ## 2. Streamlit Community Cloud
23
+
24
+ Streamlit provides a free community cloud that integrates directly with GitHub. If you prefer to deploy there:
25
+
26
+ 1. **Push your code to GitHub**:
27
+ - Create a GitHub repository for your project.
28
+ - Commit and push your code. Because the `.h5` models are large, ensure you have Git LFS installed (`git lfs install`) before pushing, or exclude them and load models from an external URL. I have added `.gitattributes` to track `.h5` files with LFS.
29
+
30
+ 2. **Deploy via Streamlit Cloud**:
31
+ - Go to [share.streamlit.io](https://share.streamlit.io/).
32
+ - Click "New app".
33
+ - Select your GitHub repository, choose the main branch, and specify `app.py` as your Main file path.
34
+ - Click **Deploy**.
35
+
36
+ > **Note on Free Tiers**: Streamlit Community Cloud has a 1GB memory limit which might be tight when loading two large VGG models simultaneously. Hugging Face Spaces (Free Tier) typically offers 16GB of RAM, making it a better fit for this project!
README.md CHANGED
@@ -1,12 +1,140 @@
1
  ---
2
  title: CaptionIQ
3
- emoji: 💻
4
- colorFrom: purple
5
- colorTo: red
6
- sdk: gradio
7
- sdk_version: 6.11.0
8
  app_file: app.py
9
  pinned: false
10
  ---
 
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  title: CaptionIQ
3
+ emoji: 🧠
4
+ colorFrom: indigo
5
+ colorTo: purple
6
+ sdk: streamlit
7
+ sdk_version: 1.28.0
8
  app_file: app.py
9
  pinned: false
10
  ---
11
+ # 🧠 CaptionIQ — AI Image Captioning
12
 
13
+ > Generate natural language captions for images using VGG16/VGG19 + LSTM on the Flickr8K dataset.
14
+
15
+ ---
16
+
17
+ ## ✨ Features
18
+
19
+ - **Dual CNN Backbones** — VGG16 and VGG19 for image feature extraction
20
+ - **LSTM Caption Decoder** — Generates fluent, descriptive captions
21
+ - **Beam Search** — Top-3 diverse captions with confidence scores
22
+ - **BLEU Evaluation** — BLEU-1 through BLEU-4 with VGG16 vs VGG19 comparison
23
+ - **Streamlit Web App** — Upload images, switch backbones, download captions
24
+ - **Demo Mode** — Try with preloaded Flickr8K sample images
25
+
26
+ ---
27
+
28
+ ## 🏗️ Architecture
29
+
30
+ ```
31
+ Image → VGG16/19 (fc2) → 4096-d → Dense(256) ─┐
32
+ ├→ Add → Dense(256) → Softmax(vocab)
33
+ Caption → Embedding(256) → LSTM(256) ───────────┘
34
+ ```
35
+
36
+ ---
37
+
38
+ ## 🚀 Quick Start
39
+
40
+ ### 1. Install Dependencies
41
+
42
+ ```bash
43
+ pip install -r requirements.txt
44
+ ```
45
+
46
+ ### 2. Preprocess Dataset
47
+
48
+ ```bash
49
+ python src/preprocess.py
50
+ ```
51
+
52
+ Downloads Flickr8K, cleans captions, builds vocabulary, creates train/val/test splits.
53
+
54
+ ### 3. Extract Features
55
+
56
+ ```bash
57
+ python src/extract_features.py --backbone both
58
+ ```
59
+
60
+ Extracts 4096-d features from VGG16 and VGG19 (saved as `.pkl`).
61
+
62
+ ### 4. Train Models
63
+
64
+ ```bash
65
+ python src/train.py --backbone both --epochs 20
66
+ ```
67
+
68
+ Trains both VGG16 and VGG19 captioning models. Saves checkpoints and loss plots.
69
+
70
+ ### 5. Evaluate
71
+
72
+ ```bash
73
+ python src/evaluate.py --backbone both
74
+ ```
75
+
76
+ Computes BLEU-1 to BLEU-4 on the test set. Prints VGG16 vs VGG19 comparison table.
77
+
78
+ ### 6. Generate Captions
79
+
80
+ ```bash
81
+ python src/inference.py --image path/to/image.jpg --backbone vgg16
82
+ ```
83
+
84
+ ### 7. Launch Web App
85
+
86
+ ```bash
87
+ streamlit run app.py
88
+ ```
89
+
90
+ ---
91
+
92
+ ## 📁 Project Structure
93
+
94
+ ```
95
+ ├── data/ # Dataset & preprocessed files
96
+ ├── models/ # Trained model checkpoints (.h5)
97
+ ├── outputs/ # Loss plots, BLEU results
98
+ ├── src/
99
+ │ ├── config.py # Paths & hyperparameters
100
+ │ ├── preprocess.py # Caption cleaning & tokenization
101
+ │ ├── extract_features.py # VGG feature extraction
102
+ │ ├── model.py # CNN-LSTM architecture
103
+ │ ├── train.py # Training with data generator
104
+ │ ├── inference.py # Greedy & beam search
105
+ │ ├── evaluate.py # BLEU score evaluation
106
+ │ └── utils.py # Shared utilities
107
+ ├── app.py # Streamlit web app
108
+ ├── requirements.txt # Dependencies
109
+ └── README.md
110
+ ```
111
+
112
+ ---
113
+
114
+ ## 📊 Results
115
+
116
+ | Metric | VGG16 | VGG19 |
117
+ |---------|--------|--------|
118
+ | BLEU-1 | — | — |
119
+ | BLEU-2 | — | — |
120
+ | BLEU-3 | — | — |
121
+ | BLEU-4 | — | — |
122
+
123
+ > Results will be populated after training and evaluation.
124
+
125
+ ---
126
+
127
+ ## 🛠️ Tech Stack
128
+
129
+ - **Deep Learning**: TensorFlow / Keras
130
+ - **Feature Extraction**: VGG16, VGG19 (ImageNet pretrained)
131
+ - **Text Processing**: NLTK, Keras Tokenizer
132
+ - **Evaluation**: NLTK BLEU
133
+ - **Web App**: Streamlit
134
+ - **Dataset**: Flickr8K (8,000 images, 5 captions each)
135
+
136
+ ---
137
+
138
+ ## 📄 License
139
+
140
+ This project is for educational purposes.
app.py ADDED
@@ -0,0 +1,686 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ CaptionIQ — Streamlit Web Application
3
+ Upload an image or use demo mode to generate captions with VGG16/VGG19 + LSTM.
4
+ """
5
+
6
+ import os
7
+ import sys
8
+ import json
9
+ import numpy as np
10
+
11
+ # Work around Streamlit watcher issues with torch custom classes.
12
+ os.environ.setdefault("STREAMLIT_SERVER_FILE_WATCHER_TYPE", "none")
13
+
14
+ import streamlit as st
15
+ from PIL import Image
16
+ from tensorflow.keras.models import load_model
17
+ from tensorflow.keras.preprocessing.image import img_to_array
18
+ from tensorflow.keras.applications.vgg16 import VGG16, preprocess_input as vgg16_preprocess
19
+ from tensorflow.keras.applications.vgg19 import VGG19, preprocess_input as vgg19_preprocess
20
+ from tensorflow.keras.models import Model as KerasModel
21
+
22
+ # ── Keras compatibility patch ──────────────────────────────────────
23
+ # Models saved with newer Keras include 'quantization_config' in every
24
+ # layer config. Older Keras versions reject the unknown kwarg.
25
+ # The Embedding layer's mask_zero=True also serialises a NotEqual op
26
+ # that the legacy h5 loader can't resolve by name.
27
+ import keras.src.ops.operation as _keras_op
28
+ from keras.src.ops.numpy import NotEqual as _NotEqual
29
+
30
+ _orig_from_config = _keras_op.Operation.from_config.__func__
31
+
32
+
33
+ @classmethod # type: ignore[misc]
34
+ def _patched_from_config(cls, config): # noqa: N805
35
+ config.pop("quantization_config", None)
36
+ return _orig_from_config(cls, config)
37
+
38
+
39
+ _keras_op.Operation.from_config = _patched_from_config
40
+
41
+ from src.model import BahdanauAttention
42
+ _CUSTOM_OBJECTS = {"NotEqual": _NotEqual, "BahdanauAttention": BahdanauAttention}
43
+ # ───────────────────────────────────────────────────────────────────
44
+
45
+ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
46
+ from src.config import (
47
+ IMAGE_SIZE, BEAM_WIDTH,
48
+ VGG16_MODEL_FILE, VGG19_MODEL_FILE,
49
+ TOKENIZER_FILE, BLEU_RESULTS_FILE,
50
+ VGG16_FEATURES_FILE, VGG19_FEATURES_FILE,
51
+ FLICKR_IMAGES_DIR, CAPTIONS_FILE,
52
+ START_TOKEN, END_TOKEN,
53
+ )
54
+ from src.utils import load_tokenizer, load_features, load_captions
55
+ from src.engine import CaptionEngine
56
+
57
+ # ──────────────────────────────────────────────
58
+ # Page config
59
+ # ──────────────────────────────────────────────
60
+ st.set_page_config(
61
+ page_title="CaptionIQ — AI Image Captioning",
62
+ page_icon="🧠",
63
+ layout="wide",
64
+ initial_sidebar_state="expanded",
65
+ )
66
+
67
+ # ──────────────────────────────────────────────
68
+ # Custom CSS
69
+ # ──────────────────────────────────────────────
70
+ st.markdown("""
71
+ <style>
72
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
73
+
74
+ .main {
75
+ font-family: 'Inter', sans-serif;
76
+ }
77
+
78
+ .stApp {
79
+ background: linear-gradient(135deg, #0f0c29 0%, #1a1a3e 50%, #24243e 100%);
80
+ }
81
+
82
+ .hero-title {
83
+ font-size: 3rem;
84
+ font-weight: 700;
85
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
86
+ -webkit-background-clip: text;
87
+ -webkit-text-fill-color: transparent;
88
+ text-align: center;
89
+ margin-bottom: 0.5rem;
90
+ }
91
+
92
+ .hero-subtitle {
93
+ font-size: 1.1rem;
94
+ color: #a0aec0;
95
+ text-align: center;
96
+ margin-bottom: 2rem;
97
+ }
98
+
99
+ .caption-card {
100
+ background: rgba(255, 255, 255, 0.05);
101
+ border: 1px solid rgba(255, 255, 255, 0.1);
102
+ border-radius: 12px;
103
+ padding: 1.2rem;
104
+ margin-bottom: 0.8rem;
105
+ backdrop-filter: blur(10px);
106
+ transition: transform 0.2s ease;
107
+ }
108
+
109
+ .caption-card:hover {
110
+ transform: translateY(-2px);
111
+ border-color: rgba(102, 126, 234, 0.4);
112
+ }
113
+
114
+ .caption-rank {
115
+ font-size: 0.85rem;
116
+ font-weight: 600;
117
+ color: #667eea;
118
+ text-transform: uppercase;
119
+ letter-spacing: 0.05em;
120
+ margin-bottom: 0.3rem;
121
+ }
122
+
123
+ .caption-text {
124
+ font-size: 1.1rem;
125
+ color: #e2e8f0;
126
+ line-height: 1.5;
127
+ }
128
+
129
+ .score-badge {
130
+ display: inline-block;
131
+ background: rgba(102, 126, 234, 0.15);
132
+ color: #667eea;
133
+ padding: 0.2rem 0.6rem;
134
+ border-radius: 6px;
135
+ font-size: 0.8rem;
136
+ font-weight: 500;
137
+ margin-top: 0.5rem;
138
+ }
139
+
140
+ .metric-card {
141
+ background: rgba(255, 255, 255, 0.05);
142
+ border: 1px solid rgba(255, 255, 255, 0.08);
143
+ border-radius: 10px;
144
+ padding: 1rem;
145
+ text-align: center;
146
+ }
147
+
148
+ .metric-value {
149
+ font-size: 1.8rem;
150
+ font-weight: 700;
151
+ color: #667eea;
152
+ }
153
+
154
+ .metric-label {
155
+ font-size: 0.8rem;
156
+ color: #a0aec0;
157
+ text-transform: uppercase;
158
+ letter-spacing: 0.05em;
159
+ }
160
+
161
+ .info-panel {
162
+ background: rgba(255, 255, 255, 0.03);
163
+ border: 1px solid rgba(255, 255, 255, 0.08);
164
+ border-radius: 12px;
165
+ padding: 1.5rem;
166
+ margin-top: 1rem;
167
+ }
168
+
169
+ .sidebar .stRadio > label {
170
+ font-weight: 500;
171
+ }
172
+
173
+ div[data-testid="stFileUploader"] {
174
+ border: 2px dashed rgba(102, 126, 234, 0.4);
175
+ border-radius: 12px;
176
+ padding: 1rem;
177
+ }
178
+ </style>
179
+ """, unsafe_allow_html=True)
180
+
181
+
182
+ # ──────────────────────────────────────────────
183
+ # Cached loading functions
184
+ # ──────────────────────────────────────────────
185
+ @st.cache_resource
186
+ def load_captioning_model(backbone: str):
187
+ """Load a trained captioning model."""
188
+ if backbone == "vgg16":
189
+ model_file = VGG16_MODEL_FILE
190
+ elif backbone == "vgg19":
191
+ model_file = VGG19_MODEL_FILE
192
+ else:
193
+ return None
194
+ if not os.path.exists(model_file):
195
+ return None
196
+ return load_model(model_file, custom_objects=_CUSTOM_OBJECTS)
197
+
198
+
199
+ @st.cache_resource
200
+ def get_caption_engine():
201
+ return CaptionEngine()
202
+
203
+
204
+ @st.cache_resource
205
+ def load_feature_extractor(backbone: str):
206
+ """Load VGG feature extractor."""
207
+ if backbone == "vgg16":
208
+ base_model = VGG16(weights="imagenet")
209
+ preprocess_fn = vgg16_preprocess
210
+ else:
211
+ base_model = VGG19(weights="imagenet")
212
+ preprocess_fn = vgg19_preprocess
213
+
214
+ model = KerasModel(
215
+ inputs=base_model.input,
216
+ outputs=base_model.get_layer("block5_pool").output
217
+ )
218
+ return model, preprocess_fn
219
+
220
+
221
+ @st.cache_resource
222
+ def get_tokenizer():
223
+ """Load the fitted tokenizer."""
224
+ if not os.path.exists(TOKENIZER_FILE):
225
+ return None
226
+ return load_tokenizer(TOKENIZER_FILE)
227
+
228
+
229
+ @st.cache_data
230
+ def get_bleu_results():
231
+ """Load BLEU evaluation results."""
232
+ if not os.path.exists(BLEU_RESULTS_FILE):
233
+ return None
234
+ with open(BLEU_RESULTS_FILE, "r") as f:
235
+ return json.load(f)
236
+
237
+
238
+ @st.cache_data
239
+ def get_demo_images():
240
+ """Get a few sample images from the dataset for demo mode."""
241
+ if not os.path.exists(FLICKR_IMAGES_DIR):
242
+ return []
243
+ images = [
244
+ f for f in os.listdir(FLICKR_IMAGES_DIR)
245
+ if f.lower().endswith((".jpg", ".jpeg", ".png"))
246
+ ]
247
+ # Return first 5
248
+ return sorted(images)[:5]
249
+
250
+
251
+ @st.cache_data
252
+ def get_all_captions():
253
+ """Load all cleaned captions."""
254
+ if not os.path.exists(CAPTIONS_FILE):
255
+ return {}
256
+ return load_captions(CAPTIONS_FILE)
257
+
258
+
259
+ def extract_feature(image: Image.Image, backbone: str) -> np.ndarray:
260
+ """Extract feature vector from a PIL image."""
261
+ extractor, preprocess_fn = load_feature_extractor(backbone)
262
+
263
+ # Resize and preprocess
264
+ image = image.resize((IMAGE_SIZE, IMAGE_SIZE))
265
+ image = image.convert("RGB")
266
+ img_array = img_to_array(image)
267
+ img_array = np.expand_dims(img_array, axis=0)
268
+ img_array = preprocess_fn(img_array)
269
+
270
+ feature = extractor.predict(img_array, verbose=0)[0] # (7, 7, 512)
271
+ h, w, c = feature.shape
272
+ return feature.reshape(h * w, c) # (49, 512)
273
+
274
+
275
+ def extract_features_for_inference(image: Image.Image, backbone: str) -> dict:
276
+ """
277
+ Return backbone->feature mapping.
278
+ """
279
+ if backbone == "ensemble":
280
+ return {
281
+ "vgg16": extract_feature(image, "vgg16"),
282
+ "vgg19": extract_feature(image, "vgg19"),
283
+ }
284
+ return {backbone: extract_feature(image, backbone)}
285
+
286
+
287
+ def clean_caption_text(caption: str) -> str:
288
+ return caption.replace(START_TOKEN, "").replace(END_TOKEN, "").strip()
289
+
290
+
291
+ def is_low_quality_caption(caption: str, confidence: float) -> bool:
292
+ weak_endings = {
293
+ "a", "an", "the", "in", "on", "at", "of", "to", "for",
294
+ "with", "by", "from", "and", "or", "but", "as",
295
+ }
296
+ words = caption.split()
297
+ if len(words) < 5:
298
+ return True
299
+ if words[-1].lower() in weak_endings:
300
+ return True
301
+ if confidence < 0.35:
302
+ return True
303
+ return False
304
+
305
+
306
+ @st.cache_data
307
+ def get_caption_memory(backbone: str):
308
+ """
309
+ Build a lightweight retrieval index from dataset features + captions.
310
+ Uses mean-pooled spatial features for cosine search.
311
+ """
312
+ features_file = VGG16_FEATURES_FILE if backbone == "vgg16" else VGG19_FEATURES_FILE
313
+ if not os.path.exists(features_file) or not os.path.exists(CAPTIONS_FILE):
314
+ return None
315
+
316
+ features = load_features(features_file)
317
+ captions = load_captions(CAPTIONS_FILE)
318
+
319
+ ids = []
320
+ vectors = []
321
+ for image_id, feat in features.items():
322
+ if image_id not in captions:
323
+ continue
324
+ vec = np.asarray(feat, dtype=np.float32).mean(axis=0) # (512,)
325
+ norm = np.linalg.norm(vec) + 1e-10
326
+ ids.append(image_id)
327
+ vectors.append(vec / norm)
328
+
329
+ if not vectors:
330
+ return None
331
+
332
+ matrix = np.stack(vectors, axis=0) # (N, 512)
333
+ return {"ids": ids, "matrix": matrix, "captions": captions}
334
+
335
+
336
+ def retrieve_caption_fallback(
337
+ query_feature: np.ndarray,
338
+ backbone: str,
339
+ top_k: int = 8,
340
+ min_similarity: float = 0.86,
341
+ ):
342
+ memory = get_caption_memory(backbone)
343
+ if memory is None:
344
+ return None
345
+
346
+ query_vec = np.asarray(query_feature, dtype=np.float32).mean(axis=0)
347
+ query_vec = query_vec / (np.linalg.norm(query_vec) + 1e-10)
348
+
349
+ sims = memory["matrix"] @ query_vec
350
+ if sims.size == 0:
351
+ return None
352
+
353
+ top_idx = np.argsort(sims)[-top_k:][::-1]
354
+ best_caption = None
355
+ best_score = -1.0
356
+ best_sim = -1.0
357
+
358
+ for idx in top_idx:
359
+ image_id = memory["ids"][int(idx)]
360
+ sim = float(sims[int(idx)])
361
+ for raw_cap in memory["captions"].get(image_id, []):
362
+ cap = clean_caption_text(raw_cap)
363
+ words = cap.split()
364
+ if len(words) < 5:
365
+ continue
366
+ if words[-1].lower() in {"a", "an", "the", "in", "on", "of", "to", "and"}:
367
+ continue
368
+ score = sim + min(len(words), 14) * 0.003
369
+ if score > best_score:
370
+ best_score = score
371
+ best_caption = cap
372
+ best_sim = sim
373
+
374
+ if not best_caption:
375
+ return None
376
+ if best_sim < min_similarity:
377
+ return None
378
+
379
+ # Keep fallback confidence conservative so it does not look over-certain.
380
+ pseudo_conf = float(np.clip(0.40 + 0.25 * best_sim, 0.40, 0.70))
381
+ return best_caption, pseudo_conf
382
+
383
+
384
+ @st.cache_resource
385
+ def load_blip_captioner():
386
+ """
387
+ Optional modern caption model for upload fallback.
388
+ Returns None if transformers/torch are unavailable.
389
+ """
390
+ try:
391
+ import torch
392
+ from transformers import BlipProcessor, BlipForConditionalGeneration
393
+ except Exception:
394
+ return None
395
+
396
+ try:
397
+ processor = BlipProcessor.from_pretrained(
398
+ "Salesforce/blip-image-captioning-base"
399
+ )
400
+ model = BlipForConditionalGeneration.from_pretrained(
401
+ "Salesforce/blip-image-captioning-base"
402
+ )
403
+ model.eval()
404
+ return {"processor": processor, "model": model, "torch": torch}
405
+ except Exception:
406
+ return None
407
+
408
+
409
+ def generate_blip_caption(image: Image.Image):
410
+ bundle = load_blip_captioner()
411
+ if bundle is None:
412
+ return None
413
+
414
+ processor = bundle["processor"]
415
+ model = bundle["model"]
416
+ torch = bundle["torch"]
417
+
418
+ rgb = image.convert("RGB")
419
+ with torch.no_grad():
420
+ inputs = processor(images=rgb, return_tensors="pt")
421
+ output = model.generate(
422
+ **inputs,
423
+ max_new_tokens=24,
424
+ num_beams=5,
425
+ length_penalty=1.0,
426
+ early_stopping=True,
427
+ )
428
+ caption = processor.decode(output[0], skip_special_tokens=True).strip()
429
+ if not caption:
430
+ return None
431
+ return caption
432
+
433
+
434
+ def display_captions(captions: list):
435
+ """Display generated captions with styling."""
436
+ rank_labels = ["🥇 Top Caption", "🥈 Runner-up", "🥉 Third"]
437
+
438
+ for i, (caption, score) in enumerate(captions):
439
+ label = rank_labels[i] if i < len(rank_labels) else f"#{i + 1}"
440
+ st.markdown(f"""
441
+ <div class="caption-card">
442
+ <div class="caption-rank">{label}</div>
443
+ <div class="caption-text">{caption}</div>
444
+ <div class="score-badge">Confidence: {score:.2%}</div>
445
+ </div>
446
+ """, unsafe_allow_html=True)
447
+
448
+
449
+ def display_bleu_scores(bleu_data: dict, backbone: str):
450
+ """Display BLEU scores as metric cards."""
451
+ if not bleu_data or backbone not in bleu_data:
452
+ st.info("BLEU scores not available. Run evaluation first.")
453
+ return
454
+
455
+ scores = bleu_data[backbone]
456
+ cols = st.columns(4)
457
+ for i, (metric, value) in enumerate(scores.items()):
458
+ with cols[i]:
459
+ st.markdown(f"""
460
+ <div class="metric-card">
461
+ <div class="metric-value">{value:.4f}</div>
462
+ <div class="metric-label">{metric}</div>
463
+ </div>
464
+ """, unsafe_allow_html=True)
465
+
466
+
467
+ # ──────────────────────────────────────────────
468
+ # Sidebar
469
+ # ──────────────────────────────────────────────
470
+ with st.sidebar:
471
+ st.markdown("## ⚙️ Settings")
472
+
473
+ backbone = st.radio(
474
+ "VGG Backbone Mode",
475
+ ["ensemble", "vgg19", "vgg16"],
476
+ index=0,
477
+ format_func=lambda x: (
478
+ "ENSEMBLE (VGG16 + VGG19)" if x == "ensemble" else x.upper()
479
+ ),
480
+ help="Use both backbones together for stronger, more stable captions."
481
+ )
482
+
483
+ st.divider()
484
+
485
+ demo_mode = st.toggle("🎮 Demo Mode", value=False,
486
+ help="Use preloaded sample images from Flickr8K")
487
+ caption_mode = st.selectbox(
488
+ "Caption Engine",
489
+ ["VGG Only (Project)", "Hybrid (VGG16 + VGG 19)"],
490
+ index=0,
491
+ help="Keep VGG-only for project purity, or use BLIP modes for class demo quality."
492
+ )
493
+
494
+ st.divider()
495
+
496
+ # ── Model Info Panel ──
497
+ with st.expander("ℹ️ Model Info", expanded=False):
498
+ st.markdown("""
499
+ **CaptionIQ** uses a CNN-LSTM architecture:
500
+
501
+ **1. Feature Extraction (CNN)**
502
+ - Pre-trained VGG16/VGG19 on ImageNet
503
+ - Extracts spatial feature map from `block5_pool` (49 x 512)
504
+ - Captures high-level visual semantics
505
+
506
+ **2. Caption Decoder (Attention + LSTM)**
507
+ - Bahdanau attention over image regions
508
+ - Word embedding layer (256-dim)
509
+ - LSTM with 512 hidden units
510
+ - Dropout (0.3) for regularization
511
+ - Softmax output over vocabulary
512
+
513
+ **3. Inference**
514
+ - Ensemble beam search (VGG16+VGG19) with repetition controls
515
+ - Length-aware caption scoring
516
+ - Normalized confidence across final candidates
517
+
518
+ **Dataset**: Flickr8K (8000 images, 5 captions each)
519
+ """)
520
+
521
+ # ── BLEU Scores Panel ──
522
+ bleu_data = get_bleu_results()
523
+ if bleu_data:
524
+ with st.expander("📊 BLEU Evaluation", expanded=False):
525
+ if backbone in bleu_data:
526
+ display_bleu_scores(bleu_data, backbone)
527
+ elif backbone == "ensemble":
528
+ st.markdown("**Ensemble mode uses both models at inference time.**")
529
+ cols = st.columns(2)
530
+ with cols[0]:
531
+ if "vgg16" in bleu_data:
532
+ st.metric("VGG16 BLEU-4", f"{bleu_data['vgg16'].get('BLEU-4', 0):.4f}")
533
+ with cols[1]:
534
+ if "vgg19" in bleu_data:
535
+ st.metric("VGG19 BLEU-4", f"{bleu_data['vgg19'].get('BLEU-4', 0):.4f}")
536
+
537
+ if "vgg16" in bleu_data and "vgg19" in bleu_data:
538
+ st.markdown("---")
539
+ st.markdown("**VGG16 vs VGG19 Comparison**")
540
+ import pandas as pd
541
+ df = pd.DataFrame({
542
+ "VGG16": bleu_data["vgg16"],
543
+ "VGG19": bleu_data["vgg19"],
544
+ }).T
545
+ st.dataframe(df, use_container_width=True)
546
+
547
+ # ──────────────────────────────────────────────
548
+ # Main content
549
+ # ──────────────────────────────────────────────
550
+ st.markdown('<h1 class="hero-title">🧠 CaptionIQ</h1>', unsafe_allow_html=True)
551
+ st.markdown(
552
+ '<p class="hero-subtitle">AI-Powered Image Captioning with VGG + LSTM</p>',
553
+ unsafe_allow_html=True
554
+ )
555
+
556
+ # Check backend engine readiness
557
+ tokenizer = get_tokenizer()
558
+ engine = get_caption_engine()
559
+ ready, ready_error = engine.is_ready(backbone)
560
+ if (tokenizer is None) or (not ready):
561
+ st.error(
562
+ "⚠️ Caption backend is not ready.\n\n"
563
+ f"{ready_error or 'Tokenizer not found.'}\n\n"
564
+ "```bash\n"
565
+ "python src/train.py --backbone both --resume\n"
566
+ "```"
567
+ )
568
+ st.stop()
569
+
570
+ # ── Image input ──
571
+ image = None
572
+ image_id = None
573
+
574
+ if demo_mode:
575
+ demo_images = get_demo_images()
576
+ if not demo_images:
577
+ st.warning("No demo images found. Upload an image instead.")
578
+ else:
579
+ st.markdown("### 🖼️ Select a Demo Image")
580
+ cols = st.columns(5)
581
+ for i, img_name in enumerate(demo_images):
582
+ img_path = os.path.join(FLICKR_IMAGES_DIR, img_name)
583
+ with cols[i]:
584
+ pil_img = Image.open(img_path)
585
+ st.image(pil_img, use_container_width=True)
586
+ if st.button(f"Select", key=f"demo_{i}"):
587
+ image = pil_img
588
+ image_id = img_name
589
+ else:
590
+ st.markdown("### 📤 Upload an Image")
591
+ uploaded_file = st.file_uploader(
592
+ "Drag and drop an image here",
593
+ type=["jpg", "jpeg", "png"],
594
+ help="Supported formats: JPG, JPEG, PNG"
595
+ )
596
+ if uploaded_file:
597
+ image = Image.open(uploaded_file)
598
+ image_id = uploaded_file.name
599
+
600
+ # ── Generate captions ──
601
+ if image is not None:
602
+ col1, col2 = st.columns([1, 1])
603
+
604
+ with col1:
605
+ st.markdown("### 🖼️ Input Image")
606
+ st.image(image, use_container_width=True)
607
+
608
+ # Show reference captions if available (demo mode)
609
+ if image_id:
610
+ all_caps = get_all_captions()
611
+ if image_id in all_caps:
612
+ with st.expander("📝 Reference Captions"):
613
+ for cap in all_caps[image_id]:
614
+ clean_cap = clean_caption_text(cap)
615
+ st.markdown(f"- {clean_cap}")
616
+
617
+ with col2:
618
+ st.markdown("### 💬 Generated Captions")
619
+
620
+ with st.spinner("Extracting features & generating captions..."):
621
+ mode_map = {
622
+ "VGG Only (Project)": "vgg_only",
623
+ "Hybrid (VGG + BLIP)": "hybrid",
624
+ "BLIP Only (Demo)": "blip_only",
625
+ }
626
+ result = engine.generate_caption(
627
+ image=image,
628
+ caption_mode=mode_map.get(caption_mode, "vgg_only"),
629
+ backbone_mode=backbone,
630
+ beam_width=BEAM_WIDTH,
631
+ )
632
+ captions_result = result["candidates"]
633
+ model_used = result["model_used"]
634
+
635
+ if captions_result:
636
+ display_captions(captions_result)
637
+ st.caption(f"Model used: {model_used}")
638
+
639
+ # ── Download button ──
640
+ caption_text = "\n".join(
641
+ [f"#{i+1}: {cap}" for i, (cap, _) in enumerate(captions_result)]
642
+ )
643
+ st.download_button(
644
+ "📥 Download Captions (.txt)",
645
+ data=caption_text,
646
+ file_name=f"captions_{backbone}.txt",
647
+ mime="text/plain",
648
+ )
649
+
650
+ # ── BLEU scores per generation (if reference available) ──
651
+ if image_id:
652
+ all_caps = get_all_captions()
653
+ if image_id in all_caps:
654
+ from nltk.translate.bleu_score import sentence_bleu, SmoothingFunction
655
+ import nltk
656
+ nltk.download("punkt", quiet=True)
657
+ nltk.download("punkt_tab", quiet=True)
658
+
659
+ refs = [
660
+ cap.replace(START_TOKEN, "").replace(END_TOKEN, "").strip().split()
661
+ for cap in all_caps[image_id]
662
+ ]
663
+
664
+ st.markdown("### 📊 Per-Caption BLEU Scores")
665
+ smooth = SmoothingFunction().method1
666
+ best_caption = captions_result[0][0]
667
+ hyp = best_caption.split()
668
+
669
+ bleu_cols = st.columns(4)
670
+ for n in range(1, 5):
671
+ weights = tuple([1.0/n]*n + [0.0]*(4-n))
672
+ score = sentence_bleu(refs, hyp, weights=weights,
673
+ smoothing_function=smooth)
674
+ with bleu_cols[n-1]:
675
+ st.metric(f"BLEU-{n}", f"{score:.4f}")
676
+ else:
677
+ st.warning("Could not generate captions. Please try a different image.")
678
+
679
+ # ── Footer ──
680
+ st.markdown("---")
681
+ st.markdown(
682
+ "<p style='text-align: center; color: #4a5568; font-size: 0.85rem;'>"
683
+ "CaptionIQ — Built with VGG + LSTM | Flickr8K Dataset | Streamlit"
684
+ "</p>",
685
+ unsafe_allow_html=True,
686
+ )
data/.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/Untitled0.ipynb ADDED
@@ -0,0 +1,542 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nbformat": 4,
3
+ "nbformat_minor": 0,
4
+ "metadata": {
5
+ "colab": {
6
+ "provenance": [],
7
+ "gpuType": "T4"
8
+ },
9
+ "kernelspec": {
10
+ "name": "python3",
11
+ "display_name": "Python 3"
12
+ },
13
+ "language_info": {
14
+ "name": "python"
15
+ },
16
+ "accelerator": "GPU"
17
+ },
18
+ "cells": [
19
+ {
20
+ "cell_type": "code",
21
+ "execution_count": 1,
22
+ "metadata": {
23
+ "id": "as_4H1mDhLFC"
24
+ },
25
+ "outputs": [],
26
+ "source": [
27
+ "!cp /content/drive/MyDrive/computer_vision.zip /content/\n",
28
+ "\n",
29
+ "# Unzip\n",
30
+ "!unzip -q /content/computer_vision.zip -d /content/"
31
+ ]
32
+ },
33
+ {
34
+ "cell_type": "code",
35
+ "source": [
36
+ "!ls /content/computer\\ vision/\n"
37
+ ],
38
+ "metadata": {
39
+ "colab": {
40
+ "base_uri": "https://localhost:8080/"
41
+ },
42
+ "id": "SCEUrWQMhj0t",
43
+ "outputId": "ec9ee3ae-84d8-441b-8a85-8156eb4050d6"
44
+ },
45
+ "execution_count": 2,
46
+ "outputs": [
47
+ {
48
+ "output_type": "stream",
49
+ "name": "stdout",
50
+ "text": [
51
+ "app.py\tdata models outputs README.md requirements.txt src\n"
52
+ ]
53
+ }
54
+ ]
55
+ },
56
+ {
57
+ "cell_type": "code",
58
+ "source": [
59
+ "!python3 \"/content/computer vision/src/extract_features.py\""
60
+ ],
61
+ "metadata": {
62
+ "colab": {
63
+ "base_uri": "https://localhost:8080/"
64
+ },
65
+ "id": "K2PK6TtMi7Z0",
66
+ "outputId": "33977dd5-7661-4391-f714-6d821921f389"
67
+ },
68
+ "execution_count": 4,
69
+ "outputs": [
70
+ {
71
+ "output_type": "stream",
72
+ "name": "stdout",
73
+ "text": [
74
+ "2026-04-07 23:31:50.856164: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:467] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n",
75
+ "WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n",
76
+ "E0000 00:00:1775604710.889407 8272 cuda_dnn.cc:8579] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n",
77
+ "E0000 00:00:1775604710.900458 8272 cuda_blas.cc:1407] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n",
78
+ "W0000 00:00:1775604710.925422 8272 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n",
79
+ "W0000 00:00:1775604710.925457 8272 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n",
80
+ "W0000 00:00:1775604710.925464 8272 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n",
81
+ "W0000 00:00:1775604710.925471 8272 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n",
82
+ "2026-04-07 23:31:50.932253: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n",
83
+ "To enable the following instructions: AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
84
+ "\n",
85
+ "============================================================\n",
86
+ " Extracting VGG16 features\n",
87
+ "============================================================\n",
88
+ "2026-04-07 23:31:58.332730: W tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:47] Overriding orig_value setting because the TF_FORCE_GPU_ALLOW_GROWTH environment variable is set. Original config value was 0.\n",
89
+ "I0000 00:00:1775604718.334255 8272 gpu_device.cc:2019] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 13757 MB memory: -> device: 0, name: Tesla T4, pci bus id: 0000:00:04.0, compute capability: 7.5\n",
90
+ "Downloading data from https://storage.googleapis.com/tensorflow/keras-applications/vgg16/vgg16_weights_tf_dim_ordering_tf_kernels.h5\n",
91
+ "\u001b[1m553467096/553467096\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m2s\u001b[0m 0us/step\n",
92
+ "2026-04-07 23:32:02.987602: W external/local_xla/xla/tsl/framework/cpu_allocator_impl.cc:83] Allocation of 411041792 exceeds 10% of free system memory.\n",
93
+ "2026-04-07 23:32:03.450495: W external/local_xla/xla/tsl/framework/cpu_allocator_impl.cc:83] Allocation of 67108864 exceeds 10% of free system memory.\n",
94
+ "\n",
95
+ "VGG16 feature extractor loaded\n",
96
+ " Output shape: (None, 7, 7, 512) (spatial features)\n",
97
+ "Extracting features for 8091 images...\n",
98
+ "Extracting: 0% 0/8091 [00:00<?, ?it/s]WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n",
99
+ "I0000 00:00:1775604723.832566 8324 service.cc:152] XLA service 0x7b98bc008340 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:\n",
100
+ "I0000 00:00:1775604723.832629 8324 service.cc:160] StreamExecutor device (0): Tesla T4, Compute Capability 7.5\n",
101
+ "2026-04-07 23:32:03.893227: I tensorflow/compiler/mlir/tensorflow/utils/dump_mlir_util.cc:269] disabling MLIR crash reproducer, set env var `MLIR_CRASH_REPRODUCER_DIRECTORY` to enable.\n",
102
+ "I0000 00:00:1775604724.047231 8324 cuda_dnn.cc:529] Loaded cuDNN version 91002\n",
103
+ "2026-04-07 23:32:06.069926: I external/local_xla/xla/service/gpu/autotuning/conv_algorithm_picker.cc:549] Omitted potentially buggy algorithm eng14{k25=2} for conv %cudnn-conv-bias-activation.46 = (f32[1,512,28,28]{3,2,1,0}, u8[0]{0}) custom-call(f32[1,256,28,28]{3,2,1,0} %bitcast.498, f32[512,256,3,3]{3,2,1,0} %bitcast.505, f32[512]{0} %bitcast.507), window={size=3x3 pad=1_1x1_1}, dim_labels=bf01_oi01->bf01, custom_call_target=\"__cudnn$convBiasActivationForward\", metadata={op_type=\"Conv2D\" op_name=\"functional_1/block4_conv1_1/convolution\" source_file=\"/usr/local/lib/python3.12/dist-packages/tensorflow/python/framework/ops.py\" source_line=1200}, backend_config={\"operation_queue_id\":\"0\",\"wait_on_operation_queues\":[],\"cudnn_conv_backend_config\":{\"conv_result_scale\":1,\"activation_mode\":\"kRelu\",\"side_input_scale\":0,\"leakyrelu_alpha\":0},\"force_earliest_schedule\":false}\n",
104
+ "2026-04-07 23:32:06.169445: I external/local_xla/xla/service/gpu/autotuning/conv_algorithm_picker.cc:549] Omitted potentially buggy algorithm eng14{k25=2} for conv %cudnn-conv-bias-activation.47 = (f32[1,512,28,28]{3,2,1,0}, u8[0]{0}) custom-call(f32[1,512,28,28]{3,2,1,0} %bitcast.512, f32[512,512,3,3]{3,2,1,0} %bitcast.519, f32[512]{0} %bitcast.521), window={size=3x3 pad=1_1x1_1}, dim_labels=bf01_oi01->bf01, custom_call_target=\"__cudnn$convBiasActivationForward\", metadata={op_type=\"Conv2D\" op_name=\"functional_1/block4_conv2_1/convolution\" source_file=\"/usr/local/lib/python3.12/dist-packages/tensorflow/python/framework/ops.py\" source_line=1200}, backend_config={\"operation_queue_id\":\"0\",\"wait_on_operation_queues\":[],\"cudnn_conv_backend_config\":{\"conv_result_scale\":1,\"activation_mode\":\"kRelu\",\"side_input_scale\":0,\"leakyrelu_alpha\":0},\"force_earliest_schedule\":false}\n",
105
+ "2026-04-07 23:32:06.307911: I external/local_xla/xla/service/gpu/autotuning/conv_algorithm_picker.cc:549] Omitted potentially buggy algorithm eng14{k25=2} for conv %cudnn-conv-bias-activation.49 = (f32[1,512,14,14]{3,2,1,0}, u8[0]{0}) custom-call(f32[1,512,14,14]{3,2,1,0} %bitcast.541, f32[512,512,3,3]{3,2,1,0} %bitcast.548, f32[512]{0} %bitcast.550), window={size=3x3 pad=1_1x1_1}, dim_labels=bf01_oi01->bf01, custom_call_target=\"__cudnn$convBiasActivationForward\", metadata={op_type=\"Conv2D\" op_name=\"functional_1/block5_conv1_1/convolution\" source_file=\"/usr/local/lib/python3.12/dist-packages/tensorflow/python/framework/ops.py\" source_line=1200}, backend_config={\"operation_queue_id\":\"0\",\"wait_on_operation_queues\":[],\"cudnn_conv_backend_config\":{\"conv_result_scale\":1,\"activation_mode\":\"kRelu\",\"side_input_scale\":0,\"leakyrelu_alpha\":0},\"force_earliest_schedule\":false}\n",
106
+ "I0000 00:00:1775604726.888658 8324 device_compiler.h:188] Compiled cluster using XLA! This line is logged at most once for the lifetime of the process.\n",
107
+ "Extracting: 100% 8091/8091 [12:32<00:00, 10.76it/s]\n",
108
+ "Extracted features for 8091 images\n",
109
+ "Features saved to: /content/computer vision/data/vgg16_features.pkl (774.9 MB)\n",
110
+ "\n",
111
+ "============================================================\n",
112
+ " Extracting VGG19 features\n",
113
+ "============================================================\n",
114
+ "Downloading data from https://storage.googleapis.com/tensorflow/keras-applications/vgg19/vgg19_weights_tf_dim_ordering_tf_kernels.h5\n",
115
+ "\u001b[1m574710816/574710816\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m5s\u001b[0m 0us/step\n",
116
+ "2026-04-07 23:44:47.428611: W external/local_xla/xla/tsl/framework/cpu_allocator_impl.cc:83] Allocation of 411041792 exceeds 10% of free system memory.\n",
117
+ "2026-04-07 23:44:47.933276: W external/local_xla/xla/tsl/framework/cpu_allocator_impl.cc:83] Allocation of 67108864 exceeds 10% of free system memory.\n",
118
+ "\n",
119
+ "VGG19 feature extractor loaded\n",
120
+ " Output shape: (None, 7, 7, 512) (spatial features)\n",
121
+ "Extracting features for 8091 images...\n",
122
+ "Extracting: 100% 8091/8091 [13:11<00:00, 10.22it/s]\n",
123
+ "Extracted features for 8091 images\n",
124
+ "Features saved to: /content/computer vision/data/vgg19_features.pkl (774.9 MB)\n",
125
+ "\n",
126
+ "✓ Feature extraction complete!\n"
127
+ ]
128
+ }
129
+ ]
130
+ },
131
+ {
132
+ "cell_type": "code",
133
+ "source": [
134
+ "!python3 \"/content/computer vision/src/train.py\" --backbone vgg16"
135
+ ],
136
+ "metadata": {
137
+ "colab": {
138
+ "base_uri": "https://localhost:8080/"
139
+ },
140
+ "id": "Nq-2hthWjOwT",
141
+ "outputId": "af65bdce-3088-4f99-cc92-844bd3502a7f"
142
+ },
143
+ "execution_count": 6,
144
+ "outputs": [
145
+ {
146
+ "output_type": "stream",
147
+ "name": "stdout",
148
+ "text": [
149
+ "2026-04-08 00:08:11.956246: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:467] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n",
150
+ "WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n",
151
+ "E0000 00:00:1775606891.978990 146966 cuda_dnn.cc:8579] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n",
152
+ "E0000 00:00:1775606891.986034 146966 cuda_blas.cc:1407] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n",
153
+ "W0000 00:00:1775606892.002800 146966 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n",
154
+ "W0000 00:00:1775606892.002848 146966 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n",
155
+ "W0000 00:00:1775606892.002852 146966 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n",
156
+ "W0000 00:00:1775606892.002866 146966 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n",
157
+ "2026-04-08 00:08:12.007976: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n",
158
+ "To enable the following instructions: AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
159
+ "============================================================\n",
160
+ " CaptionIQ — Training with VGG16\n",
161
+ "============================================================\n",
162
+ "\n",
163
+ "Loading data...\n",
164
+ " Vocabulary size: 7656\n",
165
+ " Train images: 6000\n",
166
+ " Val images: 1000\n",
167
+ " Max caption length: 37\n",
168
+ "\n",
169
+ "Building model...\n",
170
+ "2026-04-08 00:08:21.446157: W tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:47] Overriding orig_value setting because the TF_FORCE_GPU_ALLOW_GROWTH environment variable is set. Original config value was 0.\n",
171
+ "I0000 00:00:1775606901.447651 146966 gpu_device.cc:2019] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 13757 MB memory: -> device: 0, name: Tesla T4, pci bus id: 0000:00:04.0, compute capability: 7.5\n",
172
+ "\u001b[1mModel: \"CaptionIQ\"\u001b[0m\n",
173
+ "┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┓\n",
174
+ "┃\u001b[1m \u001b[0m\u001b[1mLayer (type) \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mOutput Shape \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1m Param #\u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mConnected to \u001b[0m\u001b[1m \u001b[0m┃\n",
175
+ "┡━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━┩\n",
176
+ "│ caption_input │ (\u001b[96mNone\u001b[0m, \u001b[32m37\u001b[0m) │ \u001b[32m0\u001b[0m │ - │\n",
177
+ "│ (\u001b[94mInputLayer\u001b[0m) │ │ │ │\n",
178
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
179
+ "│ caption_embedding │ (\u001b[96mNone\u001b[0m, \u001b[32m37\u001b[0m, \u001b[32m256\u001b[0m) �� \u001b[32m1,959,936\u001b[0m │ caption_input[\u001b[32m0\u001b[0m]… │\n",
180
+ "│ (\u001b[94mEmbedding\u001b[0m) │ │ │ │\n",
181
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
182
+ "│ caption_dropout │ (\u001b[96mNone\u001b[0m, \u001b[32m37\u001b[0m, \u001b[32m256\u001b[0m) │ \u001b[32m0\u001b[0m │ caption_embeddin… │\n",
183
+ "│ (\u001b[94mDropout\u001b[0m) │ │ │ │\n",
184
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
185
+ "│ not_equal │ (\u001b[96mNone\u001b[0m, \u001b[32m37\u001b[0m) │ \u001b[32m0\u001b[0m │ caption_input[\u001b[32m0\u001b[0m]… │\n",
186
+ "│ (\u001b[94mNotEqual\u001b[0m) │ │ │ │\n",
187
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
188
+ "│ image_input │ (\u001b[96mNone\u001b[0m, \u001b[32m49\u001b[0m, \u001b[32m512\u001b[0m) │ \u001b[32m0\u001b[0m │ - │\n",
189
+ "│ (\u001b[94mInputLayer\u001b[0m) │ │ │ │\n",
190
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
191
+ "│ caption_lstm (\u001b[94mLSTM\u001b[0m) │ (\u001b[96mNone\u001b[0m, \u001b[32m512\u001b[0m) │ \u001b[32m1,574,912\u001b[0m │ caption_dropout[\u001b[32m…\u001b[0m │\n",
192
+ "│ │ │ │ not_equal[\u001b[32m0\u001b[0m][\u001b[32m0\u001b[0m] │\n",
193
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
194
+ "│ attention │ (\u001b[96mNone\u001b[0m, \u001b[32m512\u001b[0m) │ \u001b[32m262,913\u001b[0m │ image_input[\u001b[32m0\u001b[0m][\u001b[32m0\u001b[0m… │\n",
195
+ "│ (\u001b[94mBahdanauAttention\u001b[0m) │ │ │ caption_lstm[\u001b[32m0\u001b[0m][\u001b[32m…\u001b[0m │\n",
196
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
197
+ "│ merge (\u001b[94mConcatenate\u001b[0m) │ (\u001b[96mNone\u001b[0m, \u001b[32m1024\u001b[0m) │ \u001b[32m0\u001b[0m │ attention[\u001b[32m0\u001b[0m][\u001b[32m0\u001b[0m], │\n",
198
+ "│ │ │ │ caption_lstm[\u001b[32m0\u001b[0m][\u001b[32m…\u001b[0m │\n",
199
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
200
+ "│ dense_relu (\u001b[94mDense\u001b[0m) │ (\u001b[96mNone\u001b[0m, \u001b[32m512\u001b[0m) │ \u001b[32m524,800\u001b[0m │ merge[\u001b[32m0\u001b[0m][\u001b[32m0\u001b[0m] │\n",
201
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
202
+ "│ dense_dropout │ (\u001b[96mNone\u001b[0m, \u001b[32m512\u001b[0m) │ \u001b[32m0\u001b[0m │ dense_relu[\u001b[32m0\u001b[0m][\u001b[32m0\u001b[0m] │\n",
203
+ "│ (\u001b[94mDropout\u001b[0m) │ │ │ │\n",
204
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
205
+ "│ output (\u001b[94mDense\u001b[0m) │ (\u001b[96mNone\u001b[0m, \u001b[32m7656\u001b[0m) │ \u001b[32m3,927,528\u001b[0m �� dense_dropout[\u001b[32m0\u001b[0m]… │\n",
206
+ "└─────────────────────┴───────────────────┴────────────┴───────────────────┘\n",
207
+ "\u001b[1m Total params: \u001b[0m\u001b[32m8,250,089\u001b[0m (31.47 MB)\n",
208
+ "\u001b[1m Trainable params: \u001b[0m\u001b[32m8,250,089\u001b[0m (31.47 MB)\n",
209
+ "\u001b[1m Non-trainable params: \u001b[0m\u001b[32m0\u001b[0m (0.00 B)\n",
210
+ " Train steps/epoch: 11051\n",
211
+ " Val steps/epoch: 1816\n",
212
+ "\n",
213
+ "Training for 50 epochs...\n",
214
+ "Epoch 1/50\n",
215
+ "I0000 00:00:1775606908.438727 147026 cuda_dnn.cc:529] Loaded cuDNN version 91002\n",
216
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 15ms/step - loss: 5.3842\n",
217
+ "Epoch 1: val_loss improved from None to 4.49467, saving model to /content/computer vision/models/model_vgg16.h5\n",
218
+ "WARNING:absl:You are saving your model as an HDF5 file via `model.save()` or `keras.saving.save_model(model)`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')` or `keras.saving.save_model(model, 'my_model.keras')`. \n",
219
+ "\n",
220
+ "Epoch 1: finished saving model to /content/computer vision/models/model_vgg16.h5\n",
221
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m188s\u001b[0m 17ms/step - loss: 5.0973 - val_loss: 4.4947 - learning_rate: 0.0010\n",
222
+ "Epoch 2/50\n",
223
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 15ms/step - loss: 4.6810\n",
224
+ "Epoch 2: val_loss improved from 4.49467 to 4.46008, saving model to /content/computer vision/models/model_vgg16.h5\n",
225
+ "WARNING:absl:You are saving your model as an HDF5 file via `model.save()` or `keras.saving.save_model(model)`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')` or `keras.saving.save_model(model, 'my_model.keras')`. \n",
226
+ "\n",
227
+ "Epoch 2: finished saving model to /content/computer vision/models/model_vgg16.h5\n",
228
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m202s\u001b[0m 18ms/step - loss: 4.6903 - val_loss: 4.4601 - learning_rate: 0.0010\n",
229
+ "Epoch 3/50\n",
230
+ "\u001b[1m11049/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 15ms/step - loss: 4.6217\n",
231
+ "Epoch 3: val_loss did not improve from 4.46008\n",
232
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m182s\u001b[0m 16ms/step - loss: 4.6642 - val_loss: 4.5293 - learning_rate: 0.0010\n",
233
+ "Epoch 4/50\n",
234
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 15ms/step - loss: 4.6129\n",
235
+ "Epoch 4: val_loss did not improve from 4.46008\n",
236
+ "\n",
237
+ "Epoch 4: ReduceLROnPlateau reducing learning rate to 0.0005000000237487257.\n",
238
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m203s\u001b[0m 18ms/step - loss: 4.6809 - val_loss: 4.6666 - learning_rate: 0.0010\n",
239
+ "Epoch 5/50\n",
240
+ "\u001b[1m11049/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.5777\n",
241
+ "Epoch 5: val_loss improved from 4.46008 to 4.41211, saving model to /content/computer vision/models/model_vgg16.h5\n",
242
+ "WARNING:absl:You are saving your model as an HDF5 file via `model.save()` or `keras.saving.save_model(model)`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')` or `keras.saving.save_model(model, 'my_model.keras')`. \n",
243
+ "\n",
244
+ "Epoch 5: finished saving model to /content/computer vision/models/model_vgg16.h5\n",
245
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m185s\u001b[0m 17ms/step - loss: 4.5544 - val_loss: 4.4121 - learning_rate: 5.0000e-04\n",
246
+ "Epoch 6/50\n",
247
+ "\u001b[1m11050/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 15ms/step - loss: 4.4628\n",
248
+ "Epoch 6: val_loss did not improve from 4.41211\n",
249
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m182s\u001b[0m 16ms/step - loss: 4.4939 - val_loss: 4.5103 - learning_rate: 5.0000e-04\n",
250
+ "Epoch 7/50\n",
251
+ "\u001b[1m11050/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 15ms/step - loss: 4.4421\n",
252
+ "Epoch 7: val_loss did not improve from 4.41211\n",
253
+ "\n",
254
+ "Epoch 7: ReduceLROnPlateau reducing learning rate to 0.0002500000118743628.\n",
255
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m183s\u001b[0m 17ms/step - loss: 4.4728 - val_loss: 4.5142 - learning_rate: 5.0000e-04\n",
256
+ "Epoch 8/50\n",
257
+ "\u001b[1m11049/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 15ms/step - loss: 4.3857\n",
258
+ "Epoch 8: val_loss did not improve from 4.41211\n",
259
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m182s\u001b[0m 16ms/step - loss: 4.3858 - val_loss: 4.4318 - learning_rate: 2.5000e-04\n",
260
+ "Epoch 9/50\n",
261
+ "\u001b[1m11048/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 15ms/step - loss: 4.3388\n",
262
+ "Epoch 9: val_loss improved from 4.41211 to 4.38911, saving model to /content/computer vision/models/model_vgg16.h5\n",
263
+ "WARNING:absl:You are saving your model as an HDF5 file via `model.save()` or `keras.saving.save_model(model)`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')` or `keras.saving.save_model(model, 'my_model.keras')`. \n",
264
+ "\n",
265
+ "Epoch 9: finished saving model to /content/computer vision/models/model_vgg16.h5\n",
266
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m183s\u001b[0m 17ms/step - loss: 4.3401 - val_loss: 4.3891 - learning_rate: 2.5000e-04\n",
267
+ "Epoch 10/50\n",
268
+ "\u001b[1m11050/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 15ms/step - loss: 4.2915\n",
269
+ "Epoch 10: val_loss did not improve from 4.38911\n",
270
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m184s\u001b[0m 17ms/step - loss: 4.3154 - val_loss: 4.3920 - learning_rate: 2.5000e-04\n",
271
+ "Epoch 11/50\n",
272
+ "\u001b[1m11049/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.2887\n",
273
+ "Epoch 11: val_loss improved from 4.38911 to 4.38810, saving model to /content/computer vision/models/model_vgg16.h5\n",
274
+ "WARNING:absl:You are saving your model as an HDF5 file via `model.save()` or `keras.saving.save_model(model)`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')` or `keras.saving.save_model(model, 'my_model.keras')`. \n",
275
+ "\n",
276
+ "Epoch 11: finished saving model to /content/computer vision/models/model_vgg16.h5\n",
277
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m186s\u001b[0m 17ms/step - loss: 4.2976 - val_loss: 4.3881 - learning_rate: 2.5000e-04\n",
278
+ "Epoch 12/50\n",
279
+ "\u001b[1m11050/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.2819\n",
280
+ "Epoch 12: val_loss did not improve from 4.38810\n",
281
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m202s\u001b[0m 18ms/step - loss: 4.2877 - val_loss: 4.4457 - learning_rate: 2.5000e-04\n",
282
+ "Epoch 13/50\n",
283
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.2826\n",
284
+ "Epoch 13: val_loss did not improve from 4.38810\n",
285
+ "\n",
286
+ "Epoch 13: ReduceLROnPlateau reducing learning rate to 0.0001250000059371814.\n",
287
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m202s\u001b[0m 18ms/step - loss: 4.2827 - val_loss: 4.4544 - learning_rate: 2.5000e-04\n",
288
+ "Epoch 14/50\n",
289
+ "\u001b[1m11050/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.2194\n",
290
+ "Epoch 14: val_loss did not improve from 4.38810\n",
291
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m194s\u001b[0m 18ms/step - loss: 4.2126 - val_loss: 4.4763 - learning_rate: 1.2500e-04\n",
292
+ "Epoch 15/50\n",
293
+ "\u001b[1m11050/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.1832\n",
294
+ "Epoch 15: val_loss did not improve from 4.38810\n",
295
+ "\n",
296
+ "Epoch 15: ReduceLROnPlateau reducing learning rate to 6.25000029685907e-05.\n",
297
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m196s\u001b[0m 18ms/step - loss: 4.1867 - val_loss: 4.4698 - learning_rate: 1.2500e-04\n",
298
+ "Epoch 16/50\n",
299
+ "\u001b[1m11050/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.1447\n",
300
+ "Epoch 16: val_loss did not improve from 4.38810\n",
301
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m192s\u001b[0m 17ms/step - loss: 4.1490 - val_loss: 4.4708 - learning_rate: 6.2500e-05\n",
302
+ "Epoch 16: early stopping\n",
303
+ "Restoring model weights from the end of the best epoch: 11.\n",
304
+ "WARNING:absl:You are saving your model as an HDF5 file via `model.save()` or `keras.saving.save_model(model)`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')` or `keras.saving.save_model(model, 'my_model.keras')`. \n",
305
+ "\n",
306
+ "Model saved to: /content/computer vision/models/model_vgg16.h5\n",
307
+ "Loss plot saved to: /content/computer vision/outputs/loss_vgg16.png\n",
308
+ "\n",
309
+ "✓ Training complete!\n"
310
+ ]
311
+ }
312
+ ]
313
+ },
314
+ {
315
+ "cell_type": "code",
316
+ "source": [
317
+ "!python3 \"/content/computer vision/src/train.py\" --backbone vgg19\n"
318
+ ],
319
+ "metadata": {
320
+ "colab": {
321
+ "base_uri": "https://localhost:8080/"
322
+ },
323
+ "id": "Cc6_3oTlqcZA",
324
+ "outputId": "12e18e9a-a802-40f1-b327-f4c130e8b89f"
325
+ },
326
+ "execution_count": 7,
327
+ "outputs": [
328
+ {
329
+ "output_type": "stream",
330
+ "name": "stdout",
331
+ "text": [
332
+ "2026-04-08 01:40:09.091223: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:467] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n",
333
+ "WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n",
334
+ "E0000 00:00:1775612409.113453 169919 cuda_dnn.cc:8579] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n",
335
+ "E0000 00:00:1775612409.120423 169919 cuda_blas.cc:1407] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n",
336
+ "W0000 00:00:1775612409.137250 169919 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n",
337
+ "W0000 00:00:1775612409.137293 169919 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n",
338
+ "W0000 00:00:1775612409.137298 169919 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n",
339
+ "W0000 00:00:1775612409.137301 169919 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n",
340
+ "2026-04-08 01:40:09.141870: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n",
341
+ "To enable the following instructions: AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
342
+ "============================================================\n",
343
+ " CaptionIQ — Training with VGG19\n",
344
+ "============================================================\n",
345
+ "\n",
346
+ "Loading data...\n",
347
+ " Vocabulary size: 7656\n",
348
+ " Train images: 6000\n",
349
+ " Val images: 1000\n",
350
+ " Max caption length: 37\n",
351
+ "\n",
352
+ "Building model...\n",
353
+ "2026-04-08 01:40:18.516807: W tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:47] Overriding orig_value setting because the TF_FORCE_GPU_ALLOW_GROWTH environment variable is set. Original config value was 0.\n",
354
+ "I0000 00:00:1775612418.518264 169919 gpu_device.cc:2019] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 13757 MB memory: -> device: 0, name: Tesla T4, pci bus id: 0000:00:04.0, compute capability: 7.5\n",
355
+ "\u001b[1mModel: \"CaptionIQ\"\u001b[0m\n",
356
+ "┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┓\n",
357
+ "┃\u001b[1m \u001b[0m\u001b[1mLayer (type) \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mOutput Shape \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1m Param #\u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mConnected to \u001b[0m\u001b[1m \u001b[0m┃\n",
358
+ "┡━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━┩\n",
359
+ "│ caption_input │ (\u001b[96mNone\u001b[0m, \u001b[32m37\u001b[0m) │ \u001b[32m0\u001b[0m │ - │\n",
360
+ "│ (\u001b[94mInputLayer\u001b[0m) │ │ │ │\n",
361
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
362
+ "│ caption_embedding │ (\u001b[96mNone\u001b[0m, \u001b[32m37\u001b[0m, \u001b[32m256\u001b[0m) │ \u001b[32m1,959,936\u001b[0m │ caption_input[\u001b[32m0\u001b[0m]… │\n",
363
+ "│ (\u001b[94mEmbedding\u001b[0m) │ │ │ │\n",
364
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
365
+ "│ caption_dropout │ (\u001b[96mNone\u001b[0m, \u001b[32m37\u001b[0m, \u001b[32m256\u001b[0m) │ \u001b[32m0\u001b[0m │ caption_embeddin… │\n",
366
+ "│ (\u001b[94mDropout\u001b[0m) │ │ │ │\n",
367
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
368
+ "│ not_equal │ (\u001b[96mNone\u001b[0m, \u001b[32m37\u001b[0m) │ \u001b[32m0\u001b[0m │ caption_input[\u001b[32m0\u001b[0m]… │\n",
369
+ "│ (\u001b[94mNotEqual\u001b[0m) │ │ │ │\n",
370
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
371
+ "│ image_input │ (\u001b[96mNone\u001b[0m, \u001b[32m49\u001b[0m, \u001b[32m512\u001b[0m) │ \u001b[32m0\u001b[0m │ - │\n",
372
+ "│ (\u001b[94mInputLayer\u001b[0m) │ │ │ │\n",
373
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
374
+ "│ caption_lstm (\u001b[94mLSTM\u001b[0m) │ (\u001b[96mNone\u001b[0m, \u001b[32m512\u001b[0m) │ \u001b[32m1,574,912\u001b[0m │ caption_dropout[\u001b[32m…\u001b[0m │\n",
375
+ "│ │ │ │ not_equal[\u001b[32m0\u001b[0m][\u001b[32m0\u001b[0m] │\n",
376
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
377
+ "│ attention │ (\u001b[96mNone\u001b[0m, \u001b[32m512\u001b[0m) │ \u001b[32m262,913\u001b[0m │ image_input[\u001b[32m0\u001b[0m][\u001b[32m0\u001b[0m… │\n",
378
+ "│ (\u001b[94mBahdanauAttention\u001b[0m) │ │ │ caption_lstm[\u001b[32m0\u001b[0m][\u001b[32m…\u001b[0m │\n",
379
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
380
+ "│ merge (\u001b[94mConcatenate\u001b[0m) │ (\u001b[96mNone\u001b[0m, \u001b[32m1024\u001b[0m) │ \u001b[32m0\u001b[0m │ attention[\u001b[32m0\u001b[0m][\u001b[32m0\u001b[0m], │\n",
381
+ "│ │ │ │ caption_lstm[\u001b[32m0\u001b[0m][\u001b[32m…\u001b[0m │\n",
382
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
383
+ "│ dense_relu (\u001b[94mDense\u001b[0m) │ (\u001b[96mNone\u001b[0m, \u001b[32m512\u001b[0m) │ \u001b[32m524,800\u001b[0m │ merge[\u001b[32m0\u001b[0m][\u001b[32m0\u001b[0m] │\n",
384
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
385
+ "│ dense_dropout │ (\u001b[96mNone\u001b[0m, \u001b[32m512\u001b[0m) │ \u001b[32m0\u001b[0m │ dense_relu[\u001b[32m0\u001b[0m][\u001b[32m0\u001b[0m] │\n",
386
+ "│ (\u001b[94mDropout\u001b[0m) │ │ │ │\n",
387
+ "├─────────────────────┼───────────────────┼────────────┼───────────────────┤\n",
388
+ "│ output (\u001b[94mDense\u001b[0m) │ (\u001b[96mNone\u001b[0m, \u001b[32m7656\u001b[0m) │ \u001b[32m3,927,528\u001b[0m │ dense_dropout[\u001b[32m0\u001b[0m]… │\n",
389
+ "└─────────────────────┴───────────────────┴────────────┴───────────────────┘\n",
390
+ "\u001b[1m Total params: \u001b[0m\u001b[32m8,250,089\u001b[0m (31.47 MB)\n",
391
+ "\u001b[1m Trainable params: \u001b[0m\u001b[32m8,250,089\u001b[0m (31.47 MB)\n",
392
+ "\u001b[1m Non-trainable params: \u001b[0m\u001b[32m0\u001b[0m (0.00 B)\n",
393
+ " Train steps/epoch: 11051\n",
394
+ " Val steps/epoch: 1816\n",
395
+ "\n",
396
+ "Training for 50 epochs...\n",
397
+ "Epoch 1/50\n",
398
+ "I0000 00:00:1775612426.160821 169976 cuda_dnn.cc:529] Loaded cuDNN version 91002\n",
399
+ "\u001b[1m11048/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 5.4579\n",
400
+ "Epoch 1: val_loss improved from None to 4.57161, saving model to /content/computer vision/models/model_vgg19.h5\n",
401
+ "WARNING:absl:You are saving your model as an HDF5 file via `model.save()` or `keras.saving.save_model(model)`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')` or `keras.saving.save_model(model, 'my_model.keras')`. \n",
402
+ "\n",
403
+ "Epoch 1: finished saving model to /content/computer vision/models/model_vgg19.h5\n",
404
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m192s\u001b[0m 17ms/step - loss: 5.1972 - val_loss: 4.5716 - learning_rate: 0.0010\n",
405
+ "Epoch 2/50\n",
406
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.7530\n",
407
+ "Epoch 2: val_loss improved from 4.57161 to 4.46729, saving model to /content/computer vision/models/model_vgg19.h5\n",
408
+ "WARNING:absl:You are saving your model as an HDF5 file via `model.save()` or `keras.saving.save_model(model)`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')` or `keras.saving.save_model(model, 'my_model.keras')`. \n",
409
+ "\n",
410
+ "Epoch 2: finished saving model to /content/computer vision/models/model_vgg19.h5\n",
411
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━��━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m188s\u001b[0m 17ms/step - loss: 4.7578 - val_loss: 4.4673 - learning_rate: 0.0010\n",
412
+ "Epoch 3/50\n",
413
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.6693\n",
414
+ "Epoch 3: val_loss did not improve from 4.46729\n",
415
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m188s\u001b[0m 17ms/step - loss: 4.6920 - val_loss: 4.5085 - learning_rate: 0.0010\n",
416
+ "Epoch 4/50\n",
417
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.6785\n",
418
+ "Epoch 4: val_loss did not improve from 4.46729\n",
419
+ "\n",
420
+ "Epoch 4: ReduceLROnPlateau reducing learning rate to 0.0005000000237487257.\n",
421
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m187s\u001b[0m 17ms/step - loss: 4.7026 - val_loss: 4.6784 - learning_rate: 0.0010\n",
422
+ "Epoch 5/50\n",
423
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.6077\n",
424
+ "Epoch 5: val_loss did not improve from 4.46729\n",
425
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m188s\u001b[0m 17ms/step - loss: 4.5923 - val_loss: 4.5105 - learning_rate: 5.0000e-04\n",
426
+ "Epoch 6/50\n",
427
+ "\u001b[1m11050/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.5364\n",
428
+ "Epoch 6: val_loss improved from 4.46729 to 4.44435, saving model to /content/computer vision/models/model_vgg19.h5\n",
429
+ "WARNING:absl:You are saving your model as an HDF5 file via `model.save()` or `keras.saving.save_model(model)`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')` or `keras.saving.save_model(model, 'my_model.keras')`. \n",
430
+ "\n",
431
+ "Epoch 6: finished saving model to /content/computer vision/models/model_vgg19.h5\n",
432
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m202s\u001b[0m 18ms/step - loss: 4.5445 - val_loss: 4.4444 - learning_rate: 5.0000e-04\n",
433
+ "Epoch 7/50\n",
434
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.4867\n",
435
+ "Epoch 7: val_loss improved from 4.44435 to 4.38079, saving model to /content/computer vision/models/model_vgg19.h5\n",
436
+ "WARNING:absl:You are saving your model as an HDF5 file via `model.save()` or `keras.saving.save_model(model)`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')` or `keras.saving.save_model(model, 'my_model.keras')`. \n",
437
+ "\n",
438
+ "Epoch 7: finished saving model to /content/computer vision/models/model_vgg19.h5\n",
439
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m187s\u001b[0m 17ms/step - loss: 4.4927 - val_loss: 4.3808 - learning_rate: 5.0000e-04\n",
440
+ "Epoch 8/50\n",
441
+ "\u001b[1m11050/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.4589\n",
442
+ "Epoch 8: val_loss did not improve from 4.38079\n",
443
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m187s\u001b[0m 17ms/step - loss: 4.4756 - val_loss: 4.4305 - learning_rate: 5.0000e-04\n",
444
+ "Epoch 9/50\n",
445
+ "\u001b[1m11049/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.4644\n",
446
+ "Epoch 9: val_loss did not improve from 4.38079\n",
447
+ "\n",
448
+ "Epoch 9: ReduceLROnPlateau reducing learning rate to 0.0002500000118743628.\n",
449
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m202s\u001b[0m 18ms/step - loss: 4.4659 - val_loss: 4.4818 - learning_rate: 5.0000e-04\n",
450
+ "Epoch 10/50\n",
451
+ "\u001b[1m11049/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.3906\n",
452
+ "Epoch 10: val_loss improved from 4.38079 to 4.33908, saving model to /content/computer vision/models/model_vgg19.h5\n",
453
+ "WARNING:absl:You are saving your model as an HDF5 file via `model.save()` or `keras.saving.save_model(model)`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')` or `keras.saving.save_model(model, 'my_model.keras')`. \n",
454
+ "\n",
455
+ "Epoch 10: finished saving model to /content/computer vision/models/model_vgg19.h5\n",
456
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m187s\u001b[0m 17ms/step - loss: 4.3772 - val_loss: 4.3391 - learning_rate: 2.5000e-04\n",
457
+ "Epoch 11/50\n",
458
+ "\u001b[1m11049/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.3284\n",
459
+ "Epoch 11: val_loss did not improve from 4.33908\n",
460
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m187s\u001b[0m 17ms/step - loss: 4.3365 - val_loss: 4.3643 - learning_rate: 2.5000e-04\n",
461
+ "Epoch 12/50\n",
462
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.3017\n",
463
+ "Epoch 12: val_loss did not improve from 4.33908\n",
464
+ "\n",
465
+ "Epoch 12: ReduceLROnPlateau reducing learning rate to 0.0001250000059371814.\n",
466
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m186s\u001b[0m 17ms/step - loss: 4.3126 - val_loss: 4.3452 - learning_rate: 2.5000e-04\n",
467
+ "Epoch 13/50\n",
468
+ "\u001b[1m11049/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.2531\n",
469
+ "Epoch 13: val_loss did not improve from 4.33908\n",
470
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m184s\u001b[0m 17ms/step - loss: 4.2552 - val_loss: 4.3426 - learning_rate: 1.2500e-04\n",
471
+ "Epoch 14/50\n",
472
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.2051\n",
473
+ "Epoch 14: val_loss improved from 4.33908 to 4.32786, saving model to /content/computer vision/models/model_vgg19.h5\n",
474
+ "WARNING:absl:You are saving your model as an HDF5 file via `model.save()` or `keras.saving.save_model(model)`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')` or `keras.saving.save_model(model, 'my_model.keras')`. \n",
475
+ "\n",
476
+ "Epoch 14: finished saving model to /content/computer vision/models/model_vgg19.h5\n",
477
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m186s\u001b[0m 17ms/step - loss: 4.2269 - val_loss: 4.3279 - learning_rate: 1.2500e-04\n",
478
+ "Epoch 15/50\n",
479
+ "\u001b[1m11048/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.2146\n",
480
+ "Epoch 15: val_loss improved from 4.32786 to 4.31915, saving model to /content/computer vision/models/model_vgg19.h5\n",
481
+ "WARNING:absl:You are saving your model as an HDF5 file via `model.save()` or `keras.saving.save_model(model)`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')` or `keras.saving.save_model(model, 'my_model.keras')`. \n",
482
+ "\n",
483
+ "Epoch 15: finished saving model to /content/computer vision/models/model_vgg19.h5\n",
484
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m202s\u001b[0m 18ms/step - loss: 4.2120 - val_loss: 4.3192 - learning_rate: 1.2500e-04\n",
485
+ "Epoch 16/50\n",
486
+ "\u001b[1m11050/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.1837\n",
487
+ "Epoch 16: val_loss did not improve from 4.31915\n",
488
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━���━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m185s\u001b[0m 17ms/step - loss: 4.1944 - val_loss: 4.3407 - learning_rate: 1.2500e-04\n",
489
+ "Epoch 17/50\n",
490
+ "\u001b[1m11050/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.1650\n",
491
+ "Epoch 17: val_loss did not improve from 4.31915\n",
492
+ "\n",
493
+ "Epoch 17: ReduceLROnPlateau reducing learning rate to 6.25000029685907e-05.\n",
494
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m188s\u001b[0m 17ms/step - loss: 4.1806 - val_loss: 4.3310 - learning_rate: 1.2500e-04\n",
495
+ "Epoch 18/50\n",
496
+ "\u001b[1m11048/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.1517\n",
497
+ "Epoch 18: val_loss did not improve from 4.31915\n",
498
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m186s\u001b[0m 17ms/step - loss: 4.1530 - val_loss: 4.3467 - learning_rate: 6.2500e-05\n",
499
+ "Epoch 19/50\n",
500
+ "\u001b[1m11050/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.1332\n",
501
+ "Epoch 19: val_loss did not improve from 4.31915\n",
502
+ "\n",
503
+ "Epoch 19: ReduceLROnPlateau reducing learning rate to 3.125000148429535e-05.\n",
504
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m185s\u001b[0m 17ms/step - loss: 4.1348 - val_loss: 4.3427 - learning_rate: 6.2500e-05\n",
505
+ "Epoch 20/50\n",
506
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 4.0971\n",
507
+ "Epoch 20: val_loss did not improve from 4.31915\n",
508
+ "\u001b[1m11051/11051\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m186s\u001b[0m 17ms/step - loss: 4.1133 - val_loss: 4.3471 - learning_rate: 3.1250e-05\n",
509
+ "Epoch 20: early stopping\n",
510
+ "Restoring model weights from the end of the best epoch: 15.\n",
511
+ "WARNING:absl:You are saving your model as an HDF5 file via `model.save()` or `keras.saving.save_model(model)`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')` or `keras.saving.save_model(model, 'my_model.keras')`. \n",
512
+ "\n",
513
+ "Model saved to: /content/computer vision/models/model_vgg19.h5\n",
514
+ "Loss plot saved to: /content/computer vision/outputs/loss_vgg19.png\n",
515
+ "\n",
516
+ "✓ Training complete!\n"
517
+ ]
518
+ }
519
+ ]
520
+ },
521
+ {
522
+ "cell_type": "code",
523
+ "source": [
524
+ "!cp -r \"/content/computer vision\" \"/content/drive/MyDrive/\""
525
+ ],
526
+ "metadata": {
527
+ "id": "OIU_d-5g4OID"
528
+ },
529
+ "execution_count": 8,
530
+ "outputs": []
531
+ },
532
+ {
533
+ "cell_type": "code",
534
+ "source": [],
535
+ "metadata": {
536
+ "id": "FSAvGV17NMxZ"
537
+ },
538
+ "execution_count": null,
539
+ "outputs": []
540
+ }
541
+ ]
542
+ }
data/captions_clean.txt ADDED
The diff for this file is too large to render. See raw diff
 
data/test_images.txt ADDED
@@ -0,0 +1,1000 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1685463722_55843b6d3c.jpg
2
+ 3718305988_fe2c91fd44.jpg
3
+ 2439031566_2e0c0d3550.jpg
4
+ 2887744223_029f2fd5fe.jpg
5
+ 1311132744_5ffd03f831.jpg
6
+ 2396691909_6b8c2f7c44.jpg
7
+ 2789648482_1df61f224a.jpg
8
+ 319870744_0e0138d205.jpg
9
+ 2065875490_a46b58c12b.jpg
10
+ 3516935867_78cf63c69c.jpg
11
+ 667626_18933d713e.jpg
12
+ 3527184455_1a9c074ff2.jpg
13
+ 3765374230_cb1bbee0cb.jpg
14
+ 371522748_dc557bcd6c.jpg
15
+ 1860543210_47e94cf652.jpg
16
+ 3557316485_574a5f7a89.jpg
17
+ 2444935470_7b0226b756.jpg
18
+ 3105929913_94a6882e25.jpg
19
+ 3046431231_dc48851062.jpg
20
+ 3126724531_f483e1b92a.jpg
21
+ 3046190891_05c6ecd9b6.jpg
22
+ 3560771491_2a18b6241e.jpg
23
+ 3165826902_6bf9c4bdb2.jpg
24
+ 3425846980_912943b4f9.jpg
25
+ 3545779287_8f52e06909.jpg
26
+ 2666078276_f7b3056997.jpg
27
+ 313326614_b2adbe59e0.jpg
28
+ 2827964381_408a310809.jpg
29
+ 3502897880_8392d0e4de.jpg
30
+ 2978810122_183e60ff2d.jpg
31
+ 2748729903_3c7c920c4d.jpg
32
+ 3401902253_cd27e6d0fe.jpg
33
+ 2942133798_e57c862a90.jpg
34
+ 3569755200_cef7ee2233.jpg
35
+ 1144288288_e5c9558b6a.jpg
36
+ 3284899112_f11ab3cfe6.jpg
37
+ 2529205842_bdcb49d65b.jpg
38
+ 2514581496_8f4102377e.jpg
39
+ 2866974237_e3c1e267c0.jpg
40
+ 3275527950_41aca690a1.jpg
41
+ 3234719720_5bb2fc5ffa.jpg
42
+ 3334866049_f5933344aa.jpg
43
+ 3730457171_e66dde8c91.jpg
44
+ 3155657768_b83a7831e5.jpg
45
+ 3174431688_ae84778db0.jpg
46
+ 2255266906_8222af18b9.jpg
47
+ 2473791980_805c819bd4.jpg
48
+ 3215896272_e9b4b547a9.jpg
49
+ 2631300484_be8621d17b.jpg
50
+ 3718076407_0b4588d7bc.jpg
51
+ 2261962622_e9318a95eb.jpg
52
+ 3703035378_c6034cac51.jpg
53
+ 3554210976_fbd0ef33a3.jpg
54
+ 2252635585_b48b3485b0.jpg
55
+ 96973080_783e375945.jpg
56
+ 3689975998_72f50b6d91.jpg
57
+ 843616798_5ab0ecb525.jpg
58
+ 2521878609_146143708e.jpg
59
+ 3214381315_b54f5c9be4.jpg
60
+ 2511019188_ca71775f2d.jpg
61
+ 3243588540_b418ac7eda.jpg
62
+ 3090600019_8808fe7a9d.jpg
63
+ 3716277216_c04002be81.jpg
64
+ 2219959872_988e6d498e.jpg
65
+ 2890731828_8a7032503a.jpg
66
+ 374103776_0de490c1b0.jpg
67
+ 2918653119_f535fc25c4.jpg
68
+ 2743652730_d909c7ae82.jpg
69
+ 3251460982_4578a568bb.jpg
70
+ 3614881872_ccf9739b0e.jpg
71
+ 2424976964_98f58a0618.jpg
72
+ 3275711232_e261143664.jpg
73
+ 2830880811_d7f66dd2cf.jpg
74
+ 1397887419_e798697b93.jpg
75
+ 1277743944_f4e8c78403.jpg
76
+ 2137789511_69a6c6afa8.jpg
77
+ 2466171100_5e60cfcc11.jpg
78
+ 3178005751_fca19815ac.jpg
79
+ 3086526292_f799d237c7.jpg
80
+ 1884727806_d84f209868.jpg
81
+ 2525666287_638ab5e784.jpg
82
+ 3214885227_2be09e7cfb.jpg
83
+ 1713248047_d03721456d.jpg
84
+ 1288909046_d2b2b62607.jpg
85
+ 3564312955_716e86c48b.jpg
86
+ 2339516180_12493e8ecf.jpg
87
+ 3553225222_f5ebe44af1.jpg
88
+ 2929506802_5432054d77.jpg
89
+ 2497420371_74788d7ba1.jpg
90
+ 2417623030_afdc1024b5.jpg
91
+ 489551372_b19a6ad0ed.jpg
92
+ 549520317_af3d5c32eb.jpg
93
+ 3216762979_813c45a8ec.jpg
94
+ 3425662680_41c7c50e8d.jpg
95
+ 179829865_095b040377.jpg
96
+ 417966898_a04f9b5349.jpg
97
+ 506343925_b30a235de6.jpg
98
+ 2481003841_06086eafc2.jpg
99
+ 3508522093_51f6d77f45.jpg
100
+ 3628994466_a12065d29b.jpg
101
+ 3359563671_35b67898e7.jpg
102
+ 3136404885_f4d8f1d15a.jpg
103
+ 3265578645_4044a7049a.jpg
104
+ 2708686056_1b8f356264.jpg
105
+ 444481722_690d0cadcf.jpg
106
+ 2295216243_0712928988.jpg
107
+ 3696698390_989f1488e7.jpg
108
+ 3506216254_04d119cac7.jpg
109
+ 2377460540_8cfb62463a.jpg
110
+ 2716903793_fb7a3d8ba6.jpg
111
+ 2470588201_955132a946.jpg
112
+ 3220650628_4ed964e5b4.jpg
113
+ 3228069008_edb2961fc4.jpg
114
+ 496606439_9333831e73.jpg
115
+ 140526326_da07305c1c.jpg
116
+ 1394927474_0afdd82fc4.jpg
117
+ 430173345_86388d8822.jpg
118
+ 2521938802_853224f378.jpg
119
+ 2363419943_717e6b119d.jpg
120
+ 472661386_723aae880b.jpg
121
+ 3426966595_c8c4e1e872.jpg
122
+ 3262301835_9f1a49b80a.jpg
123
+ 435054077_3506dbfcf4.jpg
124
+ 3710176138_fbfe00bd35.jpg
125
+ 3078844565_16e9cdcea2.jpg
126
+ 3374759363_d6f7a0df41.jpg
127
+ 3132006797_04822b5866.jpg
128
+ 3296124052_6f1d1c9f8d.jpg
129
+ 3487015378_2e90a79f4b.jpg
130
+ 449287870_f17fb825d7.jpg
131
+ 3379839396_0cd84b55f1.jpg
132
+ 1262583859_653f1469a9.jpg
133
+ 2534502836_7a75305655.jpg
134
+ 2857372127_d86639002c.jpg
135
+ 3203707977_cc9448fecb.jpg
136
+ 2417745327_a2c2705043.jpg
137
+ 478592803_f57cc9c461.jpg
138
+ 3335885203_a3fe8e541f.jpg
139
+ 3302804312_0272091cd5.jpg
140
+ 1937104503_313d22a2d0.jpg
141
+ 2759860913_f75b39d783.jpg
142
+ 1015584366_dfcec3c85a.jpg
143
+ 3627676364_1dc9294ec5.jpg
144
+ 2453891449_fedb277908.jpg
145
+ 2422482455_b98d9c2120.jpg
146
+ 3264678536_46601d25f0.jpg
147
+ 1295671216_cde1b9c9d1.jpg
148
+ 3725202807_12fbfdd207.jpg
149
+ 345284642_77dded0907.jpg
150
+ 3206919175_e3a11b6874.jpg
151
+ 437404867_209625774d.jpg
152
+ 2342478660_faef1afea8.jpg
153
+ 2795352290_9209b214f3.jpg
154
+ 2075321027_c8fcbaf581.jpg
155
+ 583174725_6b522b621f.jpg
156
+ 404850242_3a55a4c874.jpg
157
+ 263854883_0f320c1562.jpg
158
+ 3533922605_a2b1e276f6.jpg
159
+ 3318995586_c2bc50b92e.jpg
160
+ 3372022051_132b8e6233.jpg
161
+ 381514859_b40418d9c3.jpg
162
+ 3638440337_6d5c19a8f0.jpg
163
+ 3518334317_bc40bae18d.jpg
164
+ 3036033157_522a43a550.jpg
165
+ 3271385712_ffd34f2de5.jpg
166
+ 3126225245_96cd2c053f.jpg
167
+ 3301438465_10121a2412.jpg
168
+ 2728486640_cc2a31d2b0.jpg
169
+ 1482960952_95f2d419cb.jpg
170
+ 2714699748_c9270dd5aa.jpg
171
+ 432248727_e7b623adbf.jpg
172
+ 468141298_3154d717e1.jpg
173
+ 3676432043_0ca418b861.jpg
174
+ 3405942945_f4af2934a6.jpg
175
+ 2181117039_c4eea8036e.jpg
176
+ 3336211088_4c294a870b.jpg
177
+ 3203453897_6317aac6ff.jpg
178
+ 1685990174_09c4fb7df8.jpg
179
+ 2823200990_7b02b7cc36.jpg
180
+ 1370615506_2b96105ca3.jpg
181
+ 3325497914_f9014d615b.jpg
182
+ 2748435417_ea7bbcc17c.jpg
183
+ 2729655904_1dd01922fb.jpg
184
+ 2260649048_ae45d17e68.jpg
185
+ 3336759846_5220e27deb.jpg
186
+ 386470686_1ae9242878.jpg
187
+ 1443807993_aebfb2784a.jpg
188
+ 2704257993_d485058a5f.jpg
189
+ 2903617548_d3e38d7f88.jpg
190
+ 2998504949_1022fec53b.jpg
191
+ 2273028514_d7b584f73d.jpg
192
+ 2981372647_2061278c60.jpg
193
+ 428796930_476a3d6395.jpg
194
+ 3359530430_249f51972c.jpg
195
+ 3437315443_ba2263f92e.jpg
196
+ 2918880895_e61f74f2f0.jpg
197
+ 2221818690_9003756d33.jpg
198
+ 3544673666_ffc7483c96.jpg
199
+ 2954584849_3c2899f319.jpg
200
+ 3439128755_84409b8823.jpg
201
+ 3463268965_f22884fc69.jpg
202
+ 2219805467_370ee1b7aa.jpg
203
+ 3467941308_ae6989e29c.jpg
204
+ 337647771_3b819feaba.jpg
205
+ 574274795_57e0834e7d.jpg
206
+ 3165750962_e2e3843679.jpg
207
+ 2891961886_b7a2f0b0fd.jpg
208
+ 278496691_c1fd93e2d8.jpg
209
+ 3135504530_0f4130d8f8.jpg
210
+ 3360823754_90967276ec.jpg
211
+ 3287549827_04dec6fb6e.jpg
212
+ 2426215757_e008a91fcb.jpg
213
+ 3568219100_dfbffddccd.jpg
214
+ 3674565156_14d3b41450.jpg
215
+ 510531976_90bbee22a2.jpg
216
+ 717673249_ac998cfbe6.jpg
217
+ 2505056124_1276e8dbcb.jpg
218
+ 1142283988_6b227c5231.jpg
219
+ 3354414391_a3908bd4ff.jpg
220
+ 3319388517_5609ae9805.jpg
221
+ 2076865206_53918c820c.jpg
222
+ 1994416869_4dd769a806.jpg
223
+ 456512643_0aac2fa9ce.jpg
224
+ 2321865325_79b0954a5d.jpg
225
+ 2204550058_2707d92338.jpg
226
+ 1466307485_5e6743332e.jpg
227
+ 3162442331_c9711857c6.jpg
228
+ 3605676864_0fb491267e.jpg
229
+ 2469620360_6c620c6f35.jpg
230
+ 3613175012_bcd063e7c9.jpg
231
+ 2838619742_eed855d8a8.jpg
232
+ 245895500_a4eb97af02.jpg
233
+ 2271667421_7b21fc23b8.jpg
234
+ 2064417101_3b9d817f4a.jpg
235
+ 3291255271_a185eba408.jpg
236
+ 1433577867_39a1510c43.jpg
237
+ 3632842482_482f29e712.jpg
238
+ 3463523977_f2ed231585.jpg
239
+ 491964988_414b556228.jpg
240
+ 3017220118_6a9212dfdb.jpg
241
+ 485741580_ab523fa657.jpg
242
+ 327415627_6313d32a64.jpg
243
+ 3257277774_aba333a94c.jpg
244
+ 3157622277_9f59b4f62f.jpg
245
+ 2959581023_54402c8d88.jpg
246
+ 3125309108_1011486589.jpg
247
+ 2987775031_3f9ac69319.jpg
248
+ 759015118_4bd3617e60.jpg
249
+ 1797554350_20998753c0.jpg
250
+ 3138746531_f6b816c126.jpg
251
+ 2542415282_9240e1b5fc.jpg
252
+ 3367034082_31658a89bb.jpg
253
+ 2780105274_52360c4cca.jpg
254
+ 448590900_db83c42006.jpg
255
+ 241347803_afb04b12c4.jpg
256
+ 294549892_babb130543.jpg
257
+ 2858759108_6e697c5f3e.jpg
258
+ 2419221084_01a14176b4.jpg
259
+ 2186139563_e60c1d4b8b.jpg
260
+ 2251992614_0c601fae2c.jpg
261
+ 3169276423_6918dd4da1.jpg
262
+ 1468429623_f001988691.jpg
263
+ 2382411771_a16145f345.jpg
264
+ 1463732807_0cdf4f22c7.jpg
265
+ 451326127_2d95a2e1c2.jpg
266
+ 2426828433_ce894d1c54.jpg
267
+ 2271955077_0020b4ee0d.jpg
268
+ 343218198_1ca90e0734.jpg
269
+ 3019667009_20db160195.jpg
270
+ 2600170955_bf30c5d5c0.jpg
271
+ 3421547427_53411b6278.jpg
272
+ 2881441125_b580e3dd4b.jpg
273
+ 3541474181_489f19fae7.jpg
274
+ 2325258180_6217dd17eb.jpg
275
+ 2205088706_d7e633e00d.jpg
276
+ 2696951725_e0ae54f6da.jpg
277
+ 763577068_4b96ed768b.jpg
278
+ 2812125355_5e11a76533.jpg
279
+ 3416091866_a96003d652.jpg
280
+ 3567604049_da9e1be4ba.jpg
281
+ 2196316998_3b2d63f01f.jpg
282
+ 3462165890_c13ce13eff.jpg
283
+ 3365348059_9773165302.jpg
284
+ 2325816912_b3bb41cdbb.jpg
285
+ 2895700779_fac1d9d278.jpg
286
+ 2901880865_3fd7b66a45.jpg
287
+ 3737492755_bcfb800ed1.jpg
288
+ 2649705487_4605e879e9.jpg
289
+ 2085557551_7a88d01d4e.jpg
290
+ 426065353_e9a604a01f.jpg
291
+ 405961988_fcfe97f31e.jpg
292
+ 3655074079_7df3812bc5.jpg
293
+ 3273489163_8209545810.jpg
294
+ 3672057606_cb6393dbd9.jpg
295
+ 3172283002_3c0fc624de.jpg
296
+ 1808370027_2088394eb4.jpg
297
+ 979201222_75b6456d34.jpg
298
+ 2186367337_0ce9ce2104.jpg
299
+ 491600485_26c52c8816.jpg
300
+ 2893515010_4a3d9dcc67.jpg
301
+ 3614542901_29877fc342.jpg
302
+ 2806632713_edd6f6c893.jpg
303
+ 3368207495_1e2dbd6d3f.jpg
304
+ 3342272425_804316cb3d.jpg
305
+ 2522467011_cc825d89ac.jpg
306
+ 2127209046_94711c747b.jpg
307
+ 2676184321_858eff416b.jpg
308
+ 219070971_ae43410b9e.jpg
309
+ 2877424957_9beb1dc49a.jpg
310
+ 2998277360_9b4c0192f1.jpg
311
+ 3427852996_d383abd819.jpg
312
+ 2786245676_0a69543832.jpg
313
+ 378453580_21d688748e.jpg
314
+ 410453140_5401bf659a.jpg
315
+ 3207676216_48478bce97.jpg
316
+ 431410325_f4916b5460.jpg
317
+ 2858439751_daa3a30ab8.jpg
318
+ 3304556387_203b9d4db0.jpg
319
+ 1155138244_859fd6e079.jpg
320
+ 909191414_1cf5d85821.jpg
321
+ 2978409165_acc4f29a40.jpg
322
+ 3295671644_0e10891b6d.jpg
323
+ 272940778_a184dbea42.jpg
324
+ 1799188614_b5189728ba.jpg
325
+ 2415265825_fbfe0c8556.jpg
326
+ 2636876892_9353521a1c.jpg
327
+ 3177298173_78cea31d64.jpg
328
+ 3134387513_ceb75bea0a.jpg
329
+ 3626998066_3ae11ee278.jpg
330
+ 1402640441_81978e32a9.jpg
331
+ 3455920874_6fbec43194.jpg
332
+ 3569126684_a68b29a57f.jpg
333
+ 408627152_1feaa4b94e.jpg
334
+ 637342973_89f6fac1f7.jpg
335
+ 3207775692_bb897d9afd.jpg
336
+ 2266061169_dfbf8f0595.jpg
337
+ 462288558_b31a8a976f.jpg
338
+ 3508882611_3947c0dbf5.jpg
339
+ 1557838421_a33f2a4911.jpg
340
+ 3547368652_0d85c665d3.jpg
341
+ 3084711346_fda0f5a3e6.jpg
342
+ 3389321512_b11f499dab.jpg
343
+ 3491013009_572cf2c18a.jpg
344
+ 3301822808_f2ccff86f4.jpg
345
+ 2777021428_0b2ac3e987.jpg
346
+ 846085364_fc9d23df46.jpg
347
+ 2579268572_d78f8436cb.jpg
348
+ 3437273677_47d4462974.jpg
349
+ 3033612929_764d977bd5.jpg
350
+ 2934359101_cdf57442dc.jpg
351
+ 3052196390_c59dd24ca8.jpg
352
+ 3125041578_c1f2d73b6d.jpg
353
+ 3672944692_8d24a44fc6.jpg
354
+ 475317104_1cdc1653b4.jpg
355
+ 2519812011_f85c3b5cb5.jpg
356
+ 485357535_b45ba5b6da.jpg
357
+ 3326454455_960e5442e9.jpg
358
+ 2338627102_6708a9b4fd.jpg
359
+ 3111502208_71e2a414f5.jpg
360
+ 2170187328_65c2f11891.jpg
361
+ 2730819220_b58af1119a.jpg
362
+ 3572144280_ea42bbd927.jpg
363
+ 2798880731_4f51634374.jpg
364
+ 2637904605_fc355816fc.jpg
365
+ 3506096155_13632955e8.jpg
366
+ 2939371251_f923569a72.jpg
367
+ 1714316707_8bbaa2a2ba.jpg
368
+ 2739331794_4ae78f69a0.jpg
369
+ 403678611_73978faed7.jpg
370
+ 290982269_79fc9f36dc.jpg
371
+ 1805990081_da9cefe3a5.jpg
372
+ 1413956047_c826f90c8b.jpg
373
+ 2860202109_97b2b22652.jpg
374
+ 2314732154_83bc7f7314.jpg
375
+ 3457784061_8f77f43a9c.jpg
376
+ 199809190_e3f6bbe2bc.jpg
377
+ 2887750774_920eb171aa.jpg
378
+ 308956341_642589e9cc.jpg
379
+ 1579798212_d30844b4c5.jpg
380
+ 112178718_87270d9b4d.jpg
381
+ 1417295167_5299df6db8.jpg
382
+ 2837908308_8bc25c6b02.jpg
383
+ 2360194369_d2fd03b337.jpg
384
+ 386160015_d4b31df68e.jpg
385
+ 3658427967_6e2e57458d.jpg
386
+ 897621891_efb1e00d1d.jpg
387
+ 3138562460_44227a35cf.jpg
388
+ 2768662025_44001fe5d1.jpg
389
+ 506478284_7cf8bdbe36.jpg
390
+ 2497608431_8dfefc7a1a.jpg
391
+ 1836335410_de8313a64e.jpg
392
+ 265223843_9ef21e1872.jpg
393
+ 3088399255_1bd9a6aa04.jpg
394
+ 2917843040_7c9caaaa8a.jpg
395
+ 3454988449_1de1ef4f20.jpg
396
+ 3119887391_212f379797.jpg
397
+ 2618322793_5fb164d86a.jpg
398
+ 3182405529_7692256746.jpg
399
+ 2130851544_d36f4f2ea6.jpg
400
+ 307327914_f98f576adb.jpg
401
+ 336460583_6c8ccb7188.jpg
402
+ 3421104520_6a71185b3c.jpg
403
+ 3387630781_f421a94d9d.jpg
404
+ 3456251289_c4ae31d817.jpg
405
+ 2949982320_c704b31626.jpg
406
+ 2712352554_1cafd32812.jpg
407
+ 3323498985_fd9d2803fd.jpg
408
+ 309430053_cc58bcc36a.jpg
409
+ 2337757064_08c4033824.jpg
410
+ 2612608861_92beaa3d0b.jpg
411
+ 3028561714_83fb921067.jpg
412
+ 3677927146_1696f0b075.jpg
413
+ 492802403_ba5246cfea.jpg
414
+ 238512430_30dc12b683.jpg
415
+ 2044063458_fcc76a7636.jpg
416
+ 2970461648_fe14ba0359.jpg
417
+ 3564907603_14ccc655f1.jpg
418
+ 2064780645_8f28a1529f.jpg
419
+ 3224578187_749882c17f.jpg
420
+ 3587009091_37188fd07e.jpg
421
+ 3484365373_98d5304935.jpg
422
+ 1355833561_9c43073eda.jpg
423
+ 2751602672_ca5e1f6447.jpg
424
+ 2843695880_eeea6c67db.jpg
425
+ 3227594168_3351722aae.jpg
426
+ 225909073_25c3c33a29.jpg
427
+ 2102732029_9ae520914d.jpg
428
+ 2744321686_8811d8428c.jpg
429
+ 2363006088_b3e3aa5c0b.jpg
430
+ 2632381125_de32bdfdf6.jpg
431
+ 3024172109_a10198e1dd.jpg
432
+ 3694071771_ce760db4c7.jpg
433
+ 468911753_cc595f5da0.jpg
434
+ 2884400562_e0851014fc.jpg
435
+ 491405109_798222cfd0.jpg
436
+ 432167214_c17fcc1a2d.jpg
437
+ 3484070900_3e76d7fd30.jpg
438
+ 3640109324_3ce89e4d1a.jpg
439
+ 3484649669_7bfe62080b.jpg
440
+ 2491343114_a3e35a2a3a.jpg
441
+ 319847657_2c40e14113.jpg
442
+ 751737218_b89839a311.jpg
443
+ 477204750_d04d111cd4.jpg
444
+ 3394654132_9a8659605c.jpg
445
+ 2364096157_eb7970a69a.jpg
446
+ 3238654429_d899e34287.jpg
447
+ 3604384157_99241be16e.jpg
448
+ 262963190_a78b799e89.jpg
449
+ 3632258003_6a0a69bf3a.jpg
450
+ 2558911884_856dfc3951.jpg
451
+ 2796801478_8ebd7e550b.jpg
452
+ 3372215826_b3e6403b2e.jpg
453
+ 529101401_ab1f6b1206.jpg
454
+ 2836325261_a3bf5c59be.jpg
455
+ 3323514651_3efdbd63ed.jpg
456
+ 3482668767_66004ce736.jpg
457
+ 251958970_fa6b423f23.jpg
458
+ 3332202255_a30c522664.jpg
459
+ 2854207034_1f00555703.jpg
460
+ 3347701468_bb0001b035.jpg
461
+ 525968880_82623392d1.jpg
462
+ 3106340185_80d0cb770a.jpg
463
+ 2911658792_6a6ef07e3a.jpg
464
+ 2714674623_8cd05ac114.jpg
465
+ 428483413_b9370baf72.jpg
466
+ 3330333217_1a69497a74.jpg
467
+ 295258727_eaf75e0887.jpg
468
+ 2381613738_d8d2012e3c.jpg
469
+ 3154641421_d1b9b8c24c.jpg
470
+ 2860372882_e0ef4131d4.jpg
471
+ 2565350330_c7f305e7f7.jpg
472
+ 3718892835_a3e74a3417.jpg
473
+ 3701249979_8bc757e171.jpg
474
+ 1528205014_1323aa9dfd.jpg
475
+ 229862312_1a0ba19dab.jpg
476
+ 3264350290_f50494e835.jpg
477
+ 3109780402_dbae082dc5.jpg
478
+ 3368819708_0bfa0808f8.jpg
479
+ 2908512223_7e27631ed4.jpg
480
+ 3308018795_68a97a425c.jpg
481
+ 471402959_0b187560df.jpg
482
+ 3223055565_68973f5d20.jpg
483
+ 300594071_3450444752.jpg
484
+ 1510078253_96e9ec50e7.jpg
485
+ 3354474353_daf9e168cf.jpg
486
+ 3351493005_6e5030f596.jpg
487
+ 2752919987_8bfca604ab.jpg
488
+ 1469000260_5d473c8283.jpg
489
+ 3254645823_a7c072481c.jpg
490
+ 2140305708_591d10b54d.jpg
491
+ 237547381_aa17c805e0.jpg
492
+ 2102360862_264452db8e.jpg
493
+ 2449518585_113dc4a8e5.jpg
494
+ 2183227136_8bb657846b.jpg
495
+ 2751567262_e089b33ed9.jpg
496
+ 3498423815_5b8fc097f4.jpg
497
+ 1122944218_8eb3607403.jpg
498
+ 1813266419_08bf66fe98.jpg
499
+ 571507143_be346225b7.jpg
500
+ 3523819210_99782628fc.jpg
501
+ 3344948183_5b89379585.jpg
502
+ 3006095077_1992b677f8.jpg
503
+ 3488512097_e500cb499f.jpg
504
+ 2003663004_5b70920a98.jpg
505
+ 1130017585_1a219257ac.jpg
506
+ 3258396041_69717247f7.jpg
507
+ 543102698_38e7e38bbc.jpg
508
+ 532999240_1409d073be.jpg
509
+ 875731481_a5a0a09934.jpg
510
+ 161905204_247c6ca6de.jpg
511
+ 3201666946_04fe837aff.jpg
512
+ 3178300150_d4605ff02c.jpg
513
+ 3671935691_57bdd0e778.jpg
514
+ 3756150099_50882fc029.jpg
515
+ 3708839890_ed448012cf.jpg
516
+ 3721799573_2f470950e0.jpg
517
+ 3126981064_1e803c3d7f.jpg
518
+ 497579819_f91b26f7d3.jpg
519
+ 3725353555_75c346d7ec.jpg
520
+ 209605542_ca9cc52e7b.jpg
521
+ 2056930414_d2b0f1395a.jpg
522
+ 3279025792_23bfd21bcc.jpg
523
+ 3371279606_c0d0cddab2.jpg
524
+ 3352531708_a65dd694b1.jpg
525
+ 1007129816_e794419615.jpg
526
+ 2832978253_8fcc72da3b.jpg
527
+ 3446586125_cafa0bfd67.jpg
528
+ 2855667597_bf6ceaef8e.jpg
529
+ 3587941206_36769c3f1d.jpg
530
+ 393810324_1c33760a95.jpg
531
+ 2691966747_cfa154982b.jpg
532
+ 2633201394_ee4a7666ed.jpg
533
+ 396763804_3b7f1e12a8.jpg
534
+ 3344526059_4a097af285.jpg
535
+ 3053785363_50392f2c53.jpg
536
+ 3293753378_7a8ddb98b2.jpg
537
+ 3260214530_7179346407.jpg
538
+ 2395967330_7e6ea404f6.jpg
539
+ 3595992258_6f192e6ae7.jpg
540
+ 49553964_cee950f3ba.jpg
541
+ 3650986674_3e101c606b.jpg
542
+ 3597715122_45878432ec.jpg
543
+ 3563924606_5914392cd8.jpg
544
+ 2182050469_1edac0bc60.jpg
545
+ 2886533440_dfa832f2fa.jpg
546
+ 1525153022_06c48dbe52.jpg
547
+ 3033741581_136889ac73.jpg
548
+ 3025546819_ce031d2fc3.jpg
549
+ 3127888173_9a9a8ac3bd.jpg
550
+ 2045109977_b00ec93491.jpg
551
+ 2465691083_894fc48af6.jpg
552
+ 272546805_536c719648.jpg
553
+ 3492180255_0bd48a18f8.jpg
554
+ 3293596075_973b0bfd08.jpg
555
+ 498492764_fe276e505a.jpg
556
+ 3351357065_a6a9b3d485.jpg
557
+ 2190227737_6e0bde2623.jpg
558
+ 3632047678_f202609e50.jpg
559
+ 3510218982_318f738b76.jpg
560
+ 2089555297_95cf001fa7.jpg
561
+ 270263570_3160f360d3.jpg
562
+ 3208188198_2b271d2a2e.jpg
563
+ 3639363462_bcdb21de29.jpg
564
+ 305199420_89f6ddd778.jpg
565
+ 2595102568_347f6d4b07.jpg
566
+ 3121482932_f77ca12c01.jpg
567
+ 3260975858_75d0612a69.jpg
568
+ 3124964754_2e8a98fb09.jpg
569
+ 2790909995_8b7a03d9d1.jpg
570
+ 3433567526_00b5a70319.jpg
571
+ 3710353645_8fbfaa4175.jpg
572
+ 1473618073_7db56a5237.jpg
573
+ 2622971954_59f192922d.jpg
574
+ 3315726723_64c9b0a945.jpg
575
+ 242324909_06d5a6c44b.jpg
576
+ 3505657604_8899161734.jpg
577
+ 1480712062_32a61ad4b7.jpg
578
+ 2738077433_10e6264b6f.jpg
579
+ 3469585782_e708496552.jpg
580
+ 3429391520_930b153f94.jpg
581
+ 415657941_454d370721.jpg
582
+ 454686980_7517fe0c2e.jpg
583
+ 3174196837_800689a2f3.jpg
584
+ 509123893_07b8ea82a9.jpg
585
+ 2866696346_4dcccbd3a5.jpg
586
+ 1917265421_aeccf1ca38.jpg
587
+ 3107513635_fe8a21f148.jpg
588
+ 2276499757_b44dc6f8ce.jpg
589
+ 264928854_d9e61f3a8e.jpg
590
+ 1167908324_8caab45e15.jpg
591
+ 281754914_bc8119a0ed.jpg
592
+ 2384728877_48c85d58af.jpg
593
+ 2772084628_c0ae29d87a.jpg
594
+ 897406883_f09f673d94.jpg
595
+ 485245061_5a5de43e20.jpg
596
+ 3251648670_9339943ba2.jpg
597
+ 3057497487_57ecc60ff1.jpg
598
+ 2710563762_06d48329d7.jpg
599
+ 2442243868_abe8f74fb4.jpg
600
+ 3400186336_37043a2f5b.jpg
601
+ 152029243_b3582c36fa.jpg
602
+ 3649802021_8a689bc153.jpg
603
+ 3478591390_b526580644.jpg
604
+ 2414397449_2ac3b78e0d.jpg
605
+ 2490179961_e842fda5eb.jpg
606
+ 1132772170_600610c5df.jpg
607
+ 2923475135_a6b6e13d26.jpg
608
+ 2902661518_1513be3ea6.jpg
609
+ 964197865_0133acaeb4.jpg
610
+ 3529314899_b4e533bb76.jpg
611
+ 2801851082_8c3c480c0f.jpg
612
+ 2092177624_13ab757e8b.jpg
613
+ 2567812221_30fb64f5e9.jpg
614
+ 1235580648_7eebaed9bc.jpg
615
+ 2178095150_436b035741.jpg
616
+ 3330007895_78303e8a40.jpg
617
+ 1773928579_5664a810dc.jpg
618
+ 543264612_c53cc163b4.jpg
619
+ 1570723692_3a2b064d43.jpg
620
+ 3159447439_c1496cbaea.jpg
621
+ 1332722096_1e3de8ae70.jpg
622
+ 3637013_c675de7705.jpg
623
+ 2929669711_b2d5a640f0.jpg
624
+ 590445887_4d4fa43923.jpg
625
+ 2127031632_77505e4218.jpg
626
+ 693785581_68bec8312a.jpg
627
+ 782017931_75d92bb7a4.jpg
628
+ 2657663775_bc98bf67ac.jpg
629
+ 976392326_082dafc3c5.jpg
630
+ 213216174_0632af65a2.jpg
631
+ 2644920808_f5a214b744.jpg
632
+ 2540360421_f7c2401da8.jpg
633
+ 2218334049_e649dbdb1a.jpg
634
+ 452416075_60b2bb5832.jpg
635
+ 1022454332_6af2c1449a.jpg
636
+ 2854291706_d4c31dbf56.jpg
637
+ 967719295_3257695095.jpg
638
+ 3236447445_eecafdf4f0.jpg
639
+ 3258472448_75cfab5e6f.jpg
640
+ 1977827746_4e13d7e19f.jpg
641
+ 2837799692_2f1c50722a.jpg
642
+ 544257613_d9a1fea3f7.jpg
643
+ 3429956016_3c7e3096c2.jpg
644
+ 2087317114_cf06df5aa5.jpg
645
+ 3724718895_bd03f4a4dc.jpg
646
+ 3591457224_88281dd04f.jpg
647
+ 3284955091_59317073f0.jpg
648
+ 482098572_e83153b300.jpg
649
+ 1263801010_5c74bf1715.jpg
650
+ 3541141771_67d305c873.jpg
651
+ 2911245290_b2c79f328a.jpg
652
+ 3486340101_ff01d8f3f9.jpg
653
+ 263216826_acf868049c.jpg
654
+ 1514957266_a19827c538.jpg
655
+ 2934000107_d2ff15c814.jpg
656
+ 3582689770_e57ab56671.jpg
657
+ 3542771548_fcb8fa0cba.jpg
658
+ 2389107995_ec756f3514.jpg
659
+ 3691729694_2b97f14c1e.jpg
660
+ 2119302248_72493d458c.jpg
661
+ 2935649082_1ca60180c6.jpg
662
+ 3220126881_b0a4f7cccb.jpg
663
+ 2085726719_a57a75dbe5.jpg
664
+ 96399948_b86c61bfe6.jpg
665
+ 2711075591_f3ee53cfaa.jpg
666
+ 792362827_5ab5281b99.jpg
667
+ 3255732353_fbc487aefc.jpg
668
+ 607339469_af851c4119.jpg
669
+ 2205328215_3ffc094cde.jpg
670
+ 3357416302_fcfcdd7b86.jpg
671
+ 3416013671_98b5c75046.jpg
672
+ 537628742_146f2c24f8.jpg
673
+ 2319197581_94f807b204.jpg
674
+ 3091594712_2166604334.jpg
675
+ 862187579_9faf4a51e0.jpg
676
+ 2244551043_21b8cca866.jpg
677
+ 772403830_08b72c7da9.jpg
678
+ 3703960010_1e4c922a25.jpg
679
+ 3449114979_6cdc3e8da8.jpg
680
+ 1178705300_c224d9a4f1.jpg
681
+ 3109268897_d43797fc6a.jpg
682
+ 3468694409_a51571d621.jpg
683
+ 2086532897_b8714f2237.jpg
684
+ 3040575300_0e4328d205.jpg
685
+ 2880874989_a33b632924.jpg
686
+ 2759596272_e0ce0a965a.jpg
687
+ 3036382555_30b7312cf3.jpg
688
+ 3193511842_82549c21fb.jpg
689
+ 330325191_63e11d9c93.jpg
690
+ 3514184232_b336414040.jpg
691
+ 2797185895_4d9e1e9508.jpg
692
+ 3504275465_604ce2ef34.jpg
693
+ 2538423833_d1f492d1fb.jpg
694
+ 1107246521_d16a476380.jpg
695
+ 707941195_4386109029.jpg
696
+ 2656688132_d93be870e0.jpg
697
+ 2867968184_908d87cf2c.jpg
698
+ 469029994_349e138606.jpg
699
+ 1294578091_2ad02fea91.jpg
700
+ 3077781040_bc27778609.jpg
701
+ 3143155555_32b6d24f34.jpg
702
+ 2288530008_4ebcee2174.jpg
703
+ 3421177332_a05741cfa4.jpg
704
+ 2368266191_87d77750f1.jpg
705
+ 3245250964_9d3e37111e.jpg
706
+ 3251976937_20625dc2b8.jpg
707
+ 3091962081_194f2f3bd4.jpg
708
+ 2391269207_d1d2615b1d.jpg
709
+ 2869491449_1041485a6b.jpg
710
+ 3545793128_af3af544dc.jpg
711
+ 3564148252_aa4cb36a32.jpg
712
+ 3208999896_dab42dc40b.jpg
713
+ 2186087673_c7a73da7ce.jpg
714
+ 2555535057_007501dae5.jpg
715
+ 3707990914_843e8f15f1.jpg
716
+ 2384353160_f395e9a54b.jpg
717
+ 2866093652_aa717eb9ce.jpg
718
+ 470887785_e0b1241d94.jpg
719
+ 2483993827_243894a4f9.jpg
720
+ 399679638_d3036da331.jpg
721
+ 3115354165_44dbeec6c1.jpg
722
+ 745563422_f4fa7d9157.jpg
723
+ 2850719435_221f15e951.jpg
724
+ 3217056901_fe2c70377d.jpg
725
+ 3019923691_3b3c5a4766.jpg
726
+ 3585598356_8ce815bbb9.jpg
727
+ 3397633339_d1ae6d9a0e.jpg
728
+ 3727740053_3baa94ffcb.jpg
729
+ 2481367956_8577d2fa98.jpg
730
+ 3303797949_339bb969ba.jpg
731
+ 2999735171_87ca43c225.jpg
732
+ 861608773_bdafd5c996.jpg
733
+ 1597319381_1e80d9e39c.jpg
734
+ 3605061440_1d08c80a57.jpg
735
+ 583087629_a09334e1fb.jpg
736
+ 3484832904_08619300d9.jpg
737
+ 1299459550_1fd5594fa2.jpg
738
+ 3455898176_f0e003ce58.jpg
739
+ 2915538325_59e11276dd.jpg
740
+ 3108197858_441ff38565.jpg
741
+ 3420338549_bd78d35243.jpg
742
+ 3564007203_df2b8010f1.jpg
743
+ 3522749949_fb615cee47.jpg
744
+ 3632225464_612d7b4c0f.jpg
745
+ 241347547_902725b9f8.jpg
746
+ 3255737244_1f8948fc07.jpg
747
+ 975131015_9acd25db9c.jpg
748
+ 2599903773_0f724d8f63.jpg
749
+ 3647170476_0fd71a4c9f.jpg
750
+ 3459570613_3932816d3f.jpg
751
+ 2460126267_0deea8b645.jpg
752
+ 2802337003_56e555cd30.jpg
753
+ 1459032057_97e73ed6ab.jpg
754
+ 2423550887_ffc9bbcf71.jpg
755
+ 2404520067_87798dbaee.jpg
756
+ 2775249812_f4db95e818.jpg
757
+ 2876994989_a4ebbd8491.jpg
758
+ 1160034462_16b38174fe.jpg
759
+ 3435035138_af32890a4c.jpg
760
+ 2466420387_86fe77c966.jpg
761
+ 2266901263_4324af1f03.jpg
762
+ 3615730936_23457575e9.jpg
763
+ 3519942322_b37d088aae.jpg
764
+ 380590140_25b9889772.jpg
765
+ 2741380826_cfe0ddf0a9.jpg
766
+ 1676601498_7d59327523.jpg
767
+ 241347243_c751557497.jpg
768
+ 497122685_a51b29dc46.jpg
769
+ 2640153227_57cf1a3d92.jpg
770
+ 2923891109_ea0cc932ed.jpg
771
+ 3162045919_c2decbb69b.jpg
772
+ 2181846120_3744ca3942.jpg
773
+ 2888702775_0939a6680e.jpg
774
+ 1572286502_64e5c4b920.jpg
775
+ 3562903245_85071bb5f9.jpg
776
+ 369186134_5eef374112.jpg
777
+ 2980348138_91cc6f6d0f.jpg
778
+ 2449446913_28fa5b7c75.jpg
779
+ 390987167_2d5905b459.jpg
780
+ 123997871_6a9ca987b1.jpg
781
+ 58363928_6f7074608c.jpg
782
+ 2784408839_53a25a21eb.jpg
783
+ 2579460386_94c489028d.jpg
784
+ 3183875944_b2be694e06.jpg
785
+ 1874617189_e85d3f4326.jpg
786
+ 3208553539_2bf6c6d162.jpg
787
+ 3147217787_ed21cd4990.jpg
788
+ 2885111681_dc328ecfff.jpg
789
+ 1244485675_822e6efe60.jpg
790
+ 295433203_8185c13e08.jpg
791
+ 3293751136_b0ce285dc3.jpg
792
+ 3584829998_25e59fdef3.jpg
793
+ 3420469425_2980b4cd30.jpg
794
+ 2404488732_ca1bbdacc2.jpg
795
+ 3467219837_7d62213dec.jpg
796
+ 2727051596_be65bfb3d3.jpg
797
+ 2394003437_184a838aa9.jpg
798
+ 3344411431_6f4917bb2f.jpg
799
+ 3356700488_183566145b.jpg
800
+ 3459419203_cd7c68ce4d.jpg
801
+ 2942798367_022df04b49.jpg
802
+ 3613027188_1645ca1976.jpg
803
+ 687513087_413d4a3a3b.jpg
804
+ 3478877323_0a507a601b.jpg
805
+ 2045562030_654ddea5e5.jpg
806
+ 3444982197_0ff15cc50b.jpg
807
+ 3580375310_46ec3e476c.jpg
808
+ 325576658_59f68bdbd6.jpg
809
+ 3116769029_f5a76f04ba.jpg
810
+ 2524084967_a5e011b73d.jpg
811
+ 177302997_5b2d770a0a.jpg
812
+ 892340814_bdd61e10a4.jpg
813
+ 2814028429_561a215259.jpg
814
+ 3015863181_92ff43f4d8.jpg
815
+ 2364394224_c17b09e035.jpg
816
+ 436013859_793d870b6f.jpg
817
+ 506882688_b37d549593.jpg
818
+ 2938120171_970564e3d8.jpg
819
+ 2980118787_2099de53ec.jpg
820
+ 2240539658_dea8db6e55.jpg
821
+ 3241892328_4ebf8b21ce.jpg
822
+ 3626642428_3396568c3c.jpg
823
+ 3432495898_a5859f06b6.jpg
824
+ 2426303900_0a8d52eb14.jpg
825
+ 3354063643_1d8814eb13.jpg
826
+ 3032790880_d216197d55.jpg
827
+ 289616152_012a9f16c6.jpg
828
+ 824782868_a8f532f3a6.jpg
829
+ 3455405300_aa3069ecaa.jpg
830
+ 3027850131_a7772e0ba0.jpg
831
+ 2934837034_a8ca5b1f50.jpg
832
+ 2470493181_2efbbf17bd.jpg
833
+ 1680126311_b92a2e8e72.jpg
834
+ 3260768565_2b725be090.jpg
835
+ 3377117696_af91f13058.jpg
836
+ 698107542_3aa0ba78b4.jpg
837
+ 3029043380_b28644ea5d.jpg
838
+ 3188036349_8e4e2d6ca8.jpg
839
+ 3257103624_e76f25ff9e.jpg
840
+ 3420260768_26a600b844.jpg
841
+ 3426724811_137855b4f7.jpg
842
+ 179009558_69be522c63.jpg
843
+ 500308355_f0c19067c0.jpg
844
+ 2233426944_0959835ced.jpg
845
+ 3481884992_45770ec698.jpg
846
+ 3326086533_23a0a54a8e.jpg
847
+ 2696060728_3043cfc38c.jpg
848
+ 3666324102_18ecdf8253.jpg
849
+ 310260324_7f941814bc.jpg
850
+ 2246717855_c0c08fe5d2.jpg
851
+ 3413806271_17b7e102aa.jpg
852
+ 3415228562_4efa9c9b70.jpg
853
+ 468930779_8008d90e10.jpg
854
+ 255091927_2eb643beb2.jpg
855
+ 2895966469_53e0b29295.jpg
856
+ 3429142249_d09a32e291.jpg
857
+ 496971341_22782195f0.jpg
858
+ 2479180530_7ebba2d8bf.jpg
859
+ 2320125735_27fe729948.jpg
860
+ 2374652725_32f90fa15c.jpg
861
+ 3402081035_a54cfab1d9.jpg
862
+ 86542183_5e312ae4d4.jpg
863
+ 911527312_f81ee36b97.jpg
864
+ 2994179598_a45c2732b5.jpg
865
+ 3457315666_b943111dec.jpg
866
+ 333973142_abcd151002.jpg
867
+ 3284887033_e2e48f1863.jpg
868
+ 269986132_91b71e8aaa.jpg
869
+ 2836360729_6500249fe6.jpg
870
+ 2348491126_30db0d46ef.jpg
871
+ 3648081498_76ec091495.jpg
872
+ 2709648336_15455e60b2.jpg
873
+ 2678612999_893ed671f8.jpg
874
+ 3490867290_13bcd3a7f0.jpg
875
+ 2862509442_4f5dc96dca.jpg
876
+ 2899089320_3e7f6bbaca.jpg
877
+ 2398605966_1d0c9e6a20.jpg
878
+ 3362805914_72f60ee8cb.jpg
879
+ 3640348910_fcd627ec66.jpg
880
+ 2126950128_74a4882658.jpg
881
+ 3234401637_84e0d14414.jpg
882
+ 2882743431_c3e6cd1b5c.jpg
883
+ 2381583688_a6dd0a7279.jpg
884
+ 3691670743_0ed111bcf3.jpg
885
+ 3582742297_1daa29968e.jpg
886
+ 512101751_05a6d93e19.jpg
887
+ 3635577874_48ebaac734.jpg
888
+ 241345323_f53eb5eec4.jpg
889
+ 3514297698_0512623955.jpg
890
+ 3139393607_f0a54ca46d.jpg
891
+ 3334953664_a669038795.jpg
892
+ 1515025681_999199cb79.jpg
893
+ 472860064_a96a228796.jpg
894
+ 273248777_eaf0288ab3.jpg
895
+ 2052702658_da1204f6d1.jpg
896
+ 559102835_472ff702b5.jpg
897
+ 708945669_08e7ffb9a7.jpg
898
+ 2301867590_98c0ecb0cb.jpg
899
+ 3726170067_094cc1b7e5.jpg
900
+ 543940240_a54a3c7989.jpg
901
+ 3503624011_733d745d5a.jpg
902
+ 3337046794_296bd2c7e0.jpg
903
+ 1248734482_3038218f3b.jpg
904
+ 3207343907_995f7ac1d2.jpg
905
+ 3702038926_966fdaa311.jpg
906
+ 2054869561_ff723e9eab.jpg
907
+ 3208032657_27b9d6c4f3.jpg
908
+ 3695064885_a6922f06b2.jpg
909
+ 146577645_91b570c0d0.jpg
910
+ 468102269_135938e209.jpg
911
+ 2109911919_af45b93ef3.jpg
912
+ 3050606344_af711c726c.jpg
913
+ 2699342860_5288e203ea.jpg
914
+ 3427023324_f1f6504bf4.jpg
915
+ 3661239105_973f8216c4.jpg
916
+ 765298136_7805fbb079.jpg
917
+ 3323952123_deb50b0629.jpg
918
+ 2337919839_df83827fa0.jpg
919
+ 2724485630_7d2452df00.jpg
920
+ 3506560025_8d0f4f9ac4.jpg
921
+ 2710280476_dcccb8745a.jpg
922
+ 3554634863_5f6f616639.jpg
923
+ 1957371533_62bc720bac.jpg
924
+ 3477683327_d9e6a2a64f.jpg
925
+ 3000722396_1ae2e976c2.jpg
926
+ 2622624460_207dbcc4cf.jpg
927
+ 3225296260_2ee72b4917.jpg
928
+ 418357172_bdddf71d32.jpg
929
+ 2848571082_26454cb981.jpg
930
+ 3747543364_bf5b548527.jpg
931
+ 3280173193_98c2d6a223.jpg
932
+ 3500505549_d848209837.jpg
933
+ 1244140539_da4804d828.jpg
934
+ 3561639055_5ac66ae92f.jpg
935
+ 2846843520_b0e6211478.jpg
936
+ 3543600125_223747ef4c.jpg
937
+ 401079494_562454c4d6.jpg
938
+ 2561481438_447b852e4d.jpg
939
+ 2975073156_7543ed326f.jpg
940
+ 3486135177_772628d034.jpg
941
+ 3204081508_0e7f408097.jpg
942
+ 3592968286_b63c81bcd2.jpg
943
+ 3211437611_bd4af3730b.jpg
944
+ 3467843559_a457ce37b6.jpg
945
+ 1398613231_18de248606.jpg
946
+ 3655964639_21e76383d0.jpg
947
+ 3432586199_e50b0d6cb7.jpg
948
+ 3358558292_6ab14193ed.jpg
949
+ 422763475_0bc814dac6.jpg
950
+ 2306674172_dc07c7f847.jpg
951
+ 2701042060_92508ea8fa.jpg
952
+ 2476214153_99a3998509.jpg
953
+ 3356642567_f1d92cb81b.jpg
954
+ 3405100926_e96308ce89.jpg
955
+ 2659183350_730951f740.jpg
956
+ 1082379191_ec1e53f996.jpg
957
+ 3066338314_2c3fb731d1.jpg
958
+ 2488795251_c108c77b13.jpg
959
+ 3362049454_ea0c22e57b.jpg
960
+ 416106657_cab2a107a5.jpg
961
+ 146098876_0d99d7fb98.jpg
962
+ 1392272228_cf104086e6.jpg
963
+ 3571147934_d1c8af1d6e.jpg
964
+ 327621377_0bc3b7fd26.jpg
965
+ 3579686259_b1fe6aefc9.jpg
966
+ 3092370204_029b6bc10a.jpg
967
+ 3283626303_8e23d4a842.jpg
968
+ 2137071442_1c9658c81a.jpg
969
+ 2057305043_952b8dc82c.jpg
970
+ 1355945307_f9e01a9a05.jpg
971
+ 774009278_8e75b7d498.jpg
972
+ 3684680947_f1c460242f.jpg
973
+ 755326139_ee344ece7b.jpg
974
+ 3594029059_cee1f4c59a.jpg
975
+ 732468337_a37075225e.jpg
976
+ 2103361407_4ed4fc46bf.jpg
977
+ 2229179070_dc8ea8582e.jpg
978
+ 3042173467_14394234da.jpg
979
+ 525538142_7348f0bce7.jpg
980
+ 3217266166_4e0091860b.jpg
981
+ 2908466042_bf07cb52c7.jpg
982
+ 3287904625_f68ca5cea7.jpg
983
+ 3589367895_5d3729e3ea.jpg
984
+ 2097407245_c798e0dcaf.jpg
985
+ 2465497494_43d74df57c.jpg
986
+ 3165123595_8db9f918bf.jpg
987
+ 118187095_d422383c81.jpg
988
+ 3442978981_53bf1f45f3.jpg
989
+ 3687996569_99163a41c3.jpg
990
+ 3615239961_62b4dbc174.jpg
991
+ 3264337159_e1680a35ba.jpg
992
+ 2308256827_3c0a7d514d.jpg
993
+ 872135364_8c1e47d163.jpg
994
+ 3051125715_db76cebd1e.jpg
995
+ 3352871762_c9e88592d3.jpg
996
+ 2675397335_1dcdbd12f5.jpg
997
+ 293881927_ac62900fd4.jpg
998
+ 210686241_b8e069fff3.jpg
999
+ 2839038702_e168128665.jpg
1000
+ 507758961_e63ca126cc.jpg
data/tokenizer.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4259bd8e0679f78ff16c836a41cc93c7163e4d4633c9ce4ac08d3083f7dc22ff
3
+ size 302632
data/train_images.txt ADDED
The diff for this file is too large to render. See raw diff
 
data/val_images.txt ADDED
@@ -0,0 +1,1000 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 3036596725_541bbe0955.jpg
2
+ 3440104178_6871a24e13.jpg
3
+ 3667492609_97f88b373f.jpg
4
+ 2844963839_ff09cdb81f.jpg
5
+ 2862469183_a4334b904a.jpg
6
+ 3326204251_2f9e446a2f.jpg
7
+ 3470951932_27ed74eb0b.jpg
8
+ 2873065944_29c01782e2.jpg
9
+ 3612825666_54f5a2bc06.jpg
10
+ 2150564996_d173a506d7.jpg
11
+ 365128300_6966058139.jpg
12
+ 2752230113_b5dab6f0f1.jpg
13
+ 206087108_d4557d38ee.jpg
14
+ 862177617_c2c0581075.jpg
15
+ 3561433412_3985208d53.jpg
16
+ 1470132731_fa416b7504.jpg
17
+ 486300784_2cc7a770ff.jpg
18
+ 3271178748_630d269811.jpg
19
+ 2291511815_ac083fddbd.jpg
20
+ 2972864304_481aeffe50.jpg
21
+ 2991375936_bf4b0a7dc0.jpg
22
+ 3242354561_54e5a34925.jpg
23
+ 2638369467_8fc251595b.jpg
24
+ 2812590023_50182bc417.jpg
25
+ 3094278545_febac56382.jpg
26
+ 534313000_4ad39c7ee0.jpg
27
+ 2068465241_3bcabacfd7.jpg
28
+ 1032122270_ea6f0beedb.jpg
29
+ 390360326_26f5936189.jpg
30
+ 263850317_5bb3a18a08.jpg
31
+ 2612949583_f45b3afe33.jpg
32
+ 3321063116_4e5deeac83.jpg
33
+ 3376435746_1593d9b243.jpg
34
+ 186348874_75b2cf1ec5.jpg
35
+ 3028969146_26929ae0e8.jpg
36
+ 3265864834_e0229020dd.jpg
37
+ 1312954382_cf6d70d63a.jpg
38
+ 1731546544_9fbf14617b.jpg
39
+ 488416045_1c6d903fe0.jpg
40
+ 2589308405_e208b5e745.jpg
41
+ 3608752424_01a1cfd8a6.jpg
42
+ 3704995657_e2e114083d.jpg
43
+ 102455176_5f8ead62d5.jpg
44
+ 2716251485_d6113f4c8a.jpg
45
+ 2060031241_a3ae7a06bb.jpg
46
+ 2073174497_18b779999c.jpg
47
+ 2115620856_4fa5025ac6.jpg
48
+ 3590294974_4ef98f013e.jpg
49
+ 2225241766_f1e7132e3e.jpg
50
+ 3222496967_45d468ee66.jpg
51
+ 3730011701_5352e02286.jpg
52
+ 498748832_941faaaf40.jpg
53
+ 1308472581_9961782889.jpg
54
+ 3329289652_e09b80e2f3.jpg
55
+ 2500354186_0836309cc9.jpg
56
+ 2218609886_892dcd6915.jpg
57
+ 2598979962_c01811cfca.jpg
58
+ 1522787272_5a31497ef2.jpg
59
+ 2286032269_8ba929709c.jpg
60
+ 3070274658_fc39fd4f84.jpg
61
+ 3330019493_fd36fbc2ea.jpg
62
+ 2218843713_cf28ea319e.jpg
63
+ 3523920786_0eb63993fd.jpg
64
+ 3245070961_8977fdd548.jpg
65
+ 2960422620_81889a3764.jpg
66
+ 2641770481_c98465ff35.jpg
67
+ 3401333624_4b6af8c1d7.jpg
68
+ 210126070_0d43b300b9.jpg
69
+ 3259883609_6a1b46919e.jpg
70
+ 3216085740_699c2ce1ae.jpg
71
+ 3606846822_28c40b933a.jpg
72
+ 3720210639_18bb34e475.jpg
73
+ 248994078_a9257f448b.jpg
74
+ 3376972502_35e3e119cd.jpg
75
+ 3584196366_a4b43d6644.jpg
76
+ 2385871165_9438c9fe84.jpg
77
+ 3713324467_104d72f7db.jpg
78
+ 455856615_f6361d9253.jpg
79
+ 3375920709_ef7370fa09.jpg
80
+ 2466171114_3fa51415a7.jpg
81
+ 1324816249_86600a6759.jpg
82
+ 2328104318_5a43ca170c.jpg
83
+ 2472980433_210ec62874.jpg
84
+ 1547883892_e29b3db42e.jpg
85
+ 2903469015_a1e7d969c2.jpg
86
+ 2603033456_3584d95116.jpg
87
+ 2514612680_b0d2d77099.jpg
88
+ 3094064787_aed1666fc9.jpg
89
+ 3760400645_3ba51d27f9.jpg
90
+ 3027397797_4f1d305ced.jpg
91
+ 2953015871_cae796b6e7.jpg
92
+ 270816949_ffad112278.jpg
93
+ 3212456649_40a3052682.jpg
94
+ 3339768802_8ab768558a.jpg
95
+ 461505235_590102a5bf.jpg
96
+ 464251704_b0f0c4c87a.jpg
97
+ 1507563902_6ec8d5d822.jpg
98
+ 3263497678_8bb688ca01.jpg
99
+ 262642489_f5c6b9e65b.jpg
100
+ 3026102616_3cf350af9e.jpg
101
+ 3163068926_d28ed3ef53.jpg
102
+ 3639428663_dae5e8146e.jpg
103
+ 3364796213_b8948913b5.jpg
104
+ 2396025708_e4a72e2558.jpg
105
+ 267164457_2e8b4d30aa.jpg
106
+ 3640329164_20cb245fd5.jpg
107
+ 2393911878_68afe6e6c1.jpg
108
+ 2518853257_02f30e282e.jpg
109
+ 2882056260_4399dd4d7c.jpg
110
+ 2599131872_65789d86d5.jpg
111
+ 3168841415_c0705a327a.jpg
112
+ 2236016316_f476cbbf06.jpg
113
+ 3690159129_93ba49ea18.jpg
114
+ 3589267801_5a222e3a60.jpg
115
+ 421932359_edbf181f44.jpg
116
+ 3079917032_3cfacb2fd7.jpg
117
+ 350529848_9569a3bcbc.jpg
118
+ 3533145793_5d69f72e41.jpg
119
+ 2346401538_f5e8da66fc.jpg
120
+ 517094985_4b9e926936.jpg
121
+ 405051459_3b3a3ba5b3.jpg
122
+ 2525232298_cf42d415ab.jpg
123
+ 2602258549_7401a3cdae.jpg
124
+ 134724228_30408cd77f.jpg
125
+ 429283612_37f6e7fb7f.jpg
126
+ 2851931813_eaf8ed7be3.jpg
127
+ 3354075558_3b67eaa502.jpg
128
+ 3597921737_3fd1d0665b.jpg
129
+ 694496803_f2a05869cf.jpg
130
+ 3104400277_1524e4f758.jpg
131
+ 1932314876_9cc46fd054.jpg
132
+ 2823575468_15f6c345fc.jpg
133
+ 2394824046_51cec8e5e7.jpg
134
+ 2921670682_6a77a6c3e9.jpg
135
+ 1052358063_eae6744153.jpg
136
+ 3217187564_0ffd89dec1.jpg
137
+ 207237775_fa0a15c6fe.jpg
138
+ 3454199170_ae26917dcd.jpg
139
+ 336551615_a01418bc53.jpg
140
+ 3088922727_4bdf2ccc94.jpg
141
+ 3382303178_69b6d1bdd2.jpg
142
+ 3125158798_0743dae56e.jpg
143
+ 2090386465_b6ebb7df2c.jpg
144
+ 2094323311_27d58b1513.jpg
145
+ 3629492654_619d7b67ee.jpg
146
+ 2280354512_c0d035d53f.jpg
147
+ 2333288869_8c01e4c859.jpg
148
+ 3125628091_25a31709df.jpg
149
+ 3427118504_93126c83e0.jpg
150
+ 3595643050_d312e4b652.jpg
151
+ 3156991513_3bf03333d8.jpg
152
+ 2261257940_449b6e6c91.jpg
153
+ 512045825_1be2083922.jpg
154
+ 534875358_6ea30d3091.jpg
155
+ 2095078658_c14ba89bc2.jpg
156
+ 2697909987_128f11d1b7.jpg
157
+ 3322200641_c2e51ff37b.jpg
158
+ 236518934_c62a133077.jpg
159
+ 224026428_0165164ceb.jpg
160
+ 3009018821_ba47396e24.jpg
161
+ 2269961438_cae7a9c725.jpg
162
+ 2450299735_62c095f40e.jpg
163
+ 3244171699_ace4b5d999.jpg
164
+ 439916996_1ddb9dc8e7.jpg
165
+ 2863027424_9c75105660.jpg
166
+ 247691240_3881777ab8.jpg
167
+ 2062607137_dac194ad02.jpg
168
+ 3280644151_3d89cb1e0e.jpg
169
+ 3109704348_c6416244ce.jpg
170
+ 3155361712_2cbf59c78e.jpg
171
+ 1002674143_1b742ab4b8.jpg
172
+ 2506892928_7e79bec613.jpg
173
+ 2043427251_83b746da8e.jpg
174
+ 271177682_48da79ab33.jpg
175
+ 262446581_06ef7d9445.jpg
176
+ 2447035752_415f4bb152.jpg
177
+ 2347921097_f2e35753c0.jpg
178
+ 3482879314_d3387e95b1.jpg
179
+ 2446601467_a35841cb1d.jpg
180
+ 3338474677_7376e426c2.jpg
181
+ 523249012_a0a25f487e.jpg
182
+ 343662720_39e4067cd1.jpg
183
+ 2711720095_0b98426d3c.jpg
184
+ 1803631090_05e07cc159.jpg
185
+ 1072153132_53d2bb1b60.jpg
186
+ 241347300_7c84ecf764.jpg
187
+ 3051384385_c5c850c1f8.jpg
188
+ 3512033659_7e8a0c2ffa.jpg
189
+ 2655196158_5c878a4af0.jpg
190
+ 2736508369_fd9ff0b42f.jpg
191
+ 207930963_af3a2f1784.jpg
192
+ 481054596_cad8c02103.jpg
193
+ 199463720_329a802206.jpg
194
+ 3171035252_dba286ae5c.jpg
195
+ 2924884815_63826aa60d.jpg
196
+ 2272426567_9e9fb79db0.jpg
197
+ 2975807155_5a8610c297.jpg
198
+ 2059842472_f4fb61ea08.jpg
199
+ 3398788809_25c71ba018.jpg
200
+ 3450776690_38605c667d.jpg
201
+ 3446347599_0ecc49a9d5.jpg
202
+ 3278777548_290b881018.jpg
203
+ 2429978680_1e18a13835.jpg
204
+ 3346614841_698f9aa486.jpg
205
+ 101654506_8eb26cfb60.jpg
206
+ 292887910_f34ac101c8.jpg
207
+ 3397259310_1ed1a346b5.jpg
208
+ 2295894587_2fd8faf550.jpg
209
+ 195962790_3380aea352.jpg
210
+ 3627290893_561e176e80.jpg
211
+ 3578841731_f775cab089.jpg
212
+ 3109688427_d2e702456c.jpg
213
+ 2505988632_9541f15583.jpg
214
+ 367673290_f8799f3a85.jpg
215
+ 925491651_57df3a5b36.jpg
216
+ 2549968784_39bfbe44f9.jpg
217
+ 2088532947_c628e44c4a.jpg
218
+ 3208074567_ac44aeb3f3.jpg
219
+ 2681215810_00b0642f7b.jpg
220
+ 3527682660_c5e9fa644a.jpg
221
+ 1781227288_6811e734be.jpg
222
+ 1423997242_ea2189ec5e.jpg
223
+ 3183777589_460a4f445b.jpg
224
+ 3524519277_bd0c3e7382.jpg
225
+ 1159574340_99ba8c3c59.jpg
226
+ 2477121456_1ac5c6d3e4.jpg
227
+ 3667822570_d39850e217.jpg
228
+ 2190137367_746335f707.jpg
229
+ 2950637275_98f1e30cca.jpg
230
+ 2481490320_7978c76271.jpg
231
+ 3030824089_e5a840265e.jpg
232
+ 267836606_bbea2267c8.jpg
233
+ 3206058778_7053ee6b52.jpg
234
+ 3195040792_a03954a19f.jpg
235
+ 3595080592_5fd55570e5.jpg
236
+ 3560891822_7d4c1e3580.jpg
237
+ 3177468217_56a9142e46.jpg
238
+ 2611651553_61f859837e.jpg
239
+ 2224450291_4c133fabe8.jpg
240
+ 241345942_ea76966542.jpg
241
+ 2954525375_9d5ca97341.jpg
242
+ 1303727828_d1052ee341.jpg
243
+ 3263215700_e27f81f8b9.jpg
244
+ 958326692_6210150354.jpg
245
+ 1287073593_f3d2a62455.jpg
246
+ 688940111_325a74674a.jpg
247
+ 322103537_184367bf88.jpg
248
+ 247706586_7e25c7adf8.jpg
249
+ 485054073_fef8b80b4b.jpg
250
+ 613030608_4355e007c7.jpg
251
+ 1975171469_84e425f61b.jpg
252
+ 3512791890_eb065b460a.jpg
253
+ 3043908909_bb54d2c08e.jpg
254
+ 664341930_bd5c8b60ea.jpg
255
+ 934375844_dd149fed18.jpg
256
+ 3658733605_fbcf570843.jpg
257
+ 241347611_cb265be138.jpg
258
+ 3686078365_9e655e238f.jpg
259
+ 3174713468_e22fa7779e.jpg
260
+ 2623939135_0cd02ffa5d.jpg
261
+ 1491192153_7c395991e5.jpg
262
+ 2882589788_cb0b407a8d.jpg
263
+ 181157221_e12410ef0b.jpg
264
+ 1339596997_8ac29c1841.jpg
265
+ 2959500257_3621429a37.jpg
266
+ 2173677067_9d0732bcc2.jpg
267
+ 3422146099_35ffc8680e.jpg
268
+ 839295615_bb9baf2f95.jpg
269
+ 3120189281_1938460e85.jpg
270
+ 2721656220_5f4cda8bc1.jpg
271
+ 2074146683_7c83167aa1.jpg
272
+ 3666056567_661e25f54c.jpg
273
+ 2982928615_06db40f4cd.jpg
274
+ 3085973779_29f44fbdaa.jpg
275
+ 1053804096_ad278b25f1.jpg
276
+ 3199645963_a681fe04f8.jpg
277
+ 3159641529_c2c74f3eaf.jpg
278
+ 2806710650_e201acd913.jpg
279
+ 3364797223_1f0b2f98ed.jpg
280
+ 97406261_5eea044056.jpg
281
+ 3351596152_bf283f03d1.jpg
282
+ 2694890967_7c7a89de16.jpg
283
+ 2877503811_4e311253ec.jpg
284
+ 2194495372_bdac7d9e71.jpg
285
+ 453473508_682c0a7189.jpg
286
+ 1579206585_5ca6a24db0.jpg
287
+ 808245064_8a7971fc5b.jpg
288
+ 2297744130_f571f3a239.jpg
289
+ 3208571574_6dc1a461c5.jpg
290
+ 2831578193_3c997ae330.jpg
291
+ 2079110798_ad1370a646.jpg
292
+ 260850192_fd03ea26f1.jpg
293
+ 3329777647_5e1fd503ac.jpg
294
+ 441398149_297146e38d.jpg
295
+ 3618504267_d7eaa495d0.jpg
296
+ 3268908792_c24529fe88.jpg
297
+ 1998255400_0cd086908f.jpg
298
+ 2317714088_bcd081f926.jpg
299
+ 278388986_78ba84eb8f.jpg
300
+ 3150252702_828a570d46.jpg
301
+ 160566014_59528ff897.jpg
302
+ 3192266178_f9bf5d3dba.jpg
303
+ 3053743109_a2d780c0d2.jpg
304
+ 1398606571_f543f7698a.jpg
305
+ 3174453534_fcc927c647.jpg
306
+ 735787579_617b047319.jpg
307
+ 3490597800_8f94f7d353.jpg
308
+ 3091921457_83eee69591.jpg
309
+ 140377584_12bdbdf2f8.jpg
310
+ 3265162450_5b4e3c5f1b.jpg
311
+ 3337332770_5eda5cceb7.jpg
312
+ 3653837067_94050699ec.jpg
313
+ 2912476706_9a0dbd3a67.jpg
314
+ 1057210460_09c6f4c6c1.jpg
315
+ 3439982121_0afc6d5973.jpg
316
+ 565605894_8f0bed0438.jpg
317
+ 84713990_d3f3cef78b.jpg
318
+ 2999730677_0cfa1c146e.jpg
319
+ 3021780428_497542a072.jpg
320
+ 470887795_8443ce53d0.jpg
321
+ 3350785999_462f333c44.jpg
322
+ 3371887001_44ab0c2f17.jpg
323
+ 69189650_6687da7280.jpg
324
+ 2609847254_0ec40c1cce.jpg
325
+ 3430607596_7e4f74e3ff.jpg
326
+ 2410399168_1462c422d4.jpg
327
+ 639120223_7db6bdb61f.jpg
328
+ 3634032601_2236676cdd.jpg
329
+ 3108378861_d2214d971e.jpg
330
+ 531261613_f1a045cd75.jpg
331
+ 1356543628_c13ebe38fb.jpg
332
+ 1253264731_e7c689eca5.jpg
333
+ 300500054_56653bf217.jpg
334
+ 225699652_53f6fb33cd.jpg
335
+ 469259974_bb03c15c42.jpg
336
+ 656260720_a7db4ce48b.jpg
337
+ 3069037969_bb7319e0dc.jpg
338
+ 2999162229_80d17099b6.jpg
339
+ 135235570_5698072cd4.jpg
340
+ 3579842996_3a62ec1bc7.jpg
341
+ 2815745115_c8479d560c.jpg
342
+ 543603259_ef26d9c72d.jpg
343
+ 2853407781_c9fea8eef4.jpg
344
+ 640203018_c0e7175831.jpg
345
+ 2578289278_01516d23a0.jpg
346
+ 3141613533_595723208d.jpg
347
+ 2971431335_e192613db4.jpg
348
+ 2294598473_40637b5c04.jpg
349
+ 1198194316_543cc7b945.jpg
350
+ 3143953179_1c08c023a5.jpg
351
+ 3665569615_9a71c4b6e4.jpg
352
+ 2976946039_fb9147908d.jpg
353
+ 3149038044_c7c94688c6.jpg
354
+ 3341782693_426bf7139b.jpg
355
+ 3628017876_4ac27e687b.jpg
356
+ 3544233095_4bca71df1d.jpg
357
+ 3639704469_fe83e1c9b7.jpg
358
+ 2080033499_6be742f483.jpg
359
+ 1077931201_1e0bb83105.jpg
360
+ 2216695423_1362cb25f3.jpg
361
+ 3459858555_c3f0087a72.jpg
362
+ 3337461409_e4e317853d.jpg
363
+ 3661072592_2e693cd5a0.jpg
364
+ 2510560080_1439fe32f2.jpg
365
+ 2318721455_80c6644441.jpg
366
+ 1167669558_87a8a467d6.jpg
367
+ 3576060775_d9121519cc.jpg
368
+ 1454678644_7e5a371301.jpg
369
+ 3532593368_be10432e92.jpg
370
+ 3199895624_4f01798c6f.jpg
371
+ 3076052114_233f42ae5b.jpg
372
+ 241345596_91e0e2daf5.jpg
373
+ 182493240_40410254b0.jpg
374
+ 241346794_4319f8af67.jpg
375
+ 365274901_576b0f8241.jpg
376
+ 3549006919_3604bc813e.jpg
377
+ 3209523192_05a4cef844.jpg
378
+ 3275065565_9e2a640fbc.jpg
379
+ 2706766641_a9df81969d.jpg
380
+ 3613585080_36629d8157.jpg
381
+ 3139876823_859c7d7c23.jpg
382
+ 2255338013_566127590b.jpg
383
+ 413231421_43833a11f5.jpg
384
+ 275401000_8829250eb3.jpg
385
+ 1231229740_8dcbf80bfb.jpg
386
+ 2176874361_2b4149010b.jpg
387
+ 2485467050_1d5e2696d4.jpg
388
+ 3666574371_317b008d2a.jpg
389
+ 3665996775_6d7d9a46f1.jpg
390
+ 1163282319_b729b24c46.jpg
391
+ 3123351642_3794f2f601.jpg
392
+ 3283913180_7d4e43602d.jpg
393
+ 3616638478_641d02183d.jpg
394
+ 2913972180_547783dd3d.jpg
395
+ 3262760716_1e9734f5ba.jpg
396
+ 2757803246_8aa3499d26.jpg
397
+ 303607405_f36edf16c6.jpg
398
+ 2271755053_e1b1ec8442.jpg
399
+ 3497238310_2abde3965d.jpg
400
+ 528500099_7be78a0ca5.jpg
401
+ 3643684688_2f7157b23d.jpg
402
+ 3447876218_4ccf42d7a0.jpg
403
+ 2995461857_dd26188dcf.jpg
404
+ 434938585_fbf913dfb4.jpg
405
+ 3263946591_a1558b77d3.jpg
406
+ 2826574228_c63009e473.jpg
407
+ 2799871904_3b3125518a.jpg
408
+ 3726120436_740bda8416.jpg
409
+ 2394267183_735d2dc868.jpg
410
+ 279230262_e541f9b670.jpg
411
+ 1433397131_8634fa6664.jpg
412
+ 3534548254_7bee952a0e.jpg
413
+ 3662871327_b128d25f04.jpg
414
+ 3589156060_3ed8d6bbc3.jpg
415
+ 1572532018_64c030c974.jpg
416
+ 3156113206_53c2a7b5d8.jpg
417
+ 3269895626_7b253c82ed.jpg
418
+ 3682038869_585075b5ff.jpg
419
+ 2493974889_50ae29f1e1.jpg
420
+ 3107059919_0594269f72.jpg
421
+ 3622216490_1314a58b66.jpg
422
+ 2358561039_e215a8d6cd.jpg
423
+ 3245266444_2e798096e6.jpg
424
+ 3413973568_6630e5cdac.jpg
425
+ 3468023754_8a07d4c56e.jpg
426
+ 377872472_35805fc143.jpg
427
+ 1055753357_4fa3d8d693.jpg
428
+ 3407584080_c6abf71ae3.jpg
429
+ 2501942587_e59b91d1da.jpg
430
+ 3078229723_2aa52600de.jpg
431
+ 2528489543_546c1ca81f.jpg
432
+ 109202756_b97fcdc62c.jpg
433
+ 3601508034_5a3bfc905e.jpg
434
+ 861795382_5145ad433d.jpg
435
+ 2689491604_d8760f57b4.jpg
436
+ 2867736861_43c9487a65.jpg
437
+ 2495931537_9b8d4474b6.jpg
438
+ 142802798_962a4ec5ce.jpg
439
+ 2481598514_05a65d1f72.jpg
440
+ 2650485780_29d89268d7.jpg
441
+ 2244613488_4d1f9edb33.jpg
442
+ 480607352_65614ab348.jpg
443
+ 2932519416_11f23b6297.jpg
444
+ 2245914678_1f82fc3d80.jpg
445
+ 1280147517_98767ca3b3.jpg
446
+ 3692593096_fbaea67476.jpg
447
+ 267015208_d80b3eb94d.jpg
448
+ 3228960484_9aab98b91a.jpg
449
+ 2661138991_d55aa0e5dc.jpg
450
+ 2891185857_54942809cf.jpg
451
+ 2868575889_2c030aa8ae.jpg
452
+ 3084731832_8e518e320d.jpg
453
+ 272156850_c4445a53f4.jpg
454
+ 3271061953_700b96520c.jpg
455
+ 3148571800_c5515e6c3d.jpg
456
+ 2505360288_c972bd29c4.jpg
457
+ 2696636252_91ef1491ea.jpg
458
+ 2718049631_e7aa74cb9b.jpg
459
+ 3246190363_68d903bfcb.jpg
460
+ 3393035454_2d2370ffd4.jpg
461
+ 2271890493_da441718ba.jpg
462
+ 515797344_4ae75cb9b1.jpg
463
+ 446514680_ff5ca15ece.jpg
464
+ 3607969989_68cc411493.jpg
465
+ 3707283973_5cdaa39340.jpg
466
+ 618292739_0fdc2ccab0.jpg
467
+ 3310067561_b92017acab.jpg
468
+ 3478176372_7c510a0cef.jpg
469
+ 2232518012_8cb0bbc43b.jpg
470
+ 419116771_642800891d.jpg
471
+ 782401952_5bc5d3413a.jpg
472
+ 3587449716_3bf1552c36.jpg
473
+ 233242340_09963100a3.jpg
474
+ 445148321_9f2f3ac711.jpg
475
+ 2869253972_aa72df6bf3.jpg
476
+ 3220140234_e072856e6c.jpg
477
+ 326456451_effadbbe49.jpg
478
+ 514905846_b54d13946a.jpg
479
+ 3272847211_9e8a4f8308.jpg
480
+ 2986620935_e97763983d.jpg
481
+ 3517056462_483ee5a914.jpg
482
+ 2447972568_1e9b287691.jpg
483
+ 1469358746_2a879abaf3.jpg
484
+ 3136043366_b3f8607a0e.jpg
485
+ 224702242_a62aaa6dff.jpg
486
+ 3441531010_8eebbb507e.jpg
487
+ 2072574835_febf0c5fb9.jpg
488
+ 2937461473_11bbace28c.jpg
489
+ 3015368588_ef0a06076d.jpg
490
+ 3152317129_177b4678b7.jpg
491
+ 2862481071_86c65d46fa.jpg
492
+ 2537583012_4a358a6a8a.jpg
493
+ 189740668_0b045f1ff2.jpg
494
+ 3191135894_2b4bdabb6d.jpg
495
+ 3537218226_478d2e4f26.jpg
496
+ 3528105511_12ff45dc9c.jpg
497
+ 2082005167_a0d6a70020.jpg
498
+ 1991806812_065f747689.jpg
499
+ 3313232606_4ce7e16b87.jpg
500
+ 3159569570_dff24e7be9.jpg
501
+ 1187435567_18173c148b.jpg
502
+ 3432634159_1eb9a73306.jpg
503
+ 3216926094_bc975e84b9.jpg
504
+ 3091177347_58c85c1c3b.jpg
505
+ 2649406158_ded6be38de.jpg
506
+ 541063517_35044c554a.jpg
507
+ 224766705_b77996527f.jpg
508
+ 3350671534_2a5d45a961.jpg
509
+ 458183774_afe65abf67.jpg
510
+ 3386375153_20c56d0aae.jpg
511
+ 3656206975_09e6ce58bd.jpg
512
+ 494921598_af73bda568.jpg
513
+ 2895403073_906768cafa.jpg
514
+ 2897832422_0cbdb1421e.jpg
515
+ 1351315701_6580b51c41.jpg
516
+ 3484906808_ee20714408.jpg
517
+ 2633082074_32c85f532c.jpg
518
+ 519754987_51861fea85.jpg
519
+ 3529721084_4b405baf54.jpg
520
+ 3500115252_9404c066a8.jpg
521
+ 512550372_438849ce19.jpg
522
+ 3187117682_986ffd6b67.jpg
523
+ 200771289_31902164a7.jpg
524
+ 2840344516_8e15fe2668.jpg
525
+ 2938875913_0ed920a6be.jpg
526
+ 3365783912_e12c3510d8.jpg
527
+ 377872672_d499aae449.jpg
528
+ 107318069_e9f2ef32de.jpg
529
+ 3551170666_01df31412d.jpg
530
+ 3108732084_565b423162.jpg
531
+ 2937178897_ab3d1a941a.jpg
532
+ 3565598162_56044bc2f7.jpg
533
+ 2444134813_20895c640c.jpg
534
+ 2300920203_f29260b1db.jpg
535
+ 3279988814_d3693dcb6c.jpg
536
+ 3285214689_f0219e9671.jpg
537
+ 3130064588_6d1d3fa2dd.jpg
538
+ 2905948395_ca3e6b3c9a.jpg
539
+ 3514188115_f51932ae5d.jpg
540
+ 3292016893_24d14c8b4f.jpg
541
+ 2084103826_ffd76b1e3e.jpg
542
+ 3468130925_2b1489d19a.jpg
543
+ 2893476169_f38dd32051.jpg
544
+ 252504549_135b0db5a3.jpg
545
+ 661749711_6f408dad62.jpg
546
+ 3329254388_27017bab30.jpg
547
+ 3679707139_1cc1e71237.jpg
548
+ 283428775_a3665bee7c.jpg
549
+ 3412249548_00820fc4ca.jpg
550
+ 1881494074_1bebd93089.jpg
551
+ 518789868_8895ef8792.jpg
552
+ 2949497756_be8e58e6bd.jpg
553
+ 1313693129_71d0b21c63.jpg
554
+ 872622575_ba1d3632cc.jpg
555
+ 3213395965_2a823c6865.jpg
556
+ 411216802_aead9e67e3.jpg
557
+ 2582390123_71120edb0c.jpg
558
+ 2707969386_94dde00ce4.jpg
559
+ 2496399593_a24954a5ca.jpg
560
+ 2922222717_12195af92d.jpg
561
+ 1801188148_a176954965.jpg
562
+ 2085400856_ae09df33a7.jpg
563
+ 3730011219_588cdc7972.jpg
564
+ 2557922709_24d2a9655a.jpg
565
+ 2095444126_201ff9f222.jpg
566
+ 2874984466_1aafec2c9f.jpg
567
+ 241345446_2e47ae8ddc.jpg
568
+ 3636632926_09f39f2629.jpg
569
+ 3189964753_a95536ced9.jpg
570
+ 3409506817_775e38d219.jpg
571
+ 2399219552_bbba0a9a59.jpg
572
+ 3346711367_5e7b29e20f.jpg
573
+ 1357724865_4faf4e1418.jpg
574
+ 3016521240_2ef20834b6.jpg
575
+ 3153067758_53f003b1df.jpg
576
+ 1732436777_950bcdc9b8.jpg
577
+ 293327462_20dee0de56.jpg
578
+ 3349955993_a04aea97d8.jpg
579
+ 3295418287_5d590dac43.jpg
580
+ 2089350172_dc2cf9fcf6.jpg
581
+ 527272653_8a5bd818e5.jpg
582
+ 444803340_fdcaab86f9.jpg
583
+ 2540203582_9a9ac92a5d.jpg
584
+ 270724499_107481c88f.jpg
585
+ 3259110412_9908c45144.jpg
586
+ 3331102049_bc65cf6198.jpg
587
+ 390992102_67fa31b22f.jpg
588
+ 469969326_4b84073286.jpg
589
+ 391106734_d374bc3080.jpg
590
+ 3362871440_6c0f27c480.jpg
591
+ 3503544012_1771be9d3a.jpg
592
+ 2977379863_2e8d7a104e.jpg
593
+ 3264937930_9623496b64.jpg
594
+ 3366571152_20afb88ac1.jpg
595
+ 2467850190_07a74d89b7.jpg
596
+ 3122606953_a979dd3d33.jpg
597
+ 3259160693_067ec7ebc3.jpg
598
+ 3636055584_65a60426f8.jpg
599
+ 3366105287_49a4bf71c6.jpg
600
+ 3745451546_fc8ec70cbd.jpg
601
+ 3301935788_2bb7bbc515.jpg
602
+ 533979933_a95b03323b.jpg
603
+ 3319899418_4bcf1b00d8.jpg
604
+ 2987328689_96a2d814f1.jpg
605
+ 3605100550_01214a1224.jpg
606
+ 466176275_f40d37851e.jpg
607
+ 95734038_2ab5783da7.jpg
608
+ 3639967449_137f48b43d.jpg
609
+ 1396064003_3fd949c9dd.jpg
610
+ 3738685861_8dfff28760.jpg
611
+ 466956675_a2fb6bf901.jpg
612
+ 1479857177_9d4a6f38fd.jpg
613
+ 3584534971_b44f82c4b9.jpg
614
+ 505929313_7668f021ab.jpg
615
+ 3319586526_3994e9cd58.jpg
616
+ 314603661_51e05e0e24.jpg
617
+ 3597354819_0069aaf16e.jpg
618
+ 2952751562_ff1c138286.jpg
619
+ 1244306891_8e78ae1620.jpg
620
+ 2255332561_3375897ff0.jpg
621
+ 2951092164_4940b9a517.jpg
622
+ 2705947033_5999147842.jpg
623
+ 3516825206_5750824874.jpg
624
+ 3319489465_c65c91e4f2.jpg
625
+ 3610683688_bbe6d725ed.jpg
626
+ 324208502_674488bcea.jpg
627
+ 3099965396_2a0018cb9e.jpg
628
+ 2426724282_237bca30b5.jpg
629
+ 824123145_59243e504e.jpg
630
+ 2760371526_63f3d01760.jpg
631
+ 2826769554_85c90864c9.jpg
632
+ 2200901777_f6c168bd32.jpg
633
+ 3620492762_7f6a9b4746.jpg
634
+ 2367317953_503317493e.jpg
635
+ 2929272606_2a5923b38e.jpg
636
+ 2943079526_e9033a6556.jpg
637
+ 3672105509_53b13b2ed4.jpg
638
+ 2755952680_68a0a1fa42.jpg
639
+ 241347204_007d83e252.jpg
640
+ 3419238351_ac18b440c0.jpg
641
+ 3041689520_c481bdb20e.jpg
642
+ 2915183095_4ed4aa4f37.jpg
643
+ 2914800692_0c512d27b8.jpg
644
+ 2966190737_ceb6eb4b53.jpg
645
+ 380527679_574749123d.jpg
646
+ 3333675897_0043f992d3.jpg
647
+ 3516267455_ca17cc1323.jpg
648
+ 2936590102_25036069a6.jpg
649
+ 1569562856_eedb5a0a1f.jpg
650
+ 2834103050_512e5b330a.jpg
651
+ 3726700898_c50494b8bd.jpg
652
+ 1131932671_c8d17751b3.jpg
653
+ 799199774_142b1c3bb2.jpg
654
+ 306315650_e064f5c677.jpg
655
+ 2785115802_137fa30000.jpg
656
+ 3400385314_a5bc062e97.jpg
657
+ 319847643_df7c2a1d25.jpg
658
+ 2964438493_413667c04a.jpg
659
+ 2709683703_5385ea9ef4.jpg
660
+ 1998457059_c9ac9a1e1a.jpg
661
+ 2364774105_fbaf0c191f.jpg
662
+ 2094543127_46d2f1fedf.jpg
663
+ 2891240104_6755281868.jpg
664
+ 950273886_88c324e663.jpg
665
+ 2533414541_362bf043bb.jpg
666
+ 482907079_22085ada04.jpg
667
+ 261737543_b8fdc24671.jpg
668
+ 1383698008_8ac53ed7ec.jpg
669
+ 2588625139_fdf6610218.jpg
670
+ 1359101233_16c2c150e3.jpg
671
+ 1975531316_8b00eeaaf7.jpg
672
+ 3540416139_c884f38351.jpg
673
+ 3265209567_b3b9c8e0fe.jpg
674
+ 2873431806_86a56cdae8.jpg
675
+ 3651107058_d84d4c3c25.jpg
676
+ 561417861_8e25d0c0e8.jpg
677
+ 3501083764_cf592292a6.jpg
678
+ 2902269566_419d9f1d8e.jpg
679
+ 3119875880_22f9129a1c.jpg
680
+ 424869823_7aec015d87.jpg
681
+ 2509824208_247aca3ea3.jpg
682
+ 242109387_e497277e07.jpg
683
+ 1931690777_897a7d8ab6.jpg
684
+ 890734502_a5ae67beac.jpg
685
+ 2695962887_a1647c567b.jpg
686
+ 1100214449_d10861e633.jpg
687
+ 3148811252_2fa9490a04.jpg
688
+ 3030294889_78b2ccbe51.jpg
689
+ 2766854400_640e2abe08.jpg
690
+ 2596100297_372bd0f739.jpg
691
+ 3710520638_866d542a80.jpg
692
+ 3646970605_d25c25340b.jpg
693
+ 405253184_5f611f3880.jpg
694
+ 2878578240_caf64c3b19.jpg
695
+ 3538213870_9856a76b2a.jpg
696
+ 3578981202_efef47e264.jpg
697
+ 3508051251_82422717b3.jpg
698
+ 3694064560_467683205b.jpg
699
+ 416788726_5b4eb1466e.jpg
700
+ 3516521516_9950340b96.jpg
701
+ 2753531542_ace2c870b7.jpg
702
+ 490044494_d2d546be8d.jpg
703
+ 2775744946_1ab5d500a2.jpg
704
+ 2429212017_77fc107699.jpg
705
+ 3458625738_297857369c.jpg
706
+ 322791392_aa3b142f43.jpg
707
+ 2427490900_5b7a8874b9.jpg
708
+ 268654674_d29e00b3d0.jpg
709
+ 2552723989_7bc93e0f7b.jpg
710
+ 3383388869_a14552e551.jpg
711
+ 2584487952_f70e5aa9bf.jpg
712
+ 2085255128_61224cc47f.jpg
713
+ 2837808847_5407af1986.jpg
714
+ 2169067981_cc19268f23.jpg
715
+ 2667549961_57e5e2c0a5.jpg
716
+ 2540326842_bb26cec999.jpg
717
+ 141755292_7a0b3364cf.jpg
718
+ 2074764331_90a9962b52.jpg
719
+ 2220185725_45d4fa68d9.jpg
720
+ 1449625950_fc9a8d02d9.jpg
721
+ 247778426_fd59734130.jpg
722
+ 482088914_e6ea4501e9.jpg
723
+ 3466353172_deb128bbb0.jpg
724
+ 3457460673_800d7f7dd9.jpg
725
+ 3425756814_13909354d4.jpg
726
+ 3647693147_0d0434351b.jpg
727
+ 2199200615_85e4c2a602.jpg
728
+ 3613375729_d0b3c41556.jpg
729
+ 2678798732_2998f9969c.jpg
730
+ 3461049169_e068ae4f25.jpg
731
+ 58368365_03ed3e5bdf.jpg
732
+ 2461616306_3ee7ac1b4b.jpg
733
+ 2851304910_b5721199bc.jpg
734
+ 3099504809_565e17e49d.jpg
735
+ 2521938720_911ac092f7.jpg
736
+ 3012513414_86180c44cb.jpg
737
+ 3288274849_07ff76ee93.jpg
738
+ 2470486377_c3a39ccb7b.jpg
739
+ 3103340819_46de7954a9.jpg
740
+ 78984436_ad96eaa802.jpg
741
+ 2833582518_074bef3ed6.jpg
742
+ 2218907190_5f43bf5e4d.jpg
743
+ 2534424894_ccd091fcb5.jpg
744
+ 2707244524_d57120d74a.jpg
745
+ 2096771662_984441d20d.jpg
746
+ 2533642917_a5eace85e6.jpg
747
+ 3243094580_ccd01679f5.jpg
748
+ 3339140382_2e49bc324a.jpg
749
+ 3504940491_94c43792ed.jpg
750
+ 3621329299_6fb3f2935c.jpg
751
+ 3031263767_2e3856130e.jpg
752
+ 2987096101_a41896187a.jpg
753
+ 3249891874_6a090ef097.jpg
754
+ 2249865945_f432c8e5da.jpg
755
+ 2428797297_7fc3c862db.jpg
756
+ 2587017287_888c811b5a.jpg
757
+ 2619454551_c4bb726a85.jpg
758
+ 2518094853_dfce24ce8c.jpg
759
+ 2130203183_49bae96b96.jpg
760
+ 3482474257_a88bfe5c57.jpg
761
+ 930748509_8ca5cf5c24.jpg
762
+ 314904143_5a216a192b.jpg
763
+ 2676937700_456134c7b5.jpg
764
+ 109260218_fca831f933.jpg
765
+ 2769605231_dae8b30201.jpg
766
+ 3536561454_e75993d903.jpg
767
+ 3268407162_6274e0f74f.jpg
768
+ 2248487956_2603f55ab9.jpg
769
+ 3498354674_b636c7992f.jpg
770
+ 86412576_c53392ef80.jpg
771
+ 374103842_17873ce505.jpg
772
+ 2056041678_d6b5b39b26.jpg
773
+ 3052104757_d1cf646935.jpg
774
+ 3406116788_c8f62e32d1.jpg
775
+ 349889354_4b2889a9bd.jpg
776
+ 549887636_0ea5ae4739.jpg
777
+ 2797511323_bf20acab45.jpg
778
+ 2922807898_b5a06d5c70.jpg
779
+ 3396251819_1efa69310f.jpg
780
+ 2656987333_80dcc82c05.jpg
781
+ 775664534_3f6de7d413.jpg
782
+ 268365231_a0acecdc45.jpg
783
+ 3357937209_cf4a9512ac.jpg
784
+ 2963672852_c28043bb2c.jpg
785
+ 1389264266_8170bc1c54.jpg
786
+ 2445442929_8c81d42460.jpg
787
+ 3192069971_83c5a90b4c.jpg
788
+ 3717309680_e5105afa6d.jpg
789
+ 374828031_9d087da5cf.jpg
790
+ 3102204862_f1d220230b.jpg
791
+ 3598447435_f66cd10bd6.jpg
792
+ 2352414953_10f3cd0f1f.jpg
793
+ 2165677531_e1d5e086f7.jpg
794
+ 3006926228_cf3c067b3e.jpg
795
+ 2947274789_a1a35b33c3.jpg
796
+ 708860480_1a956ae0f7.jpg
797
+ 3517466790_17c7753a1a.jpg
798
+ 2795866891_7559fd8422.jpg
799
+ 2469351714_d72becd21e.jpg
800
+ 923550133_ac9d7a2932.jpg
801
+ 3726025663_e7d35d23f6.jpg
802
+ 2596876977_b61ee7ee78.jpg
803
+ 470903027_489cc507de.jpg
804
+ 2257099774_37d0d3aa9a.jpg
805
+ 1348304997_afe60a61df.jpg
806
+ 2356664078_4b1e6e465d.jpg
807
+ 3018304737_0a46fc5f1d.jpg
808
+ 543291644_64539956e9.jpg
809
+ 248646530_03c6284759.jpg
810
+ 2543589122_ec3e55f434.jpg
811
+ 237953705_cfe6999307.jpg
812
+ 3517362674_0f5296de19.jpg
813
+ 1298295313_db1f4c6522.jpg
814
+ 394463341_5311c53783.jpg
815
+ 2479553749_f7ac031940.jpg
816
+ 3262386960_14f5d857db.jpg
817
+ 2066241589_b80e9f676c.jpg
818
+ 3028095878_07341efc9c.jpg
819
+ 3587077732_0933f1677b.jpg
820
+ 247619370_a01fb21dd3.jpg
821
+ 3150380412_7021e5444a.jpg
822
+ 244760289_f4467b2b67.jpg
823
+ 2419591925_1038c6c570.jpg
824
+ 2339140905_9f625f140a.jpg
825
+ 3188319076_71724fcc07.jpg
826
+ 3258391809_38fc6211f7.jpg
827
+ 3551787566_b5ebbe2440.jpg
828
+ 380537190_11d6c0a412.jpg
829
+ 3240094420_a9eea11d39.jpg
830
+ 3562282690_cd2a95fe9e.jpg
831
+ 3144705706_391d7b77c7.jpg
832
+ 3231575742_31732664cf.jpg
833
+ 1263126002_881ebd7ac9.jpg
834
+ 1801663973_5ad393caeb.jpg
835
+ 428485639_a82635d6ee.jpg
836
+ 217838128_1f0a84ddc1.jpg
837
+ 3420064875_0349a75d69.jpg
838
+ 3601491447_a338875b51.jpg
839
+ 3461041826_0e24cdf597.jpg
840
+ 416992999_654a99a903.jpg
841
+ 3424424006_98f9d1921c.jpg
842
+ 535123126_c06c1ab9bf.jpg
843
+ 2718376488_3c62f7642c.jpg
844
+ 2040941056_7f5fd50794.jpg
845
+ 3163281186_e2f43dfb5f.jpg
846
+ 3425069551_aba046a1b6.jpg
847
+ 3651971126_309e6a5e22.jpg
848
+ 3320756943_9d004f9824.jpg
849
+ 3532200762_b28c39d311.jpg
850
+ 2654943319_d17fee7800.jpg
851
+ 3454754632_977c1523be.jpg
852
+ 2782850287_1408f7ec43.jpg
853
+ 1124448967_2221af8dc5.jpg
854
+ 1659358133_95cd1027bd.jpg
855
+ 3501781809_88429e3b83.jpg
856
+ 1003163366_44323f5815.jpg
857
+ 3134387321_3a253224c1.jpg
858
+ 3477977145_4df89d69a1.jpg
859
+ 1439046601_cf110a75a7.jpg
860
+ 1007320043_627395c3d8.jpg
861
+ 3375843443_8d9b242aa5.jpg
862
+ 2073964624_52da3a0fc4.jpg
863
+ 2666205903_8d287669e1.jpg
864
+ 3171188674_717eee0183.jpg
865
+ 2128119486_4407061c40.jpg
866
+ 2665461736_595c87f0a3.jpg
867
+ 1286408831_05282582ed.jpg
868
+ 3726730085_2468ee9220.jpg
869
+ 2187904131_96ea83b9b5.jpg
870
+ 2759813381_73303113d9.jpg
871
+ 3025513877_1a6160070d.jpg
872
+ 539744890_85e63f5854.jpg
873
+ 2602279427_191773c9e2.jpg
874
+ 2956562716_5aa3f6ef38.jpg
875
+ 2930318834_8366811283.jpg
876
+ 2657484970_610e18144f.jpg
877
+ 3665179773_dd217416fc.jpg
878
+ 3432730942_4dc4685277.jpg
879
+ 2353088412_5e5804c6f5.jpg
880
+ 615916000_5044047d71.jpg
881
+ 2578834476_118585730d.jpg
882
+ 2706023395_ac9eba0e42.jpg
883
+ 382151094_c7376cf22b.jpg
884
+ 2247889670_413db8094b.jpg
885
+ 2935986346_29df6cf692.jpg
886
+ 3044359043_627488ddf0.jpg
887
+ 3526018344_450c517a72.jpg
888
+ 498444334_a680d318a1.jpg
889
+ 2593406865_ab98490c1f.jpg
890
+ 2462702522_1b25654762.jpg
891
+ 2955673642_4279b32097.jpg
892
+ 241345533_99c731403a.jpg
893
+ 3393343330_b13df4d8ec.jpg
894
+ 2712787899_d85048eb6a.jpg
895
+ 3436313241_6c73153fb6.jpg
896
+ 501520507_c86f805ab8.jpg
897
+ 2629027962_9cc3b46527.jpg
898
+ 3656104088_a0d1642fa9.jpg
899
+ 3691622437_f13644273c.jpg
900
+ 3096918227_f9d26a7db2.jpg
901
+ 3251234434_d01e25a50a.jpg
902
+ 3542341321_faa2d2d48a.jpg
903
+ 2305437797_e6c3460190.jpg
904
+ 3143982558_9e2d44c155.jpg
905
+ 3582465732_78f77f34ae.jpg
906
+ 2522809984_2e8a7df4fb.jpg
907
+ 2191453879_11dfe2ba3a.jpg
908
+ 442918418_0f29c97fa9.jpg
909
+ 127488876_f2d2a89588.jpg
910
+ 1084104085_3b06223afe.jpg
911
+ 2351762979_0941aecced.jpg
912
+ 3540515072_8c951b738b.jpg
913
+ 2891924845_92f69b0f18.jpg
914
+ 2986716822_e220754d32.jpg
915
+ 3563059800_c073081ce3.jpg
916
+ 3232252882_05db7c2216.jpg
917
+ 1131804997_177c3c0640.jpg
918
+ 3551003620_0b02d76f65.jpg
919
+ 3376898612_41c91de476.jpg
920
+ 224369028_b1ac40d1fa.jpg
921
+ 2463067409_78188c584c.jpg
922
+ 443430496_3fea95a07d.jpg
923
+ 427167162_2c99779444.jpg
924
+ 2495394666_2ef6c37519.jpg
925
+ 3222702477_34d2d24f1f.jpg
926
+ 3458379941_657182bb09.jpg
927
+ 527288854_f26127b770.jpg
928
+ 2842865689_e37256d9ce.jpg
929
+ 3723903586_e98d3d8ec7.jpg
930
+ 3690107455_0fdb4ecee7.jpg
931
+ 2909081008_9a7bfc599a.jpg
932
+ 421316045_ae7a1eb4bc.jpg
933
+ 3482787182_a5c6d4b386.jpg
934
+ 3608849440_e7d2bed29f.jpg
935
+ 2735558076_0d7bbc18fc.jpg
936
+ 2073756099_7e02c0110c.jpg
937
+ 2367318629_b60cf4c4b3.jpg
938
+ 3335692531_dd4a995f91.jpg
939
+ 3336065481_2c21e622c8.jpg
940
+ 3304484212_b950233c30.jpg
941
+ 3399284917_721aefe2a7.jpg
942
+ 3679502342_7fe6ef8a36.jpg
943
+ 3229821595_77ace81c6b.jpg
944
+ 3673165148_67f217064f.jpg
945
+ 1384292980_4022a7520c.jpg
946
+ 2892467862_52a3c67418.jpg
947
+ 2512683710_991c9d466d.jpg
948
+ 3122938209_2b2c6c1fab.jpg
949
+ 3220200084_3ea129336e.jpg
950
+ 1474474514_b3eb492722.jpg
951
+ 3268443910_b36dbc1e5c.jpg
952
+ 1075716537_62105738b4.jpg
953
+ 1622619190_d0b51aff28.jpg
954
+ 1332815795_8eea44375e.jpg
955
+ 2720215226_5a98ff2bd3.jpg
956
+ 3471841031_a949645ba8.jpg
957
+ 2229509318_be3fef006b.jpg
958
+ 512163695_51a108761d.jpg
959
+ 3251646144_d9f4ccca3f.jpg
960
+ 2483993772_f64e9e4724.jpg
961
+ 3384314832_dffc944152.jpg
962
+ 3704698586_a42c25d0c1.jpg
963
+ 3339558806_b4afdc8394.jpg
964
+ 3193335577_9bdbaf9f70.jpg
965
+ 3000428313_8a1e65e20e.jpg
966
+ 3127142756_bf0bfcb571.jpg
967
+ 2763044275_aa498eb88b.jpg
968
+ 3143765063_a7761b16d3.jpg
969
+ 3606093421_eddd46c2c7.jpg
970
+ 3344632789_af90d54746.jpg
971
+ 256283122_a4ef4a17cb.jpg
972
+ 2557507575_b247f145bc.jpg
973
+ 3355494822_61353a224d.jpg
974
+ 412056525_191724b058.jpg
975
+ 2565657591_6c1cdfc092.jpg
976
+ 3701878677_8f2c26227b.jpg
977
+ 3495490064_8db40a83af.jpg
978
+ 2410618963_fb78307d18.jpg
979
+ 3349258288_5300c40430.jpg
980
+ 246094557_e174a5914f.jpg
981
+ 3725177385_62d5e13634.jpg
982
+ 2853811730_fbb8ab0878.jpg
983
+ 260162669_c79a900afb.jpg
984
+ 1473250020_dc829a090f.jpg
985
+ 3582914739_bef2828a06.jpg
986
+ 3668900592_a84b0c07db.jpg
987
+ 3712574653_e009f76d19.jpg
988
+ 3418504074_083f0bb68d.jpg
989
+ 3641456303_c50c33337b.jpg
990
+ 3070031806_3d587c2a66.jpg
991
+ 502783522_3656f27014.jpg
992
+ 3248220732_0f173fc197.jpg
993
+ 3427402225_234d712eeb.jpg
994
+ 393958545_48c17c66d1.jpg
995
+ 2855417531_521bf47b50.jpg
996
+ 3666537170_c4ecda4be8.jpg
997
+ 3131632154_098f86f4cb.jpg
998
+ 2461372011_ebbf513766.jpg
999
+ 169490297_b6ff13632a.jpg
1000
+ 3139160252_75109e9e05.jpg
models/.DS_Store ADDED
Binary file (6.15 kB). View file
 
models/model_vgg16.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f088b30970d6c2edb162d8b417bef3e103f185da77d0b3eb33adb70f62a23d8e
3
+ size 99057768
models/model_vgg19.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:61bb1015bbe85d97f4410ba7951346636c9d9e6c49b9cdedfe8dc3aa2091f7e6
3
+ size 99057768
requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ tensorflow>=2.13.0
2
+ numpy>=1.23.0
3
+ pandas>=1.5.0
4
+ Pillow>=9.0.0
5
+ matplotlib>=3.6.0
6
+ nltk>=3.8.0
7
+ tqdm>=4.64.0
8
+ streamlit>=1.28.0
9
+ kagglehub>=0.1.0
src/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ # CaptionIQ — Image Captioning with CNN + LSTM
src/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (173 Bytes). View file
 
src/__pycache__/config.cpython-311.pyc ADDED
Binary file (3.13 kB). View file
 
src/__pycache__/engine.cpython-311.pyc ADDED
Binary file (11.5 kB). View file
 
src/__pycache__/evaluate.cpython-311.pyc ADDED
Binary file (10.9 kB). View file
 
src/__pycache__/extract_features.cpython-311.pyc ADDED
Binary file (7.47 kB). View file
 
src/__pycache__/inference.cpython-311.pyc ADDED
Binary file (19.3 kB). View file
 
src/__pycache__/model.cpython-311.pyc ADDED
Binary file (6.63 kB). View file
 
src/__pycache__/preprocess.cpython-311.pyc ADDED
Binary file (17.9 kB). View file
 
src/__pycache__/train.cpython-311.pyc ADDED
Binary file (14.9 kB). View file
 
src/__pycache__/utils.cpython-311.pyc ADDED
Binary file (4.59 kB). View file
 
src/config.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ CaptionIQ — Central Configuration
3
+ All hyperparameters, paths, and constants in one place.
4
+ """
5
+
6
+ import os
7
+
8
+ # ──────────────────────────────────────────────
9
+ # Paths
10
+ # ──────────────────────────────────────────────
11
+ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
12
+ DATA_DIR = os.path.join(BASE_DIR, "data")
13
+ MODELS_DIR = os.path.join(BASE_DIR, "models")
14
+ OUTPUTS_DIR = os.path.join(BASE_DIR, "outputs")
15
+
16
+ # Raw dataset paths (Flickr8K)
17
+ FLICKR_IMAGES_DIR = os.path.join(DATA_DIR, "Flickr8k_Dataset")
18
+ FLICKR_TEXT_DIR = os.path.join(DATA_DIR, "Flickr8k_text")
19
+
20
+ # Processed data paths
21
+ CAPTIONS_FILE = os.path.join(DATA_DIR, "captions_clean.txt")
22
+ TOKENIZER_FILE = os.path.join(DATA_DIR, "tokenizer.pkl")
23
+ TRAIN_IMAGES_FILE = os.path.join(DATA_DIR, "train_images.txt")
24
+ VAL_IMAGES_FILE = os.path.join(DATA_DIR, "val_images.txt")
25
+ TEST_IMAGES_FILE = os.path.join(DATA_DIR, "test_images.txt")
26
+
27
+ # Feature files
28
+ VGG16_FEATURES_FILE = os.path.join(DATA_DIR, "vgg16_features.pkl")
29
+ VGG19_FEATURES_FILE = os.path.join(DATA_DIR, "vgg19_features.pkl")
30
+
31
+ # Model checkpoint paths
32
+ VGG16_MODEL_FILE = os.path.join(MODELS_DIR, "model_vgg16.h5")
33
+ VGG19_MODEL_FILE = os.path.join(MODELS_DIR, "model_vgg19.h5")
34
+
35
+ # Output paths
36
+ VGG16_LOSS_PLOT = os.path.join(OUTPUTS_DIR, "loss_vgg16.png")
37
+ VGG19_LOSS_PLOT = os.path.join(OUTPUTS_DIR, "loss_vgg19.png")
38
+ BLEU_RESULTS_FILE = os.path.join(OUTPUTS_DIR, "bleu_results.json")
39
+
40
+ # ──────────────────────────────────────────────
41
+ # Image parameters
42
+ # ──────────────────────────────────────────────
43
+ IMAGE_SIZE = 224 # VGG input requirement
44
+
45
+ # ──────────────────────────────────────────────
46
+ # Model hyperparameters
47
+ # ──────────────────────────────────────────────
48
+ EMBED_DIM = 256 # Word embedding dimension
49
+ LSTM_UNITS = 512 # LSTM hidden units
50
+ DROPOUT_RATE = 0.3 # Dropout rate (reduced from 0.5)
51
+ FEATURE_DIM = 512 # VGG spatial feature channels
52
+ FEATURE_LOCATIONS = 49 # 7x7 spatial positions from block5_pool
53
+ ATTENTION_DIM = 256 # Bahdanau attention hidden dim
54
+
55
+ # ──────────────────────────────────────────────
56
+ # Vocabulary
57
+ # ──────────────────────────────────────────────
58
+ MIN_WORD_FREQ = 5 # Drop words appearing fewer than this many times
59
+
60
+ # ──────────────────────────────────────────────
61
+ # Training hyperparameters
62
+ # ──────────────────────────────────────────────
63
+ EPOCHS = 30 # 30 is enough; early stopping handles the rest
64
+ BATCH_SIZE = 64 # 2x bigger batch = 2x fewer steps = 2x faster
65
+ LEARNING_RATE = 0.001
66
+
67
+ # Callbacks
68
+ EARLY_STOP_PATIENCE = 6 # EarlyStopping patience (epochs)
69
+ LR_PATIENCE = 3 # ReduceLROnPlateau patience (epochs)
70
+ LR_FACTOR = 0.5 # LR reduction factor
71
+
72
+ # ──────────────────────────────────────────────
73
+ # Inference
74
+ # ──────────────────────────────────────────────
75
+ BEAM_WIDTH = 5
76
+ MAX_LENGTH = 34 # Maximum caption length in tokens
77
+
78
+ # ──────────────────────────────────────────────
79
+ # Special tokens
80
+ # ──────────────────────────────────────────────
81
+ START_TOKEN = "startseq"
82
+ END_TOKEN = "endseq"
83
+
84
+ # ──────────────────────────────────────────────
85
+ # Dataset splits
86
+ # ──────────────────────────────────────────────
87
+ TRAIN_SIZE = 6000
88
+ VAL_SIZE = 1000
89
+ TEST_SIZE = 1000
90
+
91
+ # ──────────────────────────────────────────────
92
+ # Create directories if they don't exist
93
+ # ──────────────────────────────────────────────
94
+ for d in [DATA_DIR, MODELS_DIR, OUTPUTS_DIR]:
95
+ os.makedirs(d, exist_ok=True)
src/engine.py ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ CaptionIQ — Backend Caption Orchestration Engine
3
+ Transparent orchestration across VGG16, VGG19 and optional BLIP.
4
+ """
5
+
6
+ import os
7
+ import numpy as np
8
+ from tensorflow.keras.models import load_model
9
+ from tensorflow.keras.preprocessing.image import img_to_array
10
+ from tensorflow.keras.applications.vgg16 import VGG16, preprocess_input as vgg16_preprocess
11
+ from tensorflow.keras.applications.vgg19 import VGG19, preprocess_input as vgg19_preprocess
12
+ from tensorflow.keras.models import Model as KerasModel
13
+
14
+ # Keras compatibility patch for legacy h5 loading.
15
+ import keras.src.ops.operation as _keras_op
16
+ from keras.src.ops.numpy import NotEqual as _NotEqual
17
+
18
+ _orig_from_config = _keras_op.Operation.from_config.__func__
19
+
20
+
21
+ @classmethod # type: ignore[misc]
22
+ def _patched_from_config(cls, config): # noqa: N805
23
+ config.pop("quantization_config", None)
24
+ return _orig_from_config(cls, config)
25
+
26
+
27
+ _keras_op.Operation.from_config = _patched_from_config
28
+
29
+ from src.config import (
30
+ IMAGE_SIZE, BEAM_WIDTH,
31
+ VGG16_MODEL_FILE, VGG19_MODEL_FILE, TOKENIZER_FILE,
32
+ )
33
+ from src.model import BahdanauAttention
34
+ from src.utils import load_tokenizer
35
+ from src.inference import beam_search, beam_search_ensemble
36
+
37
+ _CUSTOM_OBJECTS = {"NotEqual": _NotEqual, "BahdanauAttention": BahdanauAttention}
38
+
39
+
40
+ class CaptionEngine:
41
+ """Backend orchestration service for caption generation."""
42
+
43
+ def __init__(self):
44
+ self.tokenizer = load_tokenizer(TOKENIZER_FILE) if os.path.exists(TOKENIZER_FILE) else None
45
+ self._vgg_models = {}
46
+ self._extractors = {}
47
+ self._blip_bundle = None
48
+
49
+ def is_ready(self, backbone_mode: str):
50
+ if self.tokenizer is None:
51
+ return False, "Tokenizer not found. Train/preprocess first."
52
+
53
+ if backbone_mode == "ensemble":
54
+ if not os.path.exists(VGG16_MODEL_FILE) or not os.path.exists(VGG19_MODEL_FILE):
55
+ return False, "Ensemble requires both VGG16 and VGG19 model files."
56
+ elif backbone_mode == "vgg16":
57
+ if not os.path.exists(VGG16_MODEL_FILE):
58
+ return False, "VGG16 model file not found."
59
+ elif backbone_mode == "vgg19":
60
+ if not os.path.exists(VGG19_MODEL_FILE):
61
+ return False, "VGG19 model file not found."
62
+ else:
63
+ return False, f"Unknown backbone mode: {backbone_mode}"
64
+
65
+ return True, None
66
+
67
+ def _load_vgg_model(self, backbone: str):
68
+ if backbone in self._vgg_models:
69
+ return self._vgg_models[backbone]
70
+
71
+ model_file = VGG16_MODEL_FILE if backbone == "vgg16" else VGG19_MODEL_FILE
72
+ if not os.path.exists(model_file):
73
+ return None
74
+ model = load_model(model_file, custom_objects=_CUSTOM_OBJECTS)
75
+ self._vgg_models[backbone] = model
76
+ return model
77
+
78
+ def _load_feature_extractor(self, backbone: str):
79
+ if backbone in self._extractors:
80
+ return self._extractors[backbone]
81
+
82
+ if backbone == "vgg16":
83
+ base_model = VGG16(weights="imagenet")
84
+ preprocess_fn = vgg16_preprocess
85
+ else:
86
+ base_model = VGG19(weights="imagenet")
87
+ preprocess_fn = vgg19_preprocess
88
+
89
+ extractor = KerasModel(
90
+ inputs=base_model.input,
91
+ outputs=base_model.get_layer("block5_pool").output
92
+ )
93
+ self._extractors[backbone] = (extractor, preprocess_fn)
94
+ return extractor, preprocess_fn
95
+
96
+ def _extract_feature(self, image, backbone: str):
97
+ extractor, preprocess_fn = self._load_feature_extractor(backbone)
98
+
99
+ img = image.resize((IMAGE_SIZE, IMAGE_SIZE)).convert("RGB")
100
+ img_array = img_to_array(img)
101
+ img_array = np.expand_dims(img_array, axis=0)
102
+ img_array = preprocess_fn(img_array)
103
+ feature = extractor.predict(img_array, verbose=0)[0] # (7, 7, 512)
104
+ h, w, c = feature.shape
105
+ return feature.reshape(h * w, c) # (49, 512)
106
+
107
+ def _is_low_quality(self, caption: str, confidence: float):
108
+ weak_endings = {
109
+ "a", "an", "the", "in", "on", "at", "of", "to", "for",
110
+ "with", "by", "from", "and", "or", "but", "as",
111
+ }
112
+ words = caption.split()
113
+ if len(words) < 5:
114
+ return True
115
+ if words[-1].lower() in weak_endings:
116
+ return True
117
+ if confidence < 0.35:
118
+ return True
119
+ return False
120
+
121
+ def _load_blip_bundle(self):
122
+ if self._blip_bundle is not None:
123
+ return self._blip_bundle
124
+
125
+ try:
126
+ import torch
127
+ from transformers import BlipProcessor, BlipForConditionalGeneration
128
+ except Exception:
129
+ self._blip_bundle = None
130
+ return None
131
+
132
+ try:
133
+ processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
134
+ model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base")
135
+ model.eval()
136
+ self._blip_bundle = {"processor": processor, "model": model, "torch": torch}
137
+ return self._blip_bundle
138
+ except Exception:
139
+ self._blip_bundle = None
140
+ return None
141
+
142
+ def _generate_blip_caption(self, image):
143
+ bundle = self._load_blip_bundle()
144
+ if bundle is None:
145
+ return None
146
+
147
+ processor = bundle["processor"]
148
+ model = bundle["model"]
149
+ torch = bundle["torch"]
150
+
151
+ rgb = image.convert("RGB")
152
+ with torch.no_grad():
153
+ inputs = processor(images=rgb, return_tensors="pt")
154
+ output = model.generate(
155
+ **inputs,
156
+ max_new_tokens=24,
157
+ num_beams=5,
158
+ length_penalty=1.0,
159
+ early_stopping=True,
160
+ )
161
+ caption = processor.decode(output[0], skip_special_tokens=True).strip()
162
+ return caption if caption else None
163
+
164
+ def _generate_vgg_candidates(self, image, backbone_mode: str, beam_width: int):
165
+ if backbone_mode == "ensemble":
166
+ m16 = self._load_vgg_model("vgg16")
167
+ m19 = self._load_vgg_model("vgg19")
168
+ f16 = self._extract_feature(image, "vgg16")
169
+ f19 = self._extract_feature(image, "vgg19")
170
+ max_length = min(m16.input_shape[1][1], m19.input_shape[1][1])
171
+ return beam_search_ensemble([m16, m19], self.tokenizer, [f16, f19], max_length, beam_width)
172
+
173
+ model = self._load_vgg_model(backbone_mode)
174
+ feature = self._extract_feature(image, backbone_mode)
175
+ max_length = model.input_shape[1][1]
176
+ return beam_search(model, self.tokenizer, feature, max_length, beam_width)
177
+
178
+ def generate_caption(self, image, caption_mode: str, backbone_mode: str, beam_width: int = None):
179
+ """
180
+ caption_mode: vgg_only | hybrid | blip_only
181
+ backbone_mode: vgg16 | vgg19 | ensemble
182
+ """
183
+ beam_width = beam_width or BEAM_WIDTH
184
+ vgg_candidates = self._generate_vgg_candidates(image, backbone_mode, beam_width)
185
+ candidates = list(vgg_candidates)
186
+ model_used = f"VGG {backbone_mode.upper()}"
187
+
188
+ if caption_mode == "blip_only":
189
+ blip_caption = self._generate_blip_caption(image)
190
+ if blip_caption:
191
+ deduped = [(blip_caption, 0.82)]
192
+ for cap, score in vgg_candidates:
193
+ if cap != blip_caption:
194
+ deduped.append((cap, score))
195
+ candidates = deduped[:max(3, beam_width)]
196
+ model_used = "BLIP"
197
+ elif caption_mode == "hybrid":
198
+ if vgg_candidates:
199
+ top_caption, top_conf = vgg_candidates[0]
200
+ if self._is_low_quality(top_caption, top_conf):
201
+ blip_caption = self._generate_blip_caption(image)
202
+ if blip_caption:
203
+ deduped = [(blip_caption, 0.68)]
204
+ for cap, score in vgg_candidates:
205
+ if cap != blip_caption:
206
+ deduped.append((cap, score))
207
+ candidates = deduped[:max(3, beam_width)]
208
+ model_used = "Hybrid (BLIP override)"
209
+
210
+ top_caption = candidates[0][0] if candidates else ""
211
+ top_conf = candidates[0][1] if candidates else 0.0
212
+ return {
213
+ "caption": top_caption,
214
+ "confidence": top_conf,
215
+ "model_used": model_used,
216
+ "candidates": candidates,
217
+ }
src/evaluate.py ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ CaptionIQ — BLEU Score Evaluation
3
+ Generate captions for the test set and compute BLEU-1 through BLEU-4 scores.
4
+ Compare VGG16 vs VGG19 performance.
5
+ """
6
+
7
+ import os
8
+ import sys
9
+ import json
10
+ import argparse
11
+ import numpy as np
12
+ from tqdm import tqdm
13
+ from nltk.translate.bleu_score import corpus_bleu, SmoothingFunction
14
+
15
+ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
16
+ from src.config import (
17
+ CAPTIONS_FILE, TOKENIZER_FILE,
18
+ VGG16_FEATURES_FILE, VGG19_FEATURES_FILE,
19
+ VGG16_MODEL_FILE, VGG19_MODEL_FILE,
20
+ TEST_IMAGES_FILE, BLEU_RESULTS_FILE,
21
+ START_TOKEN, END_TOKEN, MAX_LENGTH,
22
+ )
23
+ from src.utils import load_captions, load_image_list, load_features, load_tokenizer, get_vocab_size
24
+ from src.inference import greedy_search, beam_search
25
+ from src.config import BEAM_WIDTH
26
+ from tensorflow.keras.models import load_model
27
+
28
+ # ── Keras compatibility patch ──────────────────────────────────────
29
+ # Models saved with newer Keras include 'quantization_config' in every
30
+ # layer config. Older Keras versions reject the unknown kwarg.
31
+ # The Embedding layer's mask_zero=True also serialises a NotEqual op
32
+ # that the legacy h5 loader can't resolve by name.
33
+ # Fix: (1) monkey-patch from_config to strip quantization_config,
34
+ # (2) import NotEqual so we can register it as a custom object.
35
+ import keras.src.ops.operation as _keras_op
36
+ from keras.src.ops.numpy import NotEqual as _NotEqual
37
+
38
+ _orig_from_config = _keras_op.Operation.from_config.__func__
39
+
40
+
41
+ @classmethod # type: ignore[misc]
42
+ def _patched_from_config(cls, config): # noqa: N805
43
+ config.pop("quantization_config", None)
44
+ return _orig_from_config(cls, config)
45
+
46
+
47
+ _keras_op.Operation.from_config = _patched_from_config
48
+
49
+ from src.model import BahdanauAttention
50
+ _CUSTOM_OBJECTS = {"NotEqual": _NotEqual, "BahdanauAttention": BahdanauAttention}
51
+ # ───────────────────────────────────────────────────────────────────
52
+
53
+
54
+ def get_references(captions: dict, image_ids: set) -> dict:
55
+ """
56
+ Extract reference captions for evaluation.
57
+ Removes start/end tokens and returns as list of word lists.
58
+
59
+ Returns:
60
+ dict mapping image_id → list of reference word lists
61
+ """
62
+ references = {}
63
+ for img_id in image_ids:
64
+ if img_id not in captions:
65
+ continue
66
+ refs = []
67
+ for cap in captions[img_id]:
68
+ # Remove start/end tokens and split into words
69
+ words = [
70
+ w for w in cap.split()
71
+ if w not in (START_TOKEN, END_TOKEN)
72
+ ]
73
+ refs.append(words)
74
+ references[img_id] = refs
75
+ return references
76
+
77
+
78
+ def evaluate_model(backbone: str, captions: dict, features: dict,
79
+ tokenizer, test_images: set) -> dict:
80
+ """
81
+ Evaluate a trained model on the test set.
82
+
83
+ Args:
84
+ backbone: "vgg16" or "vgg19"
85
+ captions: All cleaned captions
86
+ features: Pre-extracted image features
87
+ tokenizer: Fitted tokenizer
88
+ test_images: Set of test image IDs
89
+
90
+ Returns:
91
+ dict with BLEU-1 through BLEU-4 scores
92
+ """
93
+ model_file = VGG16_MODEL_FILE if backbone == "vgg16" else VGG19_MODEL_FILE
94
+
95
+ if not os.path.exists(model_file):
96
+ print(f" Warning: Model not found: {model_file}")
97
+ return None
98
+
99
+ print(f"\nLoading {backbone.upper()} model...")
100
+ model = load_model(model_file, custom_objects=_CUSTOM_OBJECTS)
101
+
102
+ # Determine max_length from model
103
+ max_length = model.input_shape[1][1]
104
+
105
+ # Get references
106
+ references = get_references(captions, test_images)
107
+
108
+ # Generate captions for test images
109
+ actual_refs = []
110
+ hypotheses = []
111
+ skipped = 0
112
+
113
+ print(f"Generating captions for {len(test_images)} test images...")
114
+ for img_id in tqdm(sorted(test_images), desc=f"Evaluating {backbone.upper()}"):
115
+ if img_id not in features or img_id not in references:
116
+ skipped += 1
117
+ continue
118
+
119
+ feature = features[img_id]
120
+
121
+ # Generate caption using beam search for higher quality
122
+ beam_results = beam_search(model, tokenizer, feature, max_length, BEAM_WIDTH)
123
+ caption = beam_results[0][0] if beam_results else ""
124
+ hypothesis = caption.split()
125
+
126
+ hypotheses.append(hypothesis)
127
+ actual_refs.append(references[img_id])
128
+
129
+ if skipped > 0:
130
+ print(f" Skipped {skipped} images (missing features or references)")
131
+
132
+ print(f" Evaluated {len(hypotheses)} images")
133
+
134
+ # ── Compute BLEU scores ──
135
+ smooth = SmoothingFunction().method1
136
+
137
+ bleu_scores = {}
138
+ for n in range(1, 5):
139
+ weights = tuple([1.0 / n] * n + [0.0] * (4 - n))
140
+ score = corpus_bleu(actual_refs, hypotheses, weights=weights,
141
+ smoothing_function=smooth)
142
+ bleu_scores[f"BLEU-{n}"] = round(score, 4)
143
+ print(f" BLEU-{n}: {score:.4f}")
144
+
145
+ return bleu_scores
146
+
147
+
148
+ def print_comparison_table(results: dict):
149
+ """Print a formatted comparison table of VGG16 vs VGG19."""
150
+ print("\n" + "=" * 55)
151
+ print(" VGG16 vs VGG19 — BLEU Score Comparison")
152
+ print("=" * 55)
153
+ print(f"{'Metric':<10} {'VGG16':>10} {'VGG19':>10} {'Diff':>10}")
154
+ print("-" * 55)
155
+
156
+ for metric in ["BLEU-1", "BLEU-2", "BLEU-3", "BLEU-4"]:
157
+ v16 = results.get("vgg16", {}).get(metric, "N/A")
158
+ v19 = results.get("vgg19", {}).get(metric, "N/A")
159
+
160
+ if isinstance(v16, float) and isinstance(v19, float):
161
+ diff = v19 - v16
162
+ sign = "+" if diff >= 0 else ""
163
+ print(f"{metric:<10} {v16:>10.4f} {v19:>10.4f} {sign}{diff:>9.4f}")
164
+ else:
165
+ print(f"{metric:<10} {str(v16):>10} {str(v19):>10} {'—':>10}")
166
+
167
+ print("=" * 55)
168
+
169
+
170
+ def main():
171
+ parser = argparse.ArgumentParser(description="Evaluate CaptionIQ with BLEU scores")
172
+ parser.add_argument(
173
+ "--backbone", type=str, default="vgg19",
174
+ choices=["vgg16", "vgg19", "both"],
175
+ help="Which model(s) to evaluate (default: vgg19)"
176
+ )
177
+ args = parser.parse_args()
178
+
179
+ import nltk
180
+ nltk.download("punkt", quiet=True)
181
+ nltk.download("punkt_tab", quiet=True)
182
+
183
+ print("=" * 60)
184
+ print(" CaptionIQ — BLEU Score Evaluation")
185
+ print("=" * 60)
186
+
187
+ # Load shared data
188
+ all_captions = load_captions(CAPTIONS_FILE)
189
+ tokenizer = load_tokenizer(TOKENIZER_FILE)
190
+ test_images = load_image_list(TEST_IMAGES_FILE)
191
+
192
+ print(f"Test images: {len(test_images)}")
193
+
194
+ backbones = ["vgg16", "vgg19"] if args.backbone == "both" else [args.backbone]
195
+ results = {}
196
+
197
+ for backbone in backbones:
198
+ features_file = VGG16_FEATURES_FILE if backbone == "vgg16" else VGG19_FEATURES_FILE
199
+
200
+ if not os.path.exists(features_file):
201
+ print(f"\n Warning: Features not found: {features_file}")
202
+ continue
203
+
204
+ features = load_features(features_file)
205
+ scores = evaluate_model(backbone, all_captions, features, tokenizer, test_images)
206
+
207
+ if scores:
208
+ results[backbone] = scores
209
+
210
+ # Save results
211
+ if results:
212
+ with open(BLEU_RESULTS_FILE, "w") as f:
213
+ json.dump(results, f, indent=2)
214
+ print(f"\nResults saved to: {BLEU_RESULTS_FILE}")
215
+
216
+ # Print comparison table if both models evaluated
217
+ if "vgg16" in results and "vgg19" in results:
218
+ print_comparison_table(results)
219
+
220
+ print("\n✓ Evaluation complete!")
221
+
222
+
223
+ if __name__ == "__main__":
224
+ main()
src/extract_features.py ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ CaptionIQ — Image Feature Extraction
3
+ Extract spatial feature maps from VGG16 and VGG19 (`block5_pool`).
4
+ Save features as pickle files for training.
5
+ """
6
+
7
+ import os
8
+ import pickle
9
+ import argparse
10
+ import numpy as np
11
+ from tqdm import tqdm
12
+ from tensorflow.keras.applications.vgg16 import VGG16, preprocess_input as vgg16_preprocess
13
+ from tensorflow.keras.applications.vgg19 import VGG19, preprocess_input as vgg19_preprocess
14
+ from tensorflow.keras.preprocessing.image import load_img, img_to_array
15
+ from tensorflow.keras.models import Model
16
+
17
+ import sys
18
+ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
19
+ from src.config import (
20
+ FLICKR_IMAGES_DIR, IMAGE_SIZE,
21
+ VGG16_FEATURES_FILE, VGG19_FEATURES_FILE,
22
+ )
23
+
24
+
25
+ def build_feature_extractor(backbone: str = "vgg16") -> tuple:
26
+ """
27
+ Build a feature extractor from a pre-trained VGG model.
28
+ Outputs `block5_pool` spatial features (7x7x512).
29
+
30
+ Args:
31
+ backbone: "vgg16" or "vgg19"
32
+
33
+ Returns:
34
+ (model, preprocess_fn) tuple
35
+ """
36
+ if backbone == "vgg16":
37
+ base_model = VGG16(weights="imagenet")
38
+ preprocess_fn = vgg16_preprocess
39
+ elif backbone == "vgg19":
40
+ base_model = VGG19(weights="imagenet")
41
+ preprocess_fn = vgg19_preprocess
42
+ else:
43
+ raise ValueError(f"Unknown backbone: {backbone}. Use 'vgg16' or 'vgg19'.")
44
+
45
+ # Use block5_pool for spatial features (7x7x512) instead of fc2 (4096)
46
+ model = Model(
47
+ inputs=base_model.input,
48
+ outputs=base_model.get_layer("block5_pool").output
49
+ )
50
+ print(f"\n{backbone.upper()} feature extractor loaded")
51
+ print(f" Output shape: {model.output_shape} (spatial features)")
52
+ return model, preprocess_fn
53
+
54
+
55
+ def extract_features(model, preprocess_fn, images_dir: str) -> dict:
56
+ """
57
+ Extract features for all images in a directory.
58
+
59
+ Returns:
60
+ dict mapping filename → numpy array of shape (49, 512)
61
+ """
62
+ features = {}
63
+ image_files = [
64
+ f for f in os.listdir(images_dir)
65
+ if f.lower().endswith((".jpg", ".jpeg", ".png"))
66
+ ]
67
+
68
+ print(f"Extracting features for {len(image_files)} images...")
69
+ for fname in tqdm(image_files, desc="Extracting"):
70
+ filepath = os.path.join(images_dir, fname)
71
+ try:
72
+ # Load and preprocess image
73
+ image = load_img(filepath, target_size=(IMAGE_SIZE, IMAGE_SIZE))
74
+ image = img_to_array(image)
75
+ image = np.expand_dims(image, axis=0)
76
+ image = preprocess_fn(image)
77
+
78
+ # Extract spatial feature map and reshape to (49, 512)
79
+ feature = model.predict(image, verbose=0)[0] # (7, 7, 512)
80
+ h, w, c = feature.shape
81
+ features[fname] = feature.reshape(h * w, c) # (49, 512)
82
+ except Exception as e:
83
+ print(f" Warning: Failed to process {fname}: {e}")
84
+
85
+ print(f"Extracted features for {len(features)} images")
86
+ return features
87
+
88
+
89
+ def save_features(features: dict, filepath: str):
90
+ """Save features dict to pickle file."""
91
+ with open(filepath, "wb") as f:
92
+ pickle.dump(features, f)
93
+ size_mb = os.path.getsize(filepath) / (1024 * 1024)
94
+ print(f"Features saved to: {filepath} ({size_mb:.1f} MB)")
95
+
96
+
97
+ def main():
98
+ """Extract features using VGG16 and/or VGG19."""
99
+ parser = argparse.ArgumentParser(description="Extract VGG features from images")
100
+ parser.add_argument(
101
+ "--backbone", type=str, default="vgg19",
102
+ choices=["vgg16", "vgg19", "both"],
103
+ help="Which backbone to use for extraction (default: vgg19)"
104
+ )
105
+ args = parser.parse_args()
106
+
107
+ if not os.path.exists(FLICKR_IMAGES_DIR):
108
+ print(f"Error: Image directory not found: {FLICKR_IMAGES_DIR}")
109
+ print("Please run preprocess.py first to download the dataset.")
110
+ return
111
+
112
+ backbones = ["vgg16", "vgg19"] if args.backbone == "both" else [args.backbone]
113
+
114
+ for backbone in backbones:
115
+ print("\n" + "=" * 60)
116
+ print(f" Extracting {backbone.upper()} features")
117
+ print("=" * 60)
118
+
119
+ model, preprocess_fn = build_feature_extractor(backbone)
120
+ features = extract_features(model, preprocess_fn, FLICKR_IMAGES_DIR)
121
+
122
+ output_file = VGG16_FEATURES_FILE if backbone == "vgg16" else VGG19_FEATURES_FILE
123
+ save_features(features, output_file)
124
+
125
+ print("\n✓ Feature extraction complete!")
126
+
127
+
128
+ if __name__ == "__main__":
129
+ main()
src/inference.py ADDED
@@ -0,0 +1,416 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ CaptionIQ — Caption Inference
3
+ Greedy search and beam search decoding for generating captions from images.
4
+ """
5
+
6
+ import os
7
+ import sys
8
+ import argparse
9
+ import numpy as np
10
+ from tensorflow.keras.models import load_model
11
+ from tensorflow.keras.preprocessing.sequence import pad_sequences
12
+ from tensorflow.keras.preprocessing.image import load_img, img_to_array
13
+ from tensorflow.keras.applications.vgg16 import VGG16, preprocess_input as vgg16_preprocess
14
+ from tensorflow.keras.applications.vgg19 import VGG19, preprocess_input as vgg19_preprocess
15
+ from tensorflow.keras.models import Model as KerasModel
16
+
17
+ # ── Keras compatibility patch ──────────────────────────────────────
18
+ # Models saved with newer Keras include 'quantization_config' in every
19
+ # layer config. Older Keras versions reject the unknown kwarg.
20
+ # The Embedding layer's mask_zero=True also serialises a NotEqual op
21
+ # that the legacy h5 loader can't resolve by name.
22
+ import keras.src.ops.operation as _keras_op
23
+ from keras.src.ops.numpy import NotEqual as _NotEqual
24
+
25
+ _orig_from_config = _keras_op.Operation.from_config.__func__
26
+
27
+
28
+ @classmethod # type: ignore[misc]
29
+ def _patched_from_config(cls, config): # noqa: N805
30
+ config.pop("quantization_config", None)
31
+ return _orig_from_config(cls, config)
32
+
33
+
34
+ _keras_op.Operation.from_config = _patched_from_config
35
+
36
+ from src.model import BahdanauAttention
37
+ _CUSTOM_OBJECTS = {"NotEqual": _NotEqual, "BahdanauAttention": BahdanauAttention}
38
+ # ───────────────────────────────────────────────────────────────────
39
+
40
+ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
41
+ from src.config import (
42
+ IMAGE_SIZE, BEAM_WIDTH,
43
+ VGG16_MODEL_FILE, VGG19_MODEL_FILE,
44
+ TOKENIZER_FILE, START_TOKEN, END_TOKEN,
45
+ )
46
+ from src.utils import load_tokenizer, word_for_id
47
+
48
+
49
+ def _softmax(values):
50
+ """Stable softmax for confidence normalization."""
51
+ if not values:
52
+ return []
53
+ arr = np.array(values, dtype=np.float64)
54
+ arr = arr - np.max(arr)
55
+ exp_arr = np.exp(arr)
56
+ denom = np.sum(exp_arr)
57
+ if denom <= 0:
58
+ return [0.0] * len(values)
59
+ return (exp_arr / denom).tolist()
60
+
61
+
62
+ def _clean_caption_tokens(words):
63
+ """
64
+ Remove degenerate repetition patterns from generated token list.
65
+ Keeps semantics while avoiding outputs like:
66
+ "dog and dog and dog and ..."
67
+ """
68
+ if not words:
69
+ return []
70
+
71
+ # 1) Remove long runs of the same token.
72
+ collapsed = [words[0]]
73
+ for w in words[1:]:
74
+ if len(collapsed) >= 2 and collapsed[-1] == w and collapsed[-2] == w:
75
+ continue
76
+ collapsed.append(w)
77
+
78
+ # 2) Break repeated bigram loops.
79
+ cleaned = []
80
+ for w in collapsed:
81
+ cleaned.append(w)
82
+ if len(cleaned) >= 6:
83
+ b1 = tuple(cleaned[-2:])
84
+ b2 = tuple(cleaned[-4:-2])
85
+ b3 = tuple(cleaned[-6:-4])
86
+ if b1 == b2 == b3:
87
+ cleaned = cleaned[:-2]
88
+ break
89
+
90
+ return cleaned
91
+
92
+
93
+ def _ending_quality_penalty(words):
94
+ """
95
+ Penalize incomplete or low-quality endings so beam search prefers
96
+ syntactically complete captions.
97
+ """
98
+ if not words:
99
+ return 2.0
100
+
101
+ penalty = 0.0
102
+ weak_endings = {
103
+ "a", "an", "the", "in", "on", "at", "of", "to", "for",
104
+ "with", "by", "from", "and", "or", "but", "as",
105
+ }
106
+
107
+ if words[-1] in weak_endings:
108
+ penalty += 0.9
109
+ if len(words) < 5:
110
+ penalty += 0.35
111
+
112
+ # Penalize excessive duplicate words.
113
+ unique_ratio = len(set(words)) / max(len(words), 1)
114
+ if unique_ratio < 0.6:
115
+ penalty += 0.25
116
+
117
+ return penalty
118
+
119
+
120
+ def greedy_search(model, tokenizer, feature: np.ndarray, max_length: int) -> str:
121
+ """
122
+ Generate a caption using greedy search (pick highest-probability word each step).
123
+
124
+ Args:
125
+ model: Trained captioning model
126
+ tokenizer: Fitted Keras tokenizer
127
+ feature: Image feature vector of shape (4096,)
128
+ max_length: Maximum caption length
129
+
130
+ Returns:
131
+ Generated caption string (without start/end tokens)
132
+ """
133
+ in_text = START_TOKEN
134
+ previous_word = None
135
+ for _ in range(max_length):
136
+ sequence = tokenizer.texts_to_sequences([in_text])[0]
137
+ sequence = pad_sequences([sequence], maxlen=max_length, padding="post")
138
+
139
+ # Predict next word probabilities
140
+ yhat = model.predict([np.expand_dims(feature, 0), sequence], verbose=0)[0]
141
+ ranked = np.argsort(yhat)[::-1]
142
+
143
+ word = None
144
+ for idx in ranked:
145
+ candidate = word_for_id(int(idx), tokenizer)
146
+ if candidate in (None, START_TOKEN):
147
+ continue
148
+ # Avoid immediate repeated tokens when alternatives exist.
149
+ if previous_word is not None and candidate == previous_word:
150
+ continue
151
+ word = candidate
152
+ break
153
+
154
+ if word is None or word == END_TOKEN:
155
+ break
156
+
157
+ previous_word = word
158
+ in_text += " " + word
159
+
160
+ # Remove start token
161
+ caption_words = in_text.replace(START_TOKEN, "").strip().split()
162
+ caption = " ".join(_clean_caption_tokens(caption_words))
163
+ return caption
164
+
165
+
166
+ def _beam_search_core(predict_next_probs, tokenizer, max_length: int, beam_width: int = 3) -> list:
167
+ """
168
+ Shared beam-search logic.
169
+
170
+ Args:
171
+ predict_next_probs: Callable taking padded sequence and returning
172
+ probability vector over vocab.
173
+ tokenizer: Fitted Keras tokenizer
174
+ max_length: Maximum caption length
175
+ beam_width: Number of beams to maintain
176
+ """
177
+ # Each beam: (token_list, cumulative_log_prob)
178
+ start_seq = tokenizer.texts_to_sequences([START_TOKEN])[0]
179
+ if not start_seq:
180
+ return []
181
+
182
+ start_id = start_seq[0]
183
+ beams = [(start_seq, 0.0)]
184
+ completed = []
185
+ candidate_pool = max(beam_width * 5, beam_width)
186
+ alpha = 0.7 # Length penalty strength.
187
+ min_words_before_end = 4
188
+
189
+ for _ in range(max_length):
190
+ all_candidates = []
191
+
192
+ for seq, score in beams:
193
+ # If this sequence already ended, skip
194
+ if len(seq) > 1:
195
+ last_word = word_for_id(seq[-1], tokenizer)
196
+ if last_word == END_TOKEN:
197
+ completed.append((seq, score))
198
+ continue
199
+
200
+ # Pad and predict
201
+ padded = pad_sequences([seq], maxlen=max_length, padding="post")
202
+ yhat = predict_next_probs(padded)
203
+
204
+ # Expand each beam by more than beam_width to keep diverse options.
205
+ top_indices = np.argsort(yhat)[-candidate_pool:]
206
+
207
+ for idx in top_indices:
208
+ idx = int(idx)
209
+ word = word_for_id(idx, tokenizer)
210
+ if word is None:
211
+ continue
212
+
213
+ # Block invalid or degenerate transitions.
214
+ if idx == 0 or idx == start_id:
215
+ continue
216
+ if len(seq) > 1 and idx == seq[-1]:
217
+ continue
218
+ if word == END_TOKEN and (len(seq) - 1) < min_words_before_end:
219
+ continue
220
+
221
+ # Penalize overusing the same word in one caption.
222
+ repeat_count = sum(1 for token_id in seq if token_id == idx)
223
+ repeat_penalty = 0.15 * repeat_count
224
+
225
+ candidate_seq = seq + [idx]
226
+ candidate_score = score + np.log(float(yhat[idx]) + 1e-10) - repeat_penalty
227
+ all_candidates.append((candidate_seq, candidate_score))
228
+
229
+ if not all_candidates:
230
+ break
231
+
232
+ # Keep top beam_width candidates
233
+ all_candidates.sort(key=lambda x: x[1], reverse=True)
234
+ beams = all_candidates[:beam_width]
235
+
236
+ # Add remaining beams to completed
237
+ completed.extend(beams)
238
+
239
+ # Convert sequences to text
240
+ results = []
241
+ for seq, score in completed:
242
+ words = []
243
+ for idx in seq:
244
+ word = word_for_id(idx, tokenizer)
245
+ if word and word != START_TOKEN and word != END_TOKEN:
246
+ words.append(word)
247
+ caption = " ".join(words)
248
+ if caption:
249
+ cleaned_words = _clean_caption_tokens(words)
250
+ if not cleaned_words:
251
+ continue
252
+
253
+ # Length penalty similar to GNMT decoding.
254
+ lp = ((5 + len(cleaned_words)) ** alpha) / ((5 + 1) ** alpha)
255
+ norm_score = score / lp
256
+ norm_score -= _ending_quality_penalty(cleaned_words)
257
+ results.append((" ".join(cleaned_words), norm_score))
258
+
259
+ # Sort by score (best first) and deduplicate
260
+ results.sort(key=lambda x: x[1], reverse=True)
261
+ seen = set()
262
+ unique_results = []
263
+ for caption, score in results:
264
+ if caption not in seen:
265
+ seen.add(caption)
266
+ unique_results.append((caption, score))
267
+ unique_results = unique_results[:beam_width]
268
+ confidences = _softmax([score for _, score in unique_results])
269
+ return [
270
+ (caption, confidence)
271
+ for (caption, _), confidence in zip(unique_results, confidences)
272
+ ]
273
+
274
+
275
+ def beam_search(model, tokenizer, feature: np.ndarray,
276
+ max_length: int, beam_width: int = 3) -> list:
277
+ """
278
+ Beam search for a single model.
279
+ """
280
+ def _predict_single(padded_seq):
281
+ return model.predict([np.expand_dims(feature, 0), padded_seq], verbose=0)[0]
282
+
283
+ return _beam_search_core(_predict_single, tokenizer, max_length, beam_width)
284
+
285
+
286
+ def beam_search_ensemble(models: list, tokenizer, features: list,
287
+ max_length: int, beam_width: int = 5) -> list:
288
+ """
289
+ Beam search with model ensembling by averaging next-token probabilities.
290
+
291
+ Args:
292
+ models: List of trained captioning models.
293
+ tokenizer: Fitted tokenizer.
294
+ features: List of feature tensors aligned with models.
295
+ max_length: Maximum caption length.
296
+ beam_width: Beam size.
297
+ """
298
+ if not models or len(models) != len(features):
299
+ return []
300
+
301
+ def _predict_ensemble(padded_seq):
302
+ probs = []
303
+ for model, feature in zip(models, features):
304
+ p = model.predict([np.expand_dims(feature, 0), padded_seq], verbose=0)[0]
305
+ probs.append(p)
306
+ return np.mean(np.stack(probs, axis=0), axis=0)
307
+
308
+ return _beam_search_core(_predict_ensemble, tokenizer, max_length, beam_width)
309
+
310
+
311
+ def extract_single_image_feature(image_path: str, backbone: str = "vgg16") -> np.ndarray:
312
+ """
313
+ Extract feature vector from a single image using VGG.
314
+
315
+ Args:
316
+ image_path: Path to the image file
317
+ backbone: "vgg16" or "vgg19"
318
+
319
+ Returns:
320
+ Feature vector of shape (4096,)
321
+ """
322
+ if backbone == "vgg16":
323
+ base_model = VGG16(weights="imagenet")
324
+ preprocess_fn = vgg16_preprocess
325
+ else:
326
+ base_model = VGG19(weights="imagenet")
327
+ preprocess_fn = vgg19_preprocess
328
+
329
+ model = KerasModel(
330
+ inputs=base_model.input,
331
+ outputs=base_model.get_layer("block5_pool").output
332
+ )
333
+
334
+ image = load_img(image_path, target_size=(IMAGE_SIZE, IMAGE_SIZE))
335
+ image = img_to_array(image)
336
+ image = np.expand_dims(image, axis=0)
337
+ image = preprocess_fn(image)
338
+
339
+ feature = model.predict(image, verbose=0)[0] # (7, 7, 512)
340
+ h, w, c = feature.shape
341
+ return feature.reshape(h * w, c) # (49, 512)
342
+
343
+
344
+ def generate_caption(image_path: str, backbone: str = "vgg16",
345
+ use_beam: bool = True) -> list:
346
+ """
347
+ Full pipeline: image → feature extraction → caption generation.
348
+
349
+ Args:
350
+ image_path: Path to input image
351
+ backbone: "vgg16", "vgg19", or "ensemble"
352
+ use_beam: If True, use beam search; otherwise greedy
353
+
354
+ Returns:
355
+ List of (caption, score) tuples
356
+ """
357
+ tokenizer = load_tokenizer(TOKENIZER_FILE)
358
+
359
+ if backbone == "ensemble":
360
+ model16 = load_model(VGG16_MODEL_FILE, custom_objects=_CUSTOM_OBJECTS)
361
+ model19 = load_model(VGG19_MODEL_FILE, custom_objects=_CUSTOM_OBJECTS)
362
+ max_length = min(model16.input_shape[1][1], model19.input_shape[1][1])
363
+ feature16 = extract_single_image_feature(image_path, "vgg16")
364
+ feature19 = extract_single_image_feature(image_path, "vgg19")
365
+ if use_beam:
366
+ return beam_search_ensemble(
367
+ [model16, model19], tokenizer, [feature16, feature19], max_length, BEAM_WIDTH
368
+ )
369
+ caption = greedy_search(model19, tokenizer, feature19, max_length)
370
+ return [(caption, 1.0 if caption else 0.0)]
371
+
372
+ model_file = VGG16_MODEL_FILE if backbone == "vgg16" else VGG19_MODEL_FILE
373
+ model = load_model(model_file, custom_objects=_CUSTOM_OBJECTS)
374
+ max_length = model.input_shape[1][1]
375
+ feature = extract_single_image_feature(image_path, backbone)
376
+ if use_beam:
377
+ return beam_search(model, tokenizer, feature, max_length, BEAM_WIDTH)
378
+ caption = greedy_search(model, tokenizer, feature, max_length)
379
+ return [(caption, 1.0 if caption else 0.0)]
380
+
381
+
382
+ def main():
383
+ parser = argparse.ArgumentParser(description="Generate captions for images")
384
+ parser.add_argument("--image", type=str, required=True, help="Path to input image")
385
+ parser.add_argument(
386
+ "--backbone", type=str, default="vgg16",
387
+ choices=["vgg16", "vgg19", "ensemble"],
388
+ help="CNN backbone (default: vgg16)"
389
+ )
390
+ parser.add_argument(
391
+ "--greedy", action="store_true",
392
+ help="Use greedy search instead of beam search"
393
+ )
394
+ args = parser.parse_args()
395
+
396
+ if not os.path.exists(args.image):
397
+ print(f"Error: Image not found: {args.image}")
398
+ return
399
+
400
+ print(f"\nGenerating captions for: {args.image}")
401
+ print(f"Backbone: {args.backbone.upper()}")
402
+ print(f"Method: {'Greedy' if args.greedy else f'Beam (width={BEAM_WIDTH})'}")
403
+ print("-" * 40)
404
+
405
+ results = generate_caption(args.image, args.backbone, not args.greedy)
406
+
407
+ for i, (caption, score) in enumerate(results, 1):
408
+ print(f" #{i}: {caption}")
409
+ if not args.greedy:
410
+ print(f" (score: {score:.4f})")
411
+
412
+ print()
413
+
414
+
415
+ if __name__ == "__main__":
416
+ main()
src/model.py ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ CaptionIQ — Attention-Based CNN-LSTM Caption Generation Model
3
+ Uses Bahdanau (additive) attention over spatial CNN features for
4
+ image-specific caption generation.
5
+ """
6
+
7
+ import tensorflow as tf
8
+ from tensorflow.keras.models import Model
9
+ from tensorflow.keras.layers import (
10
+ Input, Dense, LSTM, Embedding, Dropout, Concatenate, Layer
11
+ )
12
+ from tensorflow.keras.optimizers import Adam
13
+
14
+ import os, sys
15
+ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
16
+ from src.config import (
17
+ EMBED_DIM, LSTM_UNITS, DROPOUT_RATE, FEATURE_DIM,
18
+ FEATURE_LOCATIONS, ATTENTION_DIM, LEARNING_RATE,
19
+ )
20
+
21
+
22
+ class BahdanauAttention(Layer):
23
+ """
24
+ Bahdanau (additive) attention over spatial image features.
25
+
26
+ Given spatial features (batch, 49, 512) and LSTM hidden state (batch, 512):
27
+ score = V * tanh(W1 * features + W2 * hidden)
28
+ weights = softmax(score)
29
+ context = sum(weights * features)
30
+
31
+ This lets the model focus on different image regions for each word.
32
+ """
33
+
34
+ def __init__(self, units, **kwargs):
35
+ super().__init__(**kwargs)
36
+ self.units = units
37
+ self.W1 = Dense(units, name="att_features")
38
+ self.W2 = Dense(units, name="att_hidden")
39
+ self.V = Dense(1, name="att_score")
40
+
41
+ def call(self, inputs):
42
+ features, hidden = inputs
43
+ # features: (batch, locations, feature_dim)
44
+ # hidden: (batch, lstm_units)
45
+
46
+ hidden_expanded = tf.expand_dims(hidden, 1) # (batch, 1, lstm_units)
47
+
48
+ score = tf.nn.tanh(
49
+ self.W1(features) + self.W2(hidden_expanded)
50
+ ) # (batch, locations, attention_dim)
51
+
52
+ attention_weights = tf.nn.softmax(
53
+ self.V(score), axis=1
54
+ ) # (batch, locations, 1)
55
+
56
+ context = tf.reduce_sum(
57
+ attention_weights * features, axis=1
58
+ ) # (batch, feature_dim)
59
+
60
+ return context
61
+
62
+ def get_config(self):
63
+ config = super().get_config()
64
+ config.update({"units": self.units})
65
+ return config
66
+
67
+
68
+ def build_model(vocab_size: int, max_length: int) -> Model:
69
+ """
70
+ Build the attention-based CNN-LSTM image captioning model.
71
+
72
+ Architecture:
73
+ Image: (49, 512) spatial features from VGG block5_pool
74
+ Caption: (max_length,) → Embedding(256) → Dropout(0.3) → LSTM(512)
75
+ Attention: query=LSTM hidden, keys=spatial features → context (512,)
76
+ Merge: Concatenate(context, LSTM) → Dense(512) → Dropout(0.3) → Dense(vocab)
77
+
78
+ Args:
79
+ vocab_size: Vocabulary size (including padding index 0)
80
+ max_length: Maximum caption length in tokens
81
+
82
+ Returns:
83
+ Compiled Keras Model
84
+ """
85
+ # ── Image spatial features ──
86
+ image_input = Input(
87
+ shape=(FEATURE_LOCATIONS, FEATURE_DIM), name="image_input"
88
+ )
89
+
90
+ # ── Caption sequence branch ──
91
+ caption_input = Input(shape=(max_length,), name="caption_input")
92
+ caption_embed = Embedding(
93
+ vocab_size, EMBED_DIM, mask_zero=True, name="caption_embedding"
94
+ )(caption_input)
95
+ caption_drop = Dropout(DROPOUT_RATE, name="caption_dropout")(caption_embed)
96
+ caption_lstm = LSTM(LSTM_UNITS, name="caption_lstm")(caption_drop)
97
+
98
+ # ── Attention over spatial features ──
99
+ context = BahdanauAttention(
100
+ ATTENTION_DIM, name="attention"
101
+ )([image_input, caption_lstm])
102
+
103
+ # ── Merge context + LSTM output ──
104
+ merged = Concatenate(name="merge")([context, caption_lstm])
105
+ dense1 = Dense(LSTM_UNITS, activation="relu", name="dense_relu")(merged)
106
+ dense_drop = Dropout(DROPOUT_RATE, name="dense_dropout")(dense1)
107
+ output = Dense(vocab_size, activation="softmax", name="output")(dense_drop)
108
+
109
+ # ── Build and compile ──
110
+ model = Model(
111
+ inputs=[image_input, caption_input], outputs=output, name="CaptionIQ"
112
+ )
113
+ model.compile(
114
+ loss="categorical_crossentropy",
115
+ optimizer=Adam(learning_rate=LEARNING_RATE),
116
+ )
117
+
118
+ return model
119
+
120
+
121
+ def print_model_summary(vocab_size: int = 5000, max_length: int = 34):
122
+ """Utility to print the model architecture."""
123
+ model = build_model(vocab_size, max_length)
124
+ model.summary()
125
+ return model
126
+
127
+
128
+ if __name__ == "__main__":
129
+ print_model_summary()
src/preprocess.py ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ CaptionIQ — Caption Preprocessing
3
+ Downloads Flickr8K dataset, cleans captions, builds vocabulary,
4
+ creates train/val/test splits, and saves everything to disk.
5
+ """
6
+
7
+ import os
8
+ import re
9
+ import string
10
+ import pickle
11
+ import kagglehub
12
+ import numpy as np
13
+ from collections import Counter
14
+ from tensorflow.keras.preprocessing.text import Tokenizer
15
+ from tqdm import tqdm
16
+
17
+ import sys
18
+ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
19
+ from src.config import (
20
+ DATA_DIR, FLICKR_IMAGES_DIR, FLICKR_TEXT_DIR,
21
+ CAPTIONS_FILE, TOKENIZER_FILE,
22
+ TRAIN_IMAGES_FILE, VAL_IMAGES_FILE, TEST_IMAGES_FILE,
23
+ START_TOKEN, END_TOKEN,
24
+ TRAIN_SIZE, VAL_SIZE, TEST_SIZE,
25
+ MIN_WORD_FREQ,
26
+ )
27
+
28
+
29
+ def download_flickr8k():
30
+ """
31
+ Download Flickr8K dataset using kagglehub.
32
+ Falls back to manual instructions if kagglehub fails.
33
+ """
34
+ print("=" * 60)
35
+ print("Downloading Flickr8K dataset via kagglehub...")
36
+ print("=" * 60)
37
+
38
+ try:
39
+ path = kagglehub.dataset_download("adityajn105/flickr8k")
40
+ print(f"Dataset downloaded to: {path}")
41
+ return path
42
+ except Exception as e:
43
+ print(f"\nkagglehub download failed: {e}")
44
+ print("\nPlease download the Flickr8K dataset manually:")
45
+ print(" 1. Go to https://www.kaggle.com/datasets/adityajn105/flickr8k")
46
+ print(" 2. Download and extract to:")
47
+ print(f" Images → {FLICKR_IMAGES_DIR}")
48
+ print(f" Captions → {FLICKR_TEXT_DIR}")
49
+ return None
50
+
51
+
52
+ def setup_dataset_dirs(kaggle_path: str = None):
53
+ """
54
+ Ensure dataset directories exist and link downloaded data.
55
+ """
56
+ os.makedirs(FLICKR_IMAGES_DIR, exist_ok=True)
57
+ os.makedirs(FLICKR_TEXT_DIR, exist_ok=True)
58
+
59
+ if kaggle_path:
60
+ # kagglehub downloads to a cache dir; copy/link files
61
+ import shutil
62
+ # Find images directory
63
+ for root, dirs, files in os.walk(kaggle_path):
64
+ for f in files:
65
+ src = os.path.join(root, f)
66
+ if f.endswith(".jpg") or f.endswith(".png"):
67
+ dst = os.path.join(FLICKR_IMAGES_DIR, f)
68
+ if not os.path.exists(dst):
69
+ shutil.copy2(src, dst)
70
+ elif f.endswith(".txt") or f.endswith(".csv"):
71
+ dst = os.path.join(FLICKR_TEXT_DIR, f)
72
+ if not os.path.exists(dst):
73
+ shutil.copy2(src, dst)
74
+ print(f"Images copied to: {FLICKR_IMAGES_DIR}")
75
+ print(f"Text files copied to: {FLICKR_TEXT_DIR}")
76
+
77
+
78
+ def load_raw_captions() -> dict:
79
+ """
80
+ Parse raw captions file into {image_id: [caption1, caption2, ...]}.
81
+ Supports both Flickr8k.token.txt format and captions.txt CSV format.
82
+ """
83
+ captions = {}
84
+
85
+ # Try Flickr8k.token.txt format first
86
+ token_file = os.path.join(FLICKR_TEXT_DIR, "Flickr8k.token.txt")
87
+ if os.path.exists(token_file):
88
+ print(f"Loading captions from: {token_file}")
89
+ with open(token_file, "r") as f:
90
+ for line in f:
91
+ line = line.strip()
92
+ if not line:
93
+ continue
94
+ # Format: image_name#caption_idx\tcaption_text
95
+ parts = line.split("\t", 1)
96
+ if len(parts) != 2:
97
+ continue
98
+ img_caption_id, caption = parts
99
+ image_id = img_caption_id.split("#")[0]
100
+ if image_id not in captions:
101
+ captions[image_id] = []
102
+ captions[image_id].append(caption)
103
+ return captions
104
+
105
+ # Try captions.txt CSV format (kaggle version)
106
+ captions_csv = os.path.join(FLICKR_TEXT_DIR, "captions.txt")
107
+ if os.path.exists(captions_csv):
108
+ print(f"Loading captions from: {captions_csv}")
109
+ with open(captions_csv, "r") as f:
110
+ header = f.readline() # skip header
111
+ for line in f:
112
+ line = line.strip()
113
+ if not line:
114
+ continue
115
+ # Format: image,caption
116
+ parts = line.split(",", 1)
117
+ if len(parts) != 2:
118
+ continue
119
+ image_id, caption = parts
120
+ if image_id not in captions:
121
+ captions[image_id] = []
122
+ captions[image_id].append(caption)
123
+ return captions
124
+
125
+ raise FileNotFoundError(
126
+ f"No captions file found. Expected one of:\n"
127
+ f" {token_file}\n"
128
+ f" {captions_csv}\n"
129
+ f"Please download the Flickr8K dataset first."
130
+ )
131
+
132
+
133
+ def clean_caption(caption: str) -> str:
134
+ """
135
+ Clean a single caption:
136
+ - Lowercase
137
+ - Remove punctuation / digits / special chars
138
+ - Remove single-character words (except 'a')
139
+ - Strip extra whitespace
140
+ """
141
+ caption = caption.lower()
142
+ # Remove digits
143
+ caption = re.sub(r"\d+", "", caption)
144
+ # Remove punctuation
145
+ caption = caption.translate(str.maketrans("", "", string.punctuation))
146
+ # Remove single characters except 'a'
147
+ caption = " ".join(w for w in caption.split() if len(w) > 1 or w == "a")
148
+ # Strip extra whitespace
149
+ caption = caption.strip()
150
+ return caption
151
+
152
+
153
+ def clean_all_captions(captions: dict) -> dict:
154
+ """
155
+ Clean all captions and add start/end tokens.
156
+ """
157
+ cleaned = {}
158
+ for image_id, caption_list in tqdm(captions.items(), desc="Cleaning captions"):
159
+ cleaned[image_id] = []
160
+ for cap in caption_list:
161
+ cap = clean_caption(cap)
162
+ cap = f"{START_TOKEN} {cap} {END_TOKEN}"
163
+ cleaned[image_id].append(cap)
164
+ return cleaned
165
+
166
+
167
+ def save_captions(captions: dict, filepath: str):
168
+ """
169
+ Save cleaned captions to file (image_id<tab>caption per line).
170
+ """
171
+ with open(filepath, "w") as f:
172
+ for image_id, caption_list in captions.items():
173
+ for cap in caption_list:
174
+ f.write(f"{image_id}\t{cap}\n")
175
+ print(f"Saved cleaned captions to: {filepath}")
176
+
177
+
178
+ def create_splits(captions: dict):
179
+ """
180
+ Split image IDs into train / val / test sets.
181
+ Uses Flickr8K official split files if available, otherwise random split.
182
+ """
183
+ all_images = sorted(captions.keys())
184
+
185
+ # Try official split files
186
+ train_file = os.path.join(FLICKR_TEXT_DIR, "Flickr_8k.trainImages.txt")
187
+ val_file = os.path.join(FLICKR_TEXT_DIR, "Flickr_8k.devImages.txt")
188
+ test_file = os.path.join(FLICKR_TEXT_DIR, "Flickr_8k.testImages.txt")
189
+
190
+ if all(os.path.exists(f) for f in [train_file, val_file, test_file]):
191
+ print("Using official Flickr8K split files...")
192
+ train = _load_split_file(train_file, all_images)
193
+ val = _load_split_file(val_file, all_images)
194
+ test = _load_split_file(test_file, all_images)
195
+ else:
196
+ print("Official splits not found — creating random splits...")
197
+ np.random.seed(42)
198
+ np.random.shuffle(all_images)
199
+ train = all_images[:TRAIN_SIZE]
200
+ val = all_images[TRAIN_SIZE:TRAIN_SIZE + VAL_SIZE]
201
+ test = all_images[TRAIN_SIZE + VAL_SIZE:TRAIN_SIZE + VAL_SIZE + TEST_SIZE]
202
+
203
+ # Save split files
204
+ _save_split(train, TRAIN_IMAGES_FILE, "Train")
205
+ _save_split(val, VAL_IMAGES_FILE, "Val")
206
+ _save_split(test, TEST_IMAGES_FILE, "Test")
207
+
208
+ return train, val, test
209
+
210
+
211
+ def _load_split_file(filepath: str, valid_images: list) -> list:
212
+ """Load image IDs from an official split file."""
213
+ valid_set = set(valid_images)
214
+ with open(filepath, "r") as f:
215
+ return [line.strip() for line in f if line.strip() in valid_set]
216
+
217
+
218
+ def _save_split(image_ids: list, filepath: str, name: str):
219
+ """Save a list of image IDs to file."""
220
+ with open(filepath, "w") as f:
221
+ for img_id in image_ids:
222
+ f.write(f"{img_id}\n")
223
+ print(f" {name}: {len(image_ids)} images → {filepath}")
224
+
225
+
226
+ def build_tokenizer(captions: dict, train_images: list) -> Tokenizer:
227
+ """
228
+ Fit a Keras Tokenizer on training captions only.
229
+ Filters vocabulary to keep only words with frequency >= MIN_WORD_FREQ.
230
+ Save to disk as pickle.
231
+ """
232
+ # Collect all training captions
233
+ train_captions = []
234
+ train_set = set(train_images)
235
+ for img_id in train_set:
236
+ if img_id in captions:
237
+ train_captions.extend(captions[img_id])
238
+
239
+ # Fit tokenizer (word_index is ordered by frequency)
240
+ tokenizer = Tokenizer()
241
+ tokenizer.fit_on_texts(train_captions)
242
+
243
+ total_words = len(tokenizer.word_index)
244
+
245
+ # Filter: keep only words with frequency >= MIN_WORD_FREQ
246
+ freq_words = sum(
247
+ 1 for c in tokenizer.word_counts.values()
248
+ if c >= MIN_WORD_FREQ
249
+ )
250
+
251
+ print(f" Total unique words: {total_words}")
252
+ print(f" Words with freq >= {MIN_WORD_FREQ}: {freq_words}")
253
+ print(f" Filtered out: {total_words - freq_words} rare words")
254
+
255
+ # num_words keeps the top (num_words - 1) words by frequency
256
+ tokenizer.num_words = freq_words + 1 # +1 for padding index 0
257
+ vocab_size = tokenizer.num_words
258
+ print(f"Vocabulary size: {vocab_size}")
259
+
260
+ # Compute max caption length
261
+ max_length = max(len(cap.split()) for cap in train_captions)
262
+ print(f"Max caption length: {max_length}")
263
+
264
+ # Save tokenizer
265
+ with open(TOKENIZER_FILE, "wb") as f:
266
+ pickle.dump(tokenizer, f)
267
+ print(f"Tokenizer saved to: {TOKENIZER_FILE}")
268
+
269
+ return tokenizer
270
+
271
+
272
+ def main():
273
+ """Run the full preprocessing pipeline."""
274
+ print("=" * 60)
275
+ print(" CaptionIQ — Preprocessing Pipeline")
276
+ print("=" * 60)
277
+
278
+ # Step 1: Download dataset
279
+ kaggle_path = download_flickr8k()
280
+ setup_dataset_dirs(kaggle_path)
281
+
282
+ # Step 2: Load and clean captions
283
+ raw_captions = load_raw_captions()
284
+ print(f"Loaded captions for {len(raw_captions)} images")
285
+
286
+ cleaned_captions = clean_all_captions(raw_captions)
287
+ save_captions(cleaned_captions, CAPTIONS_FILE)
288
+
289
+ # Step 3: Create train/val/test splits
290
+ train, val, test = create_splits(cleaned_captions)
291
+
292
+ # Step 4: Build tokenizer on training data
293
+ tokenizer = build_tokenizer(cleaned_captions, train)
294
+
295
+ print("\n" + "=" * 60)
296
+ print(" Preprocessing complete!")
297
+ print("=" * 60)
298
+ print(f" Cleaned captions: {CAPTIONS_FILE}")
299
+ print(f" Tokenizer: {TOKENIZER_FILE}")
300
+ print(f" Train split: {len(train)} images")
301
+ print(f" Val split: {len(val)} images")
302
+ print(f" Test split: {len(test)} images")
303
+
304
+
305
+ if __name__ == "__main__":
306
+ main()
src/train.py ADDED
@@ -0,0 +1,291 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ CaptionIQ — Training Script
3
+ Data generator + training loop for VGG16 and VGG19 captioning models.
4
+ """
5
+
6
+ import os
7
+ import sys
8
+ import argparse
9
+ import math
10
+ import numpy as np
11
+ import tensorflow as tf
12
+ import matplotlib
13
+ matplotlib.use("Agg")
14
+ import matplotlib.pyplot as plt
15
+ from tensorflow.keras.models import load_model
16
+ from tensorflow.keras.utils import to_categorical
17
+ from tensorflow.keras.preprocessing.sequence import pad_sequences
18
+ from tensorflow.keras.callbacks import ModelCheckpoint, EarlyStopping, ReduceLROnPlateau
19
+
20
+ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
21
+ from src.config import (
22
+ EPOCHS, BATCH_SIZE, MAX_LENGTH, FEATURE_DIM, FEATURE_LOCATIONS,
23
+ VGG16_FEATURES_FILE, VGG19_FEATURES_FILE,
24
+ VGG16_MODEL_FILE, VGG19_MODEL_FILE,
25
+ VGG16_LOSS_PLOT, VGG19_LOSS_PLOT,
26
+ CAPTIONS_FILE, TOKENIZER_FILE,
27
+ TRAIN_IMAGES_FILE, VAL_IMAGES_FILE,
28
+ MODELS_DIR, OUTPUTS_DIR,
29
+ EARLY_STOP_PATIENCE, LR_PATIENCE, LR_FACTOR,
30
+ )
31
+ from src.utils import load_captions, load_image_list, load_features, load_tokenizer, get_vocab_size
32
+ from src.model import build_model, BahdanauAttention
33
+
34
+
35
+ def data_generator(captions: dict, features: dict, tokenizer,
36
+ max_length: int, vocab_size: int, batch_size: int):
37
+ """
38
+ Generator that yields batches of ((image_features, partial_sequence), next_word).
39
+
40
+ For each image-caption pair, creates multiple training samples:
41
+ Input: image features + first k words → Target: (k+1)th word
42
+
43
+ Yields:
44
+ ((img_features_batch, seq_batch), target_batch)
45
+ """
46
+ image_ids = list(captions.keys())
47
+
48
+ while True:
49
+ np.random.shuffle(image_ids)
50
+ img_batch, seq_batch, target_batch = [], [], []
51
+
52
+ for img_id in image_ids:
53
+ if img_id not in features:
54
+ continue
55
+
56
+ img_feature = features[img_id]
57
+
58
+ for caption in captions[img_id]:
59
+ # Encode the caption as a sequence of integers
60
+ seq = tokenizer.texts_to_sequences([caption])[0]
61
+
62
+ # Create input-output pairs for each subsequence
63
+ for i in range(1, len(seq)):
64
+ # Input: partial sequence up to position i
65
+ in_seq = pad_sequences([seq[:i]], maxlen=max_length, padding="post")[0]
66
+ # Output: next word (one-hot)
67
+ out_word = to_categorical([seq[i]], num_classes=vocab_size)[0]
68
+
69
+ img_batch.append(img_feature)
70
+ seq_batch.append(in_seq)
71
+ target_batch.append(out_word)
72
+
73
+ if len(img_batch) >= batch_size:
74
+ yield (
75
+ (np.array(img_batch, dtype=np.float32),
76
+ np.array(seq_batch, dtype=np.int32)),
77
+ np.array(target_batch, dtype=np.float32)
78
+ )
79
+ img_batch, seq_batch, target_batch = [], [], []
80
+
81
+ # Yield remaining samples
82
+ if img_batch:
83
+ yield (
84
+ (np.array(img_batch, dtype=np.float32),
85
+ np.array(seq_batch, dtype=np.int32)),
86
+ np.array(target_batch, dtype=np.float32)
87
+ )
88
+
89
+
90
+ def make_dataset(captions, features, tokenizer, max_length, vocab_size, batch_size):
91
+ """Wrap the Python generator in a tf.data.Dataset with proper output_signature."""
92
+ dataset = tf.data.Dataset.from_generator(
93
+ lambda: data_generator(captions, features, tokenizer,
94
+ max_length, vocab_size, batch_size),
95
+ output_signature=(
96
+ (
97
+ tf.TensorSpec(shape=(None, FEATURE_LOCATIONS, FEATURE_DIM), dtype=tf.float32),
98
+ tf.TensorSpec(shape=(None, max_length), dtype=tf.int32),
99
+ ),
100
+ tf.TensorSpec(shape=(None, vocab_size), dtype=tf.float32),
101
+ )
102
+ )
103
+ return dataset.prefetch(tf.data.AUTOTUNE)
104
+
105
+
106
+ def count_steps(captions: dict, features: dict, tokenizer, batch_size: int) -> int:
107
+ """Count total training steps per epoch."""
108
+ total = 0
109
+ for img_id in captions:
110
+ if img_id not in features:
111
+ continue
112
+ for caption in captions[img_id]:
113
+ seq = tokenizer.texts_to_sequences([caption])[0]
114
+ total += len(seq) - 1 # number of subsequences per caption
115
+ # Use ceil so every sample is seen each epoch (including final partial batch).
116
+ return max(1, math.ceil(total / batch_size))
117
+
118
+
119
+ def compute_max_length(captions: dict) -> int:
120
+ """Compute maximum caption length from the data."""
121
+ max_len = 0
122
+ for caps in captions.values():
123
+ for cap in caps:
124
+ length = len(cap.split())
125
+ if length > max_len:
126
+ max_len = length
127
+ return max_len
128
+
129
+
130
+ def plot_loss(history: dict, filepath: str, title: str):
131
+ """Plot and save training loss curve."""
132
+ plt.figure(figsize=(10, 6))
133
+ plt.plot(history["loss"], label="Training Loss", color="#4a90d9", linewidth=2)
134
+ if "val_loss" in history:
135
+ plt.plot(history["val_loss"], label="Validation Loss", color="#e74c3c", linewidth=2)
136
+ plt.title(title, fontsize=14, fontweight="bold")
137
+ plt.xlabel("Epoch", fontsize=12)
138
+ plt.ylabel("Loss", fontsize=12)
139
+ plt.legend(fontsize=11)
140
+ plt.grid(True, alpha=0.3)
141
+ plt.tight_layout()
142
+ plt.savefig(filepath, dpi=150)
143
+ plt.close()
144
+ print(f"Loss plot saved to: {filepath}")
145
+
146
+
147
+ def train(backbone: str = "vgg16", epochs: int = None, resume: bool = True):
148
+ """
149
+ Train the captioning model with specified backbone features.
150
+
151
+ Args:
152
+ backbone: "vgg16" or "vgg19"
153
+ epochs: Override default epoch count
154
+ """
155
+ epochs = epochs or EPOCHS
156
+
157
+ # ── Select files based on backbone ──
158
+ if backbone == "vgg16":
159
+ features_file = VGG16_FEATURES_FILE
160
+ model_file = VGG16_MODEL_FILE
161
+ loss_plot = VGG16_LOSS_PLOT
162
+ else:
163
+ features_file = VGG19_FEATURES_FILE
164
+ model_file = VGG19_MODEL_FILE
165
+ loss_plot = VGG19_LOSS_PLOT
166
+
167
+ print("=" * 60)
168
+ print(f" CaptionIQ — Training with {backbone.upper()}")
169
+ print("=" * 60)
170
+
171
+ # ── Load data ──
172
+ print("\nLoading data...")
173
+ all_captions = load_captions(CAPTIONS_FILE)
174
+ tokenizer = load_tokenizer(TOKENIZER_FILE)
175
+ features = load_features(features_file)
176
+ train_images = load_image_list(TRAIN_IMAGES_FILE)
177
+ val_images = load_image_list(VAL_IMAGES_FILE)
178
+
179
+ vocab_size = get_vocab_size(tokenizer)
180
+ print(f" Vocabulary size: {vocab_size}")
181
+
182
+ # Filter captions for train/val splits
183
+ train_captions = {k: v for k, v in all_captions.items() if k in train_images}
184
+ val_captions = {k: v for k, v in all_captions.items() if k in val_images}
185
+ print(f" Train images: {len(train_captions)}")
186
+ print(f" Val images: {len(val_captions)}")
187
+
188
+ # Compute max length from training data
189
+ max_length = compute_max_length(train_captions)
190
+ print(f" Max caption length: {max_length}")
191
+
192
+ # ── Build or resume model ──
193
+ if resume and os.path.exists(model_file):
194
+ print(f"\nLoading existing checkpoint to resume training: {model_file}")
195
+ try:
196
+ model = load_model(
197
+ model_file,
198
+ custom_objects={"BahdanauAttention": BahdanauAttention}
199
+ )
200
+ except Exception as exc:
201
+ print(f" Warning: could not load existing model ({exc}). Rebuilding from scratch.")
202
+ model = build_model(vocab_size, max_length)
203
+ else:
204
+ print("\nBuilding model...")
205
+ model = build_model(vocab_size, max_length)
206
+
207
+ model.summary()
208
+
209
+ # ── Create tf.data.Dataset ──
210
+ train_dataset = make_dataset(
211
+ train_captions, features, tokenizer, max_length, vocab_size, BATCH_SIZE
212
+ )
213
+ val_dataset = make_dataset(
214
+ val_captions, features, tokenizer, max_length, vocab_size, BATCH_SIZE
215
+ )
216
+
217
+ train_steps = count_steps(train_captions, features, tokenizer, BATCH_SIZE)
218
+ val_steps = count_steps(val_captions, features, tokenizer, BATCH_SIZE)
219
+ print(f" Train steps/epoch: {train_steps}")
220
+ print(f" Val steps/epoch: {val_steps}")
221
+
222
+ # ── Callbacks ──
223
+ os.makedirs(MODELS_DIR, exist_ok=True)
224
+ os.makedirs(OUTPUTS_DIR, exist_ok=True)
225
+
226
+ callbacks = [
227
+ ModelCheckpoint(
228
+ model_file, monitor="val_loss", save_best_only=True, verbose=1
229
+ ),
230
+ ReduceLROnPlateau(
231
+ monitor="val_loss", factor=LR_FACTOR, patience=LR_PATIENCE,
232
+ min_lr=1e-6, verbose=1
233
+ ),
234
+ EarlyStopping(
235
+ monitor="val_loss", patience=EARLY_STOP_PATIENCE,
236
+ restore_best_weights=True, verbose=1
237
+ ),
238
+ ]
239
+
240
+ # ── Train ──
241
+ print(f"\nTraining for {epochs} epochs...")
242
+ history = model.fit(
243
+ train_dataset,
244
+ steps_per_epoch=train_steps,
245
+ epochs=epochs,
246
+ validation_data=val_dataset,
247
+ validation_steps=val_steps,
248
+ callbacks=callbacks,
249
+ verbose=1,
250
+ )
251
+
252
+ # ── Save final model ──
253
+ model.save(model_file)
254
+ print(f"\nModel saved to: {model_file}")
255
+
256
+ # ── Plot loss ──
257
+ plot_loss(
258
+ history.history, loss_plot,
259
+ f"CaptionIQ Training Loss — {backbone.upper()}"
260
+ )
261
+
262
+ return model, history
263
+
264
+
265
+ def main():
266
+ parser = argparse.ArgumentParser(description="Train CaptionIQ model")
267
+ parser.add_argument(
268
+ "--backbone", type=str, default="vgg19",
269
+ choices=["vgg16", "vgg19", "both"],
270
+ help="Which backbone features to use (default: vgg19)"
271
+ )
272
+ parser.add_argument(
273
+ "--epochs", type=int, default=None,
274
+ help=f"Number of epochs (default: {EPOCHS})"
275
+ )
276
+ parser.add_argument(
277
+ "--resume", action=argparse.BooleanOptionalAction, default=True,
278
+ help="Resume from existing model checkpoint if available (default: enabled)"
279
+ )
280
+ args = parser.parse_args()
281
+
282
+ backbones = ["vgg16", "vgg19"] if args.backbone == "both" else [args.backbone]
283
+
284
+ for backbone in backbones:
285
+ train(backbone, args.epochs, args.resume)
286
+
287
+ print("\n✓ Training complete!")
288
+
289
+
290
+ if __name__ == "__main__":
291
+ main()
src/utils.py ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ CaptionIQ — Shared Utility Functions
3
+ Load captions, image lists, features, and tokenizer from disk.
4
+ """
5
+
6
+ import pickle
7
+ from typing import Dict, List, Set
8
+
9
+
10
+ def load_captions(filepath: str) -> Dict[str, List[str]]:
11
+ """
12
+ Load cleaned captions from file.
13
+
14
+ Expected format per line:
15
+ image_id<tab>caption text
16
+
17
+ Returns:
18
+ dict mapping image_id → list of caption strings
19
+ """
20
+ captions = {}
21
+ with open(filepath, "r") as f:
22
+ for line in f:
23
+ line = line.strip()
24
+ if not line:
25
+ continue
26
+ parts = line.split("\t", 1)
27
+ if len(parts) != 2:
28
+ continue
29
+ image_id, caption = parts
30
+ if image_id not in captions:
31
+ captions[image_id] = []
32
+ captions[image_id].append(caption)
33
+ return captions
34
+
35
+
36
+ def load_image_list(filepath: str) -> Set[str]:
37
+ """
38
+ Load a set of image IDs from a text file (one per line).
39
+ """
40
+ with open(filepath, "r") as f:
41
+ return {line.strip() for line in f if line.strip()}
42
+
43
+
44
+ def load_features(pkl_path: str) -> Dict[str, any]:
45
+ """
46
+ Load pre-extracted image features from a pickle file.
47
+
48
+ Returns:
49
+ dict mapping image_id → numpy array of shape (4096,)
50
+ """
51
+ with open(pkl_path, "rb") as f:
52
+ return pickle.load(f)
53
+
54
+
55
+ def load_tokenizer(pkl_path: str):
56
+ """
57
+ Load a fitted Keras Tokenizer from a pickle file.
58
+ """
59
+ with open(pkl_path, "rb") as f:
60
+ return pickle.load(f)
61
+
62
+
63
+ def word_for_id(integer: int, tokenizer) -> str:
64
+ """
65
+ Map an integer index back to a word using the tokenizer.
66
+ Uses a cached reverse index for O(1) lookup.
67
+ Returns None if the index is not found or exceeds num_words.
68
+ """
69
+ if not hasattr(tokenizer, '_reverse_index'):
70
+ tokenizer._reverse_index = {
71
+ idx: word for word, idx in tokenizer.word_index.items()
72
+ }
73
+ # Respect vocab filtering
74
+ if tokenizer.num_words is not None and integer >= tokenizer.num_words:
75
+ return None
76
+ return tokenizer._reverse_index.get(integer, None)
77
+
78
+
79
+ def get_vocab_size(tokenizer) -> int:
80
+ """Get vocabulary size, respecting num_words filter if set."""
81
+ if tokenizer.num_words is not None:
82
+ return tokenizer.num_words
83
+ return len(tokenizer.word_index) + 1