DL Ex 13
DL Ex 13
PROJECT EXP 13
CODE:
import numpy as np import
pandas as pd import cv2 import
tensorflow as from tensorflow.keras.layers import Input, Conv2D, MaxPooling2D,
UpSampling2D, Fla en, Dense, BatchNormaliza on, Ac va on, Add from tensorflow.keras.models
import Model from sklearn.model_selec on import train_test_split from sklearn.preprocessing
import LabelEncoder
# Load the CSV file containing image paths and labels df = pd.read_csv('balanced_dataset.csv') #
Update 'your_dataset.csv' with the path to your CSV file image_paths = df['Image_Path'].values labels =
df['Label'].values
# Decoder x =
UpSampling2D((2, 2))(x)
decoded = Conv2D(3, (3, 3), ac va on='sigmoid', padding='same')(x) # Output image with 3
channels (RGB)
# Extract compressed representa ons using the encoder part of the autoencoder encoder
= Model(input_img, x)
X_train_compressed = encoder.predict(X_train)
X_test_compressed = encoder.predict(X_test)
x = Add()([x, x_shortcut]) x
= Ac va on('relu')(x)
return x
x = Add()([x, x_shortcut]) x
= Ac va on('relu')(x)
return x
OUTPUT: