Batch - 7 FINAL Review (DEEP LEARNING)
Batch - 7 FINAL Review (DEEP LEARNING)
Batch - 7 FINAL Review (DEEP LEARNING)
PARKING PLACES
DETECTION USING DEEP
LEARNING
Project Members:
S.JOHN JOSHUA
ID NO:
2100069003,2100069008,2100069030
1
2
Dataset Details
Taken 12,416 image samples along
with corresponding captions
6. Convolutional
1. Data Loading And Neural Network
7. VGG Model
Preprocessing (CNN)
Implementation
2. Sequential Model
5. Random Mini-
For Binary 8. RNN Model
Batch Evaluation
Classification
3. Sequential Model
By Adding Various 4. Sequential Model
9. LSTM
Optimization For Multi-Class
Techniques
4
DEVELOPE PROJECT TITLE USING WEB
APPLICATION
5
6
Data Loading And Preprocessing
For image captioning, data loading involves fetching image-caption pairs from a dataset
like MSCOCO. Preprocessing includes resizing images to a fixed size, normalizing pixel
values, and tokenizing captions into words for input into the neural network model.
These steps ensure compatibility between the visual and textual data for training the deep
learning model.
• 1. Resizing
• 2. Grayscale Conversion
• 3. Cropping
• 4. Rotation
• 5. Flipping (Horizontal/Vertical)
• 6. Brightness Adjustment
• 7. Contrast Adjustment
• 8. Gaussian Blurring
• 9. Histogram Equalization
• 10. Edge Detection
• 11. Padding
7
Data Loading And Preprocessing
Data Loading And Preprocessing
Data Loading And Preprocessing
Binary Classification
The project employs a binary classification model to predict the presence or absence of a
target variable based on input features. Through preprocessing steps like scaling,
encoding, and handling missing values, the data is prepared for training. The model
undergoes training on the training dataset and is evaluated on a separate testing set to
assess its performance and generalization ability.
model = Sequential([
Flatten(input_shape=(img_height, img_width, 3)),
Dense(128, activation='relu'),
Dense(1, activation='sigmoid')
])
1. Data Pre-processing
2. Model Selection
3. Adam Optimization
4. RMSprop Optimization
5. Stochastic Gradient Descent (SGD) Optimization
6. Model Training and Evaluation
7. Comparison and Analysis
Sequential Model for Different Optimization Techniques
import tensorflow as tf
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dense
from tensorflow.keras.optimizers import SGD, RMSprop, Adam
import matplotlib.pyplot as plt
17
# Function to train the model with a given optimizer
def train_model(optimizer, epochs=20):
model = build_model()
model.compile(optimizer=optimizer,
loss='binary_crossentropy',
metrics=['accuracy'])
history = model.fit(train_generator, epochs=epochs, validation_data=test_generator)
return history
1. Importing Libraries
2. Randomly Selecting Classes
3. Setting Parameters
4. Data Preprocessing and Augmentation
5. Loading Training Data
6. Defining the Model
7. Compiling the Model
8. Training the Model
9. Plotting Training Accuracy
Sequential Model For Multi-Class
from tensorflow.keras.layers import Dropout
model = Sequential([
Flatten(input_shape=(img_height, img_width, 3)),
Dense(256, activation='relu'),
Dropout(0.5),
Sequential Model Dense(128, activation='relu'),
Dropout(0.3),
For Multi-Class Dense(num_classes, activation='softmax')
])
model.compile(optimizer='adam',
loss='categorical_crossentropy', metrics=['accuracy'])
history = model.fit(train_generator, epochs=20,
validation_data=val_generator)
Sequential Model For Multi-Class
Random Mini-Batch
Random Mini-Batch training, a pivotal strategy in deep learning, involves dividing data into
small, random subsets called mini-batches. These subsets are utilized iteratively to update
model parameters, offering efficiency and enhanced convergence. This approach optimizes
memory usage, accelerates training through parallel processing, improves generalization, and
introduces stochasticity for regularization.
• Importing Libraries
• Defining the Neural Network Class
• Data Transformation and Loading
• Setting Parameters
• Model Initialization
• Defining Loss Function and Optimizer
• Training Loop
• Monitoring Performance
• Plotting Training Accuracy
Random Mini-Batch
from tensorflow.keras.preprocessing.image import img_to_array,
load_img
import numpy as np
• Importing Libraries
• Data Augmentation
• Loading Training Data
• Defining the Model
• Compiling the Model
• Training the Model
• Displaying Training Accuracy
• Plotting Training Accuracy
Convolutional Neural Network Model(CNN)
import tensorflow as tf
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dense, Dropout
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.callbacks import LearningRateScheduler, EarlyStopping
import matplotlib.pyplot as plt
test_datagen = ImageDataGenerator(rescale=1.0/255)
Convolutional Neural Network Model(CNN)
30
Convolutional Neural Network Model(CNN)
# Function to train the model with a given optimizer
def train_model(optimizer, epochs=20):
model = build_model()
model.compile(optimizer=optimizer,
loss='binary_crossentropy',
metrics=['accuracy'])
history = model.fit(train_generator, epochs=epochs, validation_data=test_generator, callbacks=[lr_scheduler, early_stopping])
return history
31
Convolutional Neural Network Model(CNN)
Visual Geometry Group(VGG)
The VGG model, originally designed for image classification, has been adapted for image captioning tasks in
deep learning projects. Leveraging its deep convolutional architecture with multiple layers, VGG extracts
intricate features from images. These features are then fed into recurrent neural networks to generate
descriptive captions, enhancing the model's ability to understand and articulate visual content.
33
Visual Geometry Group
import tensorflow as tf
from tensorflow.keras.preprocessing.image import
ImageDataGenerator
from tensorflow.keras.applications import VGG16
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Flatten, Dropout
import matplotlib.pyplot as plt
# Parameters
img_width, img_height = 224, 224
batch_size = 32
epochs = 10
34
Visual Geometry Group
# Data Preprocessing
train_datagen = ImageDataGenerator(rescale=1./255, shear_range=0.2,
zoom_range=0.2, horizontal_flip=True)
test_datagen = ImageDataGenerator(rescale=1./255)
train_generator = train_datagen.flow_from_directory(train_data_dir,
target_size=(img_width, img_height),
batch_size=batch_size, class_mode='binary')
validation_generator = test_datagen.flow_from_directory(validation_data_dir,
target_size=(img_width, img_height),
batch_size=batch_size, class_mode='binary')
# Training
history = model.fit(train_generator, steps_per_epoch=train_generator.samples // batch_size,
validation_data=validation_generator,
validation_steps=validation_generator.samples // batch_size,
epochs=epochs)
36
LSTM
In image captioning using deep learning, LSTM (Long Short-Term Memory) models are utilized for their ability
to capture sequential information and long-range dependencies. These models excel in understanding
context and generating coherent captions by learning from both image features and preceding words.
Through recurrent connections and gating mechanisms, LSTM networks effectively encode and decode
image-context relationships, providing meaningful descriptions for images.
1. Importing Libraries
2. Loading Images and Captions
3. Preprocessing Images and Captions
4. Tokenizing and Padding Captions
5. Loading Labels (Assuming binary classification)
6. Building the LSTM Model
7. Compiling the Model
8. Training the Model
9. Evaluating the Model
10. Extracting Patterns and Insights
37
LSTM
import numpy as np
import tensorflow as tf
from tensorflow.keras.applications import VGG16
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import LSTM, Dense
from tensorflow.keras.callbacks import EarlyStopping
import matplotlib.pyplot as plt
# Parameters
img_width, img_height = 224, 224
batch_size = 32
epochs = 50
n_lstm_units = 128
38
LSTM
# Load pre-trained VGG model
vgg_model = VGG16(weights='imagenet', include_top=False,
input_shape=(img_width, img_height, 3))