Git Product home page Git Product logo

googlenet-inception's Introduction

GoogLeNet for Image Classification

  • This repository contains the examples of natural image classification using pre-trained model as well as training a Inception network from scratch on CIFAR-10 dataset (93.64% accuracy on testing set). The pre-trained model on CIFAR-10 can be download from here.
  • Architecture of GoogLeNet from the paper: googlenet

Requirements

Implementation Details

For testing the pre-trained model

  • Images are rescaled so that the smallest side equals 224 before fed into the model. This is not the same as the original paper which is an ensemble of 7 similar models using 144 224x224 crops per image for testing. So the performance will not be as good as the original paper.

For training from scratch on CIFAR-10

  • All the LRN layers are removed from the convolutional layers.
  • Batch normalization and ReLU activation are used in all the convolutional layers including the layers in Inception structure except the output layer.
  • Two auxiliary classifiers are used as mentioned in the paper, though 512 instead of 1024 hidden units are used in the two fully connected layers to reduce the computation. However, I found the results are almost the same on CIFAR-10 with and without auxiliary classifiers.
  • Since the 32 x 32 images are down-sampled to 1 x 1 before fed into inception_5a, this makes the multi-scale structure of inception layers less useful and harm the performance (around 80% accuracy). To make full use of the multi-scale structures, the stride of the first convolutional layer is reduced to 1 and the first two max pooling layers are removed. The the feature map (32 x 32 x channels) will have almost the same size as described in table 1 (28 x 28 x channel) in the paper before fed into inception_3a. I have also tried only reduce the stride or only remove one max pooling layer. But I found the current setting provides the best performance on the testing set.
  • During training, dropout with keep probability 0.4 is applied to two fully connected layers and weight decay with 5e-4 is used as well.
  • The network is trained through Adam optimizer. Batch size is 128. The initial learning rate is 1e-3, decays to 1e-4 after 30 epochs, and finally decays to 1e-5 after 50 epochs.
  • Each color channel of the input images are subtracted by the mean value computed from the training set.

Usage

ImageNet Classification

Preparation

  • Download the pre-trained parameters here. This is original from here.
  • Setup path in examples/inception_pretrained.py: PRETRINED_PATH is the path for pre-trained model. DATA_PATH is the path to put testing images.

Run

Go to examples/ and put test image in folder DATA_PATH, then run the script:

python inception_pretrained.py --im_name PART_OF_IMAGE_NAME
  • --im_name is the option for image names you want to test. If the testing images are all png files, this can be png. The default setting is .jpg.
  • The output will be the top-5 class labels and probabilities.

Train the network on CIFAR-10

Preparation

  • Download CIFAR-10 dataset from here
  • Setup path in examples/inception_cifar.py: DATA_PATH is the path to put CIFAR-10. SAVE_PATH is the path to save or load summary file and trained model.

Train the model

Go to examples/ and run the script:

python inception_cifar.py --train \
  --lr LEARNING_RATE \
  --bsize BATCH_SIZE \
  --keep_prob KEEP_PROB_OF_DROPOUT \
  --maxepoch MAX_TRAINING_EPOCH
  • Summary and model will be saved in SAVE_PATH. One pre-trained model on CIFAR-10 can be downloaded from here.

Evaluate the model

Go to examples/ and put the pre-trained model in SAVE_PATH. Then run the script:

python inception_cifar.py --eval \
  --load PRE_TRAINED_MODEL_ID
  • The pre-trained ID is epoch ID shown in the save modeled file name. The default value is 99, which indicates the one I uploaded.
  • The output will be the accuracy of training and testing set.

Results

Image classification using pre-trained model

  • Top five predictions are shown. The probabilities are shown keeping two decimal places. Note that the pre-trained model are trained on ImageNet.
  • Result of VGG19 for the same images can be found here. The pre-processing of images for both experiments are the same.
Data Source Image Result
COCO 1: probability: 1.00, label: brown bear, bruin, Ursus arctos
2: probability: 0.00, label: ice bear, polar bear
3: probability: 0.00, label: hyena, hyaena
4: probability: 0.00, label: chow, chow chow
5: probability: 0.00, label: American black bear, black bear
COCO 1: probability: 0.79, label: street sign
2: probability: 0.06, label: traffic light, traffic signal, stoplight
3: probability: 0.03, label: parking meter
4: probability: 0.02, label: mailbox, letter box
5: probability: 0.01, label: balloon
COCO 1: probability: 0.94, label: trolleybus, trolley coach
2: probability: 0.05, label: passenger car, coach, carriage
3: probability: 0.00, label: fire engine, fire truck
4: probability: 0.00, label: streetcar, tram, tramcar, trolley
5: probability: 0.00, label: minibus
COCO 1: probability: 0.35, label: burrito
2: probability: 0.17, label: potpie
3: probability: 0.14, label: mashed potato
4: probability: 0.10, label: plate
5: probability: 0.03, label: pizza, pizza pie
ImageNet 1: probability: 1.00, label: goldfish, Carassius auratus
2: probability: 0.00, label: rock beauty, Holocanthus tricolor
3: probability: 0.00, label: puffer, pufferfish, blowfish, globefish
4: probability: 0.00, label: tench, Tinca tinca
5: probability: 0.00, label: anemone fish
Self Collection 1: probability: 0.32, label: Egyptian cat
2: probability: 0.30, label: tabby, tabby cat
3: probability: 0.05, label: tiger cat
4: probability: 0.02, label: mouse, computer mouse
5: probability: 0.02, label: paper towel
Self Collection 1: probability: 1.00, label: streetcar, tram, tramcar, trolley, trolley car
2: probability: 0.00, label: passenger car, coach, carriage
3: probability: 0.00, label: trolleybus, trolley coach, trackless trolley
4: probability: 0.00, label: electric locomotive
5: probability: 0.00, label: freight car

Train the network from scratch on CIFAR-10

  • Here is a similar experiment using VGG19.

learning curve for training set

train_lc

learning curve for testing set

  • The accuracy on testing set is 93.64% around 100 epochs. We can observe the slightly over-fitting behavior at the end of training.

valid_lc

Author

Qian Ge

googlenet-inception's People

Contributors

conan7882 avatar infinoid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

googlenet-inception's Issues

The npy file can not download

Thanks for you great job, it really help me.
But the net to download the pretrained GoogleNet npy file can not open. I don't know if it only happen on me. Anyway could you provide it for me?
Thanks so much.

No googlenet.py in the repository

Hi there,

I wanted to try out the googlenet pretrained model, but it seems there is no googlenet.py in the lib/models directory. Also the googlenet.py from deeplearningmodel.net seems to be different.

Greetings

Nothing here

When I run the python inception_pretrained.py,the result is Empty test kit.
How can I deal with the issue?

LRN Layer

LRN (Local Response Normalization) layers are used in the original GoogLeNet a.k.a. original Inception architecture.

Going deeper with convolutions.
Szegedy, Christian, et al. 
Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. 2015.

Not sure where these layers have been implemented in the source code.

Thanks in advance. Any help would be appreciated!

Up-sampling to 224x224?

Is it really necessary to scale the 32x32 images up to 224x224 to adapt to the original network? 10 classes classification is rather a light-weighted task. Maybe simply changing the pre-inception convolution layers to two 3x3 convolutions would still be deep enough while also keeping Inception-3a's input feature size 28x28.

Set Path

Sorry to interrupt,I have a question.
In the inception_cifar. py file, there is a four-path setting, where IM_PATH is set according to what.It would be nice to have a basis for the other three path Settings

Can not set large batch_size?

I trianed the same dataset in caffe-googlenet with the batch size of 32 ,but can only set batch size of 4. That is strange.
My device is 1080Ti and has a memory of 12GB.

image classification

I take the liberty to bother you. I want to ask you a question about image classification, but images are not images in the usual sense. The experiment is to detect different objects with the collected WiFi signals. The above figure shows the rssi and phase change curves of the WiFi signal when a bottle is placed indoors. Now I want to classify objects according to these curves. Currently, Resnet50 DenseNet201 is used but the accuracy is not high and only 80。So I would like to ask what kind of network structure is better to use deep learning to classify this kind of image?

testing use different kind image, but results are the same 'cat'

Hello, Thanks for your job very much.
I have download the code and datafile 'cifar-10', After training, I predicted the file of ‘inception-cifar-epoch-99.meta’ with some different kind images, But the predicted results are the same 'cat'.
So, could you please give me some ideas?

And another question is the connect to download the pretrained GoogleNet.npy file still can not open.

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.