0% found this document useful (0 votes)
15 views7 pages

Input

The document outlines experiments conducted using Convolutional Neural Networks (CNN) and Artificial Neural Networks (ANN) for image recognition and age classification. It details the implementation of a CNN model using TensorFlow for recognizing images from the CIFAR-10 dataset and an ANN for predicting the age group of an actor from uploaded images using the DeepFace library. The results include training accuracy and age predictions, demonstrating the effectiveness of the models.

Uploaded by

csecgirls0203
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views7 pages

Input

The document outlines experiments conducted using Convolutional Neural Networks (CNN) and Artificial Neural Networks (ANN) for image recognition and age classification. It details the implementation of a CNN model using TensorFlow for recognizing images from the CIFAR-10 dataset and an ANN for predicting the age group of an actor from uploaded images using the DeepFace library. The results include training accuracy and age predictions, demonstrating the effectiveness of the models.

Uploaded by

csecgirls0203
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

RollNo:22NE1A05G0

EXPERIMENT-1
Aim:-Build a Convolution Neural Network for Image Recognition. Go
through the modules of the course mentioned and answer the self-assessment
questions given in the link below at the end of the course.
INPUT:
import tensorflow as tf
from [Link] import layers, models
import [Link] as plt
OUTPUT:
Downloading data from [Link]
170498071/170498071 4s 0us/step
INPUT:
x_train, x_test = x_train / 255.0, x_test / 255.0
class_names= ['airplane','automobile','bird','cat','deer','dog','frog','horse','ship','truck']
model = [Link]([
layers.Conv2D(32, (3,3), activation='relu', input_shape=(32, 32, 3)),
layers.MaxPooling2D((2,2)),

layers.Conv2D(64, (3,3), activation='relu'),


layers.MaxPooling2D((2,2)),

layers.Conv2D(64, (3,3), activation='relu'),

[Link](),
[Link](64, activation='relu'),
[Link](10) ])
OUTPUT:
/usr/local/lib/python3.12/dist-packages/keras/src/layers/convolutional/base_conv.py:113:
UserWarning: Do not pass an `input_shape`/`input_dim` argument to a layer. When using
Sequential models, prefer using an `Input(shape)` object as the first layer in the model
instead.

TIRUMALA ENGINEERING COLLEGE PageNo:1


RollNo:22NE1A05G0
super().__init__(activity_regularizer=activity_regularizer, **kwargs)
INPUT:
[Link](optimizer='adam',
loss=[Link](from_logits=True),
metrics=['accuracy'])
history = [Link](x_train, y_train, epochs=5,
validation_data=(x_test, y_test))
OUTPUT:
Epoch 1/5
1563/1563 71s 44ms/step - accuracy:
0.3702 - loss: 1.7135 - val_accuracy: 0.5603 - val_loss: 1.2176
Epoch 2/5
1563/1563 82s 44ms/step - accuracy:
0.5851 - loss: 1.1653 - val_accuracy: 0.6319 - val_loss: 1.0754
Epoch 3/5
1563/1563 67s 43ms/step - accuracy:
0.6492 - loss: 0.9939 - val_accuracy: 0.6626 - val_loss: 0.9718
Epoch 4/5
1563/1563 68s 44ms/step - accuracy:
0.6916 - loss: 0.8810 - val_accuracy: 0.6787 - val_loss: 0.9256
Epoch 5/5
1563/1563 81s 43ms/step - accuracy:
0.7101 - loss: 0.8218 - val_accuracy: 0.6911 - val_loss: 0.8898
INPUT:
test_loss, test_acc = [Link](x_test, y_test, verbose=2)
print('\nTest accuracy:', test_acc)
OUTPUT:
313/313 - 3s - 11ms/step - accuracy: 0.6911 - loss: 0.8898
Test accuracy: 0.691100001335144
INPUT:
[Link]([Link]['accuracy'], label='Train Acc')

TIRUMALA ENGINEERING COLLEGE PageNo:2


RollNo:22NE1A05G0
[Link]([Link]['val_accuracy'], label='Test Acc')
[Link]('Epoch')
[Link]('Accuracy')
[Link]()
[Link]()
OUTPUT:

TIRUMALA ENGINEERING COLLEGE PageNo:3


RollNo:22NE1A05G0
EXPERIMENT-2
Aim:- Understanding and Using ANN : Identifying age group of an actor. Design
Artificial Neural Networks for Identifying and Classifying an actor using Kaggle Dataset.
INPUT:
!pip install deepface –quiet
import cv2
import [Link] as plt
from deepface import DeepFace
from tkinter import filedialog, Tk
from [Link] import files
import cv2
import [Link] as plt
from deepface import DeepFace
import numpy as np
from PIL import Image
import io
uploaded = [Link]()
OUTPUT:-

INPUT:-
for filename in [Link]():
image_data = uploaded[filename]
image = [Link]([Link](image_data))
image = [Link]('RGB') # Ensure 3-channel
img_np = [Link](image)
img_bgr = [Link](img_np, cv2.COLOR_RGB2BGR)
[Link](image)
[Link]('off')

TIRUMALA ENGINEERING COLLEGE PageNo:4


RollNo:22NE1A05G0
[Link]("Uploaded Image")
[Link]()
OUTPUT:-

INPUT:-
result = [Link](img_path=img_bgr, actions=['age'], enforce_detection=False)
age = result[0]['age']
def get_age_group(age):
if age < 13:
return "Child"
elif age < 20:
return "Teen"
elif age < 50:
return "Adult"
else:
return "Senior"
age_group = get_age_group(age)
print(f"Predicted Age: {age}")
print(f"Age Group: {age_group}")

TIRUMALA ENGINEERING COLLEGE PageNo:5


RollNo:22NE1A05G0
OUTPUT:-
Predicted Age: 56
Age Group: Senior

EXPERIMENT-3

TIRUMALA ENGINEERING COLLEGE PageNo:6


RollNo:22NE1A05G0
Aim:-

TIRUMALA ENGINEERING COLLEGE PageNo:7

You might also like