GithubHelp home page GithubHelp logo

muhamuttaqien / siamese-fruits-detector Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 1.0 14.79 MB

:apple: Computer Vision project to detect different varieties of fruits and vegetables included: Apple, Banana, Eggplant, Hazelnut, Kiwi, Lychee, Mango, Onion, Orange, Pear, Potato etc. using Siamese Network (One-Shot-Learning Technique).

Jupyter Notebook 100.00%
artificial-intelligence visual-learning computer-vision one-shot-learning siamese-network

siamese-fruits-detector's Introduction

Siamese Fruits Detector

Computer Vision project to detect different varieties of fruits and vegetables included: Apple, Banana, Eggplant, Hazelnut, Kiwi, Lychee, Mango, Onion, Orange, Pear, Potato etc. using Siamese Network, one of powerful one-shot-learning techniques currently getting increasingly popular in Deep Learning research and applications.

Datasets

Datasets was obtained and carefully filtered from Kaggle Fruit 360 consisting of 82213 RGB images of 120 fruits and vegetables. I only obtained 1627 images of fruits and vegetables for this project.

Train Images

I turned the training images into Luminance-based (not RGB) images in order to avoid the network cheating the colour of fruits or vegetables while predicting the dissimilarity score of two input images. Each class of the train images only contains 10 images to train the network.

Test Images

Test Images cover six classes of fruits and vegetables variants. All the classes were not included when I trained the network:

  • Strawberry
  • Tomato Cherry Red
  • Pepper Yellow
  • Cauliflower
  • Grapefruit Pink
  • Guava
  • Clementine
  • Physalis with Husk

Deep Learning Framework

To research and implement the technique, I was supported by two popular open-source Deep Learning framework, namely: Pytorch and ReNom.

Learning Process

Hyper-parameters I set to train the network were:

  • BATCH_SIZE = 64
  • N_EPOCHS = 20
  • LR = 0.0005
  • Optimizer = Adam
  • Loss Function = Contrastive Loss

The plot showed that the model learned the problem fast, achieving a low loss within just a few training epochs.

Work Results

As shown from the following results, the network can successfully differentiated all testing images. When the pair of two simillar images but categorized in the same class were fed into the network, it can predicted its dissimilarity in lowest score.

Note that, these variety of fruits and vegetables were never seen by the network during training process!

Pepper Yellow

Tomato Cherry Red

Grapefruit Pink

Physalis with Husk

Lesson Learned

According to the research I conducted, I found that there are 3 crucial points to notice when building Siamese network:

  1. Datasets we obtain to train the network must be balanced with as many positive as negative samples since we want the network to learn well similarity function, otherwise learning process doesn’t meet desired result

  2. The layers in the two subnetwork must share the same weights each other. This allows the network to learn symmetrically while capturing meaningful features for a pair of input image

  3. Calculating the squared distances of the feature vectors. To measure the performance of the network, we can experience with three popular distance metrics proposed by research including binary-cross entropy, contrastive and triplet loss. For my case, I used contrastive loss to lead learning process into good result

Dependencies

This project requires Python 3.6 and the following Python libraries installed:

siamese-fruits-detector's People

Contributors

muhamuttaqien avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

benwufc

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.