Code Monkey home page Code Monkey logo

mosquito-species-identification-model's Introduction

Mosquito-Species-Identification-Model

Overview

Created by Abdullah Zubair as part of Honours Undergraduate Thesis (University of Calgary BHSc) titled 'Development and Evaluation of a Machine Learning-Based Image Classification Web Application for Mosquito Species Identification for Species Present in Alberta, Canada'

Main Objectives for this Project

i. Build a comprehensive image dataset by capturing images of mosquito species currently found within Alberta and combining with published image datasets.

ii. Create and evaluate a CNN model using transfer learning with a known and tested architecture and train, validate, and test the model using the image dataset.

iii. Develop a user-friendly Flask web application that allows users to easily upload multiple images and receive species identification results from the trained CNN model.

Details

Folders and Files

Folders

  • App - This folder contains the files needed to run the Flask app along with the .pth file which has the weights for the model used by the app
  • Model - This folder contains all the python files used to create, train, and test the model along with creating figures based on the model metrics
  • Images - This folder is the image datset created for this project and as such it contains all the images captured with each subfolder using the convention 'genus_species'

Files

  • App/environment.yml - contains a list of dependencies and their versions and is to be used to create the conda environment to run the Flask app
  • App/app.py - This is main Python file that contains the Flask app
  • App/best_model.pth - This is the Pytorch model that the Flask app will use
  • App/templates/index.html - Home page/entry point for a web application
  • App/templates/result.html - Page that displays the output from the ML model for each image
  • App/best_model.pth - Stores the PyTorch model which is used for the Flask app
  • Model/data_utils.py - Contains all the data-related functions for the model (More information present within the file)
  • Model/visualize.py - Contains functions for visualizing and saving various plots and metrics related to the model (More information present within the file)
  • Model/train_eval.py - Contains the core functionality for training and evaluating the model (More information present within the file)
  • Model/main.py - This is the main file as it serves as the entry point for training and evaluating the mosquito identification model (More information present within the file)

Installation

Conda Environment

The environment.yml file contains a list of dependencies and their versions. First install Conda if you havent then to set up a virtual environment using conda use the command:

conda env create -f environment.yml -n (env_name).

Then activate the environment by running:

conda activate (env_name)

To Run the Files to Create the Model

Change the directories used to save the checkpoints and obtain the images within the main.py file (lines 32 and 33)

Running the Web App

The Flask app has only been tested on a HPC specifically the ARC HPC at the University of Calgary, however, it can run on a local machine with a GPU.

Running on a Cluster

For Unix-based Systems

  1. Open Terminal, ssh and Login to ARC, and Run an interactive session on one of ARC's GPU nodes

Here is the command for that:

salloc --ntasks=1 --cpus-per-task=4 --mem=16G --time=00:10:00 --gpus-per-node=1

You can adjust the time argument depending on how long you plan to run the app (currently set for 10 minutes)

  1. Activate conda environment made earlier

  2. Navigate to the app directory and run the app

Once running it should give you text that shows you that the application is running and accessible on a certain IP addresse Here is an example:

Running on http://127.0.0.1:8888

  1. Open another terminal/command prompt window and connect to ARC using the normal SSH client with the tunnel option

Here are the commands for that:

ssh (Your Username)@arc.ucalgary.ca -L 8888:(specific node you are on):8888

This command depends on which GPU node you were assigned in your interactive session Here is an example of that command:

ssh [email protected] -L 8888:fg1:8888

  1. Now go back to the first terminal/command prompt window with the app running and copy the IP address and paste it into your browser

The IP address that starts with 127 is the one that should work and then pasting that address into Chrome or Safari should let you then access and use the app!

Running Locally

  1. Activate conda environment made earlier
  2. Navigate to the app directory and run the app
  3. Copy the IP address provided by the app and paste it into your browser

mosquito-species-identification-model's People

Contributors

ahzr199 avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.