imdeep2905 / COMP6721_Winter2023_GroupA

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

COMP6721-Winter2023-GroupA

This repo contains .pth model files so it may be large in the size. To download the project we recommend using this link (~130MB). This only downloads the latest version of the repo (and not the git history).

Contents

  1. Introduction
  2. Downloading Datasets
  3. How to Run
  4. Acknowledgment

Introduction

The present research project was undertaken as a component of the Applied Artificial Intelligence (COMP6721) course that was taught at Concordia University during the Winter 2023 semester. The main objective of this study is to conduct a comparative analysis of various established Convolutional Neural Network (CNN) architectures in the context of Animal Classification.

Downloading Datasets

Note that to split the dataset we use a python script. Make sure to see Installing Requirements section prior to running the script.

Animal With Attributes 2

An overview of the dataset used in this study is available here. This dataset, which is the largest among all other datasets utilized, can be downloaded from here. The size of the compressed dataset is approximately 13GB. After downloading, the dataset can be extracted to any desired folder. Next, to split the dataset into train, test, and validation subsets, the script available here (with the path to the dataset updated accordingly) can be run. It should be noted that only 11 specific classes were utilized in this study, namely antelope, cow, deer, elephant, giraffe, horse, lion, rabbit, sheep, squirrel, and zebra. Therefore, prior to executing the script to split the dataset, any unnecessary class folders can be directly deleted.

Animal 10

This dataset is available on the kaggle and can be accessed via this link. Similar to stated above after downloading and extracting the dataset, run this script to split the dataset. Again do not forget to change the path pointing to the dataset in the script. We used the following classes: Spider, Horse, Dog, Elephant, Sheep, Cow, Squirrel, and Cat. The folders for the rest of the classes can be deleted prior to running the script.

Animal Faces

This dataset is available on the kaggle and can be accessed via this link. During our study, we used all of the classes available in the dataset. Again, to split the dataset run run this script.

How to Run

Installing Requirements

You can find all the requirements to run the project in this. To install the requirement run the following command:

pip install -r requirements.txt

These requirements file does not include the pytorch. To install it you can go to this link and generate an appropriate command to install the pytorch.

Sample Dataset

A sample dataset has been included in this folder, along with the code. The dataset is divided into three folders: awa2, animal10, and animalfaces, each containing three subfolders: train, test, and val. The dataset includes three images for each of the categories and can be used to run the project without having to download the entire dataset. Note that you may still have to change the paths pointing to the datasets wherever necessary. Usually the paths are defined in the first cell of the notebook.

Training From Scratch

Generally we followed this training workflow:

  1. Train the model from scratch. While training, save training logs and models at each epoch in a csv file. You can use these notebooks to train models from scratch:
Dataset MobilenetV2 VGG11 Resnet18
Awa2 notebook notebook notebook
Animal 10 notebook notebook notebook
Animal Faces notebook notebook notebook

Please make sure to change the path pointing to the dataset accordingly.

  1. After the training is completed, load the trained model and CSV file to create graphs, confusion matrices, and other relevant data.

Using a Pretrained Model

We have uploaded some of the models we trained. This pretrained models can be used to observe our model's performance without having to train them from the beginning. We have also uploaded some notebooks demonstrating this in this folder. You can run any of the notebooks to see our models in action (both on the dataset and images from the internet)!

Acknowledgment

We would like to thank Dr. Mahdi S. Hosseini for the highly effective course instruction, as well as to all of the Teaching Assistants who provided guidance and support throughout the project.

About


Languages

Language:Jupyter Notebook 100.0%Language:Python 0.0%