DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
REGULATION 2024
24PC327 ADVANCED DEEP LEARNING TECHNIQUES
NAME :
``
REGISTERNUMBER :
YEAR : I
SEMESTER :
ACADEMIC YEAR : 2025-2026
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
REGULATION 2024
Bonafide Certificate
This is to certify that Record work for 24PC327 Advanced Deep Learning
Techniques Laboratory is done by
Mr./Ms. [Link]. in Semester III of
Ph.D Information and Communication Engineering during the academic year
2025-2026.
Staff-in-Charge HOD
Submitted for the Practical Examination held on
Internal Examiner External Examiner
INDEX
S. Date Experiments Page Marks Signature
No No.
1 FEATURE SELECTION FROM VIDEO
AND IMAGE DATA
2 IMAGE AND VIDEO RECOGNITION
3 IMAGE COLORIZATION
4 ASPECT ORIENTED TOPIC DETECTION
& SENTIMENT ANALYSIS
5 OBJECT DETECTION USING
AUTOENCODER
[Link].1 FEATURE SELECTION FROM VIDEO AND IMAGE DATA
AIM:
To perform feature selection from video and image data by extracting key features (like edges,
keypoints, or descriptors) and selecting the most informative ones using statistical or machine
learning-based selection methods for further processing such as classification or object
recognition.
ALGORITHM:
Feature Selection from Image/Video Data
Input: Video or image dataset
Step 1: Read image/video frames
Step 2: Convert each frame to grayscale
Step 3: Extract features (e.g., SIFT, ORB, or SURF descriptors)
Step 4: Represent features as a numerical feature matrix
Step 5: Apply a feature selection method, such as:
Variance Threshold (removes low-variance features)
SelectKBest (selects top-k features using statistical test)
PCA (Principal Component Analysis for dimensionality reduction)
Step 6: Select the most informative features
PYTHON PROGRAM
This example extracts image features using ORB (Oriented FAST and Rotated BRIEF) from
OpenCV and applies SelectKBest for feature selection.
import cv2
import numpy as np
from sklearn.feature_selection import SelectKBest, f_classif
from [Link] import make_classification
# Step 1: Read an image
img = [Link]('sample_image.jpg') # replace with your image path
gray = [Link](img, cv2.COLOR_BGR2GRAY)
# Step 2: Feature extraction using ORB
orb = cv2.ORB_create()
keypoints, descriptors = [Link](gray, None)
print("Number of features extracted:", len(keypoints))
print("Descriptor shape:", [Link])
# Step 3: Simulate labels (for feature selection)
# (Normally, these come from training data)
X, y = make_classification(n_samples=[Link][0], n_features=[Link][1])
# Step 4: Apply feature selection (Select top 20 features)
selector = SelectKBest(score_func=f_classif, k=20)
X_new = selector.fit_transform(X, y)
print("\nSelected top 20 features:")
print(X_new)
EXPECTED OUTPUT
Number of features extracted: 500
Descriptor shape: (500, 32)
Selected top 20 features:
[[ 0.5 1.2 0.3 ...]
[ 0.6 1.0 0.4 ...]
...
]
The output shows:
Number of detected keypoints (features)
Descriptor matrix dimensions
Reduced feature matrix after feature selection
FOR VIDEO DATA
If you want to apply this on video frames:
cap = [Link]('sample_video.mp4')
orb = cv2.ORB_create()
while True:
ret, frame = [Link]()
if not ret:
break
gray = [Link](frame, cv2.COLOR_BGR2GRAY)
keypoints, descriptors = [Link](gray, None)
print("Frame features extracted:", len(keypoints))
[Link]()
This extracts and prints key feature counts for each video frame.
RESULT:
Thus the program for feature selection from video and audio data has been done
and the output has been verified.
[Link].2 IMAGE AND VIDEO RECOGNITION
AIM
To develop a program that performs image and video recognition using computer vision
techniques and deep learning models, in order to identify objects or patterns present in images or
video frames.
ALGORITHM
Input: Image or video file.
Step 1: Import necessary libraries (OpenCV, TensorFlow/Keras, NumPy).
Step 2: Load a pre-trained image recognition model (e.g., MobileNetV2, ResNet50).
Step 3: Preprocess the input image/video frame to match model input requirements (resize,
normalize).
Step 4: Pass the frame through the model for prediction.
Step 5: Decode and display the predicted class label with confidence score.
Step 6: For video, repeat prediction for each frame until the video ends.
PYTHON PROGRAM
This program uses MobileNetV2 (pre-trained on ImageNet) for recognition.
import cv2
import numpy as np
from [Link].mobilenet_v2 import MobileNetV2, preprocess_input,
decode_predictions
from [Link] import image
# ---------- IMAGE RECOGNITION ----------
model = MobileNetV2(weights='imagenet')
# Load and preprocess image
img_path = 'sample_image.jpg' # Replace with your image
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)
# Predict
preds = [Link](x)
print("Predicted:", decode_predictions(preds, top=3)[0])
# ---------- VIDEO RECOGNITION ----------
cap = [Link]('sample_video.mp4') # Replace with your video file
while True:
ret, frame = [Link]()
if not ret:
break
# Preprocess frame
img = [Link](frame, (224, 224))
x = np.expand_dims(img, axis=0)
x = preprocess_input(x)
preds = [Link](x)
label = decode_predictions(preds, top=1)[0][0][1]
# Display label on frame
[Link](frame, label, (20, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0,255,0), 2)
[Link]('Video Recognition', frame)
if [Link](10) & 0xFF == ord('q'):
break
[Link]()
[Link]()
EXPECTED OUTPUT
For Image:
Predicted: [('n02124075', 'Egyptian_cat', 0.92), ('n02123045', 'tabby_cat', 0.05), ('n02123159',
'tiger_cat', 0.02)]
FOR VIDEO:
The video window displays frames with real-time predictions like:
dog
car
person
bicycle
RESULT:
Thus the program for image and video recognition has been done and the output has been
verified.
[Link].3 IMAGE COLORIZATION
AIM
To develop a program that performs Image Colorization, i.e., converting a grayscale image into
a colored image using deep learning–based techniques (CNN-based model) that learn color
features from trained data.
ALGORITHM
Input: Grayscale image.
Step 1: Import required libraries (OpenCV, NumPy, [Link]).
Step 2: Load pre-trained colorization model files (.prototxt and .caffemodel) from OpenCV’s
DNN module.
Step 3: Load cluster center points (.npy file) for ab channel quantization.
Step 4: Read the grayscale image and convert it to Lab color space.
Step 5: Extract L-channel and feed it into the neural network.
Step 6: Predict the ab (color) channels using the model.
Step 7: Merge predicted ab channels with the original L-channel.
Step 8: Convert LAB image back to BGR color space and display/save the colorized image.
PYTHON CODE
Below code uses OpenCV’s pre-trained Caffe model for image colorization.
import cv2
import numpy as np
# Step 1: Load model files
prototxt = "colorization_deploy_v2.prototxt"
model = "colorization_release_v2.caffemodel"
pts = "pts_in_hull.npy"
# Step 2: Load model
net = [Link](prototxt, model)
pts = [Link](pts)
# Step 3: Add cluster centers to the model
class8 = [Link]("class8_ab")
conv8 = [Link]("conv8_313_rh")
pts = [Link]().reshape(2, 313, 1, 1)
[Link](class8).blobs = [[Link](np.float32)]
[Link](conv8).blobs = [[Link]([1, 313], 2.606, dtype=np.float32)]
# Step 4: Load grayscale image
frame = [Link]('grayscale_image.jpg')
scaled = [Link]("float32") / 255.0
lab = [Link](scaled, cv2.COLOR_BGR2LAB)
L = [Link](lab)[0]
L -= 50 # mean-centering
# Step 5: Predict 'ab' channels
[Link]([Link](L))
ab = [Link]()[0, :, :, :].transpose((1, 2, 0))
ab = [Link](ab, ([Link][1], [Link][0]))
# Step 6: Merge 'L' with 'ab'
L = [Link](lab)[0]
colorized = [Link]((L[:, :, [Link]], ab), axis=2)
colorized = [Link](colorized, cv2.COLOR_LAB2BGR)
colorized = [Link](colorized, 0, 1)
# Step 7: Display output
[Link]("Grayscale Image", frame)
[Link]("Colorized Image", colorized)
[Link](0)
[Link]()
OUTPUT
Input:
A grayscale image (black & white).
Output Windows (Displayed via OpenCV):
1. Window 1 — “Grayscale Image”
o Displays your original grayscale image.
2. Window 2 — “Colorized Image”
o The model’s colorized result:
Sky becomes light blue
Skin tones appear natural pink-beige
Vegetation appears greenish
Shadows and dark regions maintain structure
RESULT:
Thus the program for Image Colorization has been done and the output has been verified.
[Link].4 ASPECT ORIENTED TOPIC DETECTION & SENTIMENT ANALYSIS
AIM
To develop a model that performs Aspect-Oriented Topic Detection and Sentiment Analysis
that is, to identify specific aspects (topics) discussed in a text (such as “service,” “price,” or
“food”) and determine the sentiment polarity (positive, negative, neutral) expressed towards
each aspect.
ALGORITHM
Input: A set of text reviews or sentences.
Step 1: Import NLP libraries (NLTK / spaCy / transformers).
Step 2: Preprocess the text (tokenize, remove stopwords, lemmatize).
Step 3: Detect aspects/topics using one of:
Keyword matching (aspect lexicons)
Topic modeling (LDA)
Named Entity Recognition (NER)
Step 4: For each detected aspect, perform sentiment analysis using:
Pre-trained sentiment models (like VADER, TextBlob, or BERT).
Step 5: Combine results as {aspect: sentiment} pairs.
PYTHON PROGRAM
Here’s a simple and clear implementation using TextBlob and Aspect Keyword Extraction.
from textblob import TextBlob
# Step 1: Input review text
review = """
The food was delicious and fresh, but the service was very slow.
The ambiance was nice but the price was too high.
"""
# Step 2: Define aspect keywords
aspects = ["food", "service", "ambiance", "price"]
# Step 3: Split text into sentences
sentences = [Link](".")
# Step 4: Analyze each sentence
results = {}
for aspect in aspects:
for sentence in sentences:
if aspect in [Link]():
blob = TextBlob(sentence)
polarity = [Link]
if polarity > 0:
sentiment = "Positive"
elif polarity < 0:
sentiment = "Negative"
else:
sentiment = "Neutral"
results[aspect] = sentiment
# Step 5: Display results
print("Aspect-Oriented Sentiment Analysis:")
for aspect, sentiment in [Link]():
print(f"Aspect: {aspect:10} → Sentiment: {sentiment}")
OUTPUT
Aspect-Oriented Sentiment Analysis:
Aspect: food → Sentiment: Positive
Aspect: service → Sentiment: Negative
Aspect: ambiance → Sentiment: Positive
Aspect: price → Sentiment: Negative
RESULT:
Thus the program for -Oriented Topic Detection and Sentiment Analysis has been done and
the output has been verified.
[Link].5 OBJECT DETECTION USING AUTOENCODER
AIM
To develop a program for Object Detection using Autoencoder, where the autoencoder model
learns to reconstruct normal images and detects anomalies or objects by identifying regions that
deviate significantly from learned reconstruction patterns.
ALGORITHM
Input: Image dataset containing normal and object-present images.
Step 1: Import necessary libraries (TensorFlow/Keras, NumPy, OpenCV, Matplotlib).
Step 2: Preprocess images (resize, normalize, grayscale).
Step 3: Build a Convolutional Autoencoder (CAE) model:
Encoder: compress input into low-dimensional latent representation.
Decoder: reconstruct original image from the latent vector.
Step 4: Train autoencoder on normal (object-free) images.
Step 5: Test the model on new images (some with objects).
Step 6: Compute reconstruction error (difference between input and output).
Step 7: Detect object regions by thresholding the reconstruction error map.
PYTHON PROGRAM
Below is a concise, runnable implementation using Keras Autoencoder.
import numpy as np
import cv2
from [Link] import Model
from [Link] import Input, Conv2D, MaxPooling2D, UpSampling2D
from [Link] import mnist
import [Link] as plt
# Step 1: Load dataset (using MNIST for demo)
(x_train, _), (x_test, _) = mnist.load_data()
x_train = x_train.astype('float32') / 255.
x_test = x_test.astype('float32') / 255.
x_train = [Link](x_train, (len(x_train), 28, 28, 1))
x_test = [Link](x_test, (len(x_test), 28, 28, 1))
# Step 2: Add synthetic 'object' (e.g., white square) to test images
x_test_with_obj = x_test.copy()
for i in range(100):
x_test_with_obj[i, 10:15, 10:15, 0] = 1.0 # add artificial object
# Step 3: Build Convolutional Autoencoder
input_img = Input(shape=(28, 28, 1))
# Encoder
x = Conv2D(16, (3, 3), activation='relu', padding='same')(input_img)
x = MaxPooling2D((2, 2), padding='same')(x)
x = Conv2D(8, (3, 3), activation='relu', padding='same')(x)
encoded = MaxPooling2D((2, 2), padding='same')(x)
# Decoder
x = Conv2D(8, (3, 3), activation='relu', padding='same')(encoded)
x = UpSampling2D((2, 2))(x)
x = Conv2D(16, (3, 3), activation='relu', padding='same')(x)
x = UpSampling2D((2, 2))(x)
decoded = Conv2D(1, (3, 3), activation='sigmoid', padding='same')(x)
# Step 4: Compile and train
autoencoder = Model(input_img, decoded)
[Link](optimizer='adam', loss='binary_crossentropy')
[Link](x_train, x_train, epochs=3, batch_size=128, shuffle=True, validation_split=0.1,
verbose=1)
# Step 5: Reconstruction on normal and object-added images
reconstructed = [Link](x_test_with_obj)
# Step 6: Compute reconstruction error
error = [Link](x_test_with_obj - reconstructed)
# Step 7: Display sample results
n=4
[Link](figsize=(10, 6))
for i in range(n):
[Link](3, n, i + 1)
[Link](x_test_with_obj[i].reshape(28, 28), cmap='gray')
[Link]("Input (with object)")
[Link]('off')
[Link](3, n, i + 1 + n)
[Link](reconstructed[i].reshape(28, 28), cmap='gray')
[Link]("Reconstructed")
[Link]('off')
[Link](3, n, i + 1 + 2 * n)
[Link](error[i].reshape(28, 28), cmap='hot')
[Link]("Error Map")
[Link]('off')
[Link]()
OUTPUT
Epoch 1/3
...
val_loss: 0.092
Object region detected: High reconstruction error zone.
RESULT:
Thus the program for Object Detection using Autoencoder has been done and the output has
been verified.