Fai Micro Report
Fai Micro Report
A PROJECT REPORT
Submitted by
(4350705)
Page 2 of 20
VISION: To mould young and fresh minds into challenging computer professionals with ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
R.C. TECHNICAL INSTITUTE, AHMEDABAD
COMPUTER ENGINEERING DEPARTMENT
VISION: To mould young and fresh minds into challenging computer professionals with ethical Page 2 of 20
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
Course Outcome
Micro-Project Assessment
CO Enrolment No
RB1 RB2 RB3 RB4 RB5 TOTAL
Covered
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
Table of Contents :
1. Introduction
....................................................................................................... (Page 1)
a. 1.1 Overview of the Project
b. 1.2 Purpose of Animal Prediction
2. Problem Statement ..................................................................... (Page 2)
a. 2.1 Motivation Behind Wild Animal Prediction
b. 2.2 Real-World Applications
3. System Requirements ................................................................. (Page 3)
a. 3.1 Hardware Requirements
b. 3.2 Software Requirements
4. Dataset Description .................................................................... (Page 4)
a. 4.1 Overview of the Wild Animal Dataset
b. 4.2 Dataset Preprocessing and Augmentation
5. Model Architecture .................................................................... (Page 5)
a. 5.1 Pre-trained MobileNetV2
b. 5.2 Why Use Transfer Learning
c. 5.3 Modifications for Wild Animal Classification
6. Program Structure ..................................................................... (Page 6)
a. 6.1 GUI Implementation using Tkinter
b. 6.2 Image Processing using TensorFlow and OpenCV
c. 6.3 Integration of Model and Image Classification
7. Model Training and Evaluation .............................................. (Page 7)
a. 7.1 Training Process
b. 7.2 Evaluation Metrics
c. 7.3 Confusion Matrix and Accuracy
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
10. Image Capture and Prediction ................................................ (Page 16)
a. 10.1 Uploading an Image
b. 10.2 Real-time Image Capture Using Webcam
c. 10.3 Wild Animal Prediction Results
11. Challenges and Limitations ..................................................... (Page 17)
a. 11.1 Model Limitations
b. 11.2 Dataset Constraints
c. 11.3 Accuracy and Speed Trade-offs
12. Conclusion and Future Work ................................................. (Page 18)
a. 12.1 Summary of Findings
b. 12.2 Potential Improvements
c. 12.3 Future Enhancements for Wild Animal Prediction
13. References ................................................................................. (Page 19)
a. 13.1 Books, Articles, and Online Resources
14. Appendix ................................................................................... (Page 20)
a. 14.1 Python Code
b. 14.2 Additional Results and Screenshots
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
1. Introduction :
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
2. Problem Statement :
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
3. System Requirements :
• Python 3.x
• TensorFlow: Deep learning framework for model
training and prediction
• Tkinter: For building the graphical user interface (GUI)
• OpenCV: For capturing images from a webcam
• Pillow: For image manipulation in Python
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
4. Dataset Description :
The dataset used for this project consists of images of wild animals
commonly found in the wild. The dataset includes classes such as
Lion, Tiger, Elephant, Cheetah, Zebra, Deer, Rhino, Wolf, Fox, Bear,
and others. These images are gathered from various online resources
and repositories.
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
5. Model Architecture :
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
6. Program Structure :
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
7. Model Training and Evaluation :
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
8. Code and Explanation :
import tkinter as tk
from tkinter import filedialog, messagebox
import tensorflow as tf
from tensorflow.keras.applications import MobileNetV2
from tensorflow.keras.applications.mobilenet_v2 import
preprocess_input, decode_predictions
from PIL import Image, ImageTk
import numpy as np
from sklearn.metrics import precision_score, recall_score, f1_score
def preprocess_image(image_path):
"""
Preprocess the image to match the input shape of MobileNetV2.
"""
image = Image.open(image_path)
image = image.resize((224, 224)) # MobileNetV2 expects 224x224
images
image = np.array(image)
image = preprocess_input(image) # Preprocess the image for
MobileNetV2
image = np.expand_dims(image, axis=0) # Add batch dimension
return image
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
def identify_animal(image_path):
"""
Predict the class of the animal using the pre-trained MobileNetV2
model.
"""
image = preprocess_image(image_path)
predictions = model.predict(image)
decoded_predictions = decode_predictions(predictions, top=5)[0]
# Get top-5 predictions
def calculate_metrics():
"""
Calculate and display precision, recall, and F1 score.
"""
if len(true_labels) > 0 and len(predicted_labels) > 0:
precision = precision_score(true_labels, predicted_labels,
average='weighted', zero_division=0)
recall = recall_score(true_labels, predicted_labels,
average='weighted', zero_division=0)
f1 = f1_score(true_labels, predicted_labels, average='weighted',
zero_division=0)
def upload_image():
"""
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
Handle the image upload, display the image, and show the
prediction.
"""
file_path = filedialog.askopenfilename()
if file_path:
# Display the uploaded image
img = Image.open(file_path)
img.thumbnail((300, 300)) # Resize for display purposes
img_tk = ImageTk.PhotoImage(img)
img_label.config(image=img_tk)
img_label.image = img_tk
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
img_label = tk.Label(app)
img_label.pack()
Explanation :
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
2. Defining Wild Animal Classes:
python
Copy code
WILD_ANIMAL_CLASSES = [
"Lion", "Tiger", "Elephant", "Leopard",
"Cheetah", "Giraffe",
"Zebra", "Deer", "Rhino", "Panda", "Wolf",
"Fox", "Bear", "Buffalo", "Hyena"
]
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
def preprocess_image(image_path):
...
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
def upload_image():
..
a. This function allows the user to upload an image. It
displays the image in the GUI, identifies the animal, and
appends the true and predicted labels to the respective lists
for metrics calculation. It also invokes the
calculate_metrics() function to update the metrics
display.
9. Creating the GUI Application:
python
Copy code
app = tk.Tk()
...
app.mainloop()
a. The main application window is created using tkinter.
A button is added to upload an image, labels are added to
display the image and results, and the GUI event loop is
started.
GUI Elements
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
9. Experimental Results :
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
10. Image Capture and Prediction :
Users can upload an image file from their device. The image is
displayed in the GUI, and the prediction result is shown after
processing.
The model outputs the predicted animal species based on the uploaded
or captured image, helping users identify various wild animals in real-
time.
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
11. Challenges and Limitations :
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
12. Conclusion and Future Work :
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
13. References :
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.
14. Appendix :
VISION: To mould young and fresh minds into challenging computer professionals with Page 2 of 20
ethical
values and shaping them with upcoming technologies and develop the ability to deal with real world
situations with skills and innovative ideas.