Skip to content

deksa89/Insect-Classification-Model-Pytorch

Repository files navigation

Insect classification model made using pytorch

INTRO

This is my first model which is actually the result of my experience in forestry and completed a course in the field of artificial intelligence. The project is just a basis for creating a much bigger model that would be actually useful for those unexperienced in entomology. Creating my first model was a big deal to me but collecting insect images was strenuous but I got help from Faculty of Forestry in Zagreb and google.

During this project I learned a lot what is going on "under the hood" when model is using training images and setting up its weights in order to be able to recognize given object, how to use image augmentation in order to expand my dataset, plot images and confusion matrix using matplotlib and scikit-learn or using tensorboard to track model's curve to tell whether model is overfitting or underfitting.

It's just a beginning :D

Project Description:

  • this is a small and demonstrative project that classifies 12 different insects and returns their latin names
  • those insects are: Adalia bipunctata, Calliteara pudibunda, Cerambyx cerdo, Gryllotalpa gryllotalpa, Lucanus cervus, Mantis religiosa, Melolontha melolontha, Phyrrochorus apterus, Rhaphigaster nebulosa, Sesia apiformis, Tettigonia viridissima, Xylocopa violacea
  • image classification is done by using torch 1.10.2, matplotlib 3.5.1 for visualization and scikit-learn 1.0.2 for making a confusion matrix
  • model was fed with 5500 images of 12 different insects splited in 3 folders: training, validation and test
  • final model was trained using pretrained resnet18 which showed high accuracy on test images >94% after just 4 epochs
  • I have also tried model from https://github.com/rwightman/pytorch-image-models but built-in resnet18 did its job
  • frontend was cloned from https://github.com/codebasics/potato-disease-classification/tree/main/frontend and the background image was replaced as well as the title

to run the model:

  • clone the repository
  • install requirements.txt
  • run pytorch_insect_classification_model.ipynb

results matplotlib confusion_matrix successfully returned ping

FRONTEND part of the project

to install frontend:

  • install NodeJS and NPM
  • install dependencies in frontend folder cd Desktop/Insects/frontend by typing npm install --from-lock-json and then npm audit fix
  • copy and rename .env.example to .env and change REACT_APP_API_URL to API URL if needed

to run frontend:

  • first run model.py and fast.py
  • go to frontend folder in cmd, e.g. C:\Users\User\Desktop\torch_model\frontend>
  • run the frontend by typing npm run start in cmd

Screenshot

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages