Giter VIP home page Giter VIP logo

traincaffecustomdataset's Introduction

Train CaffeNet model on custom dataset

How to train CaffeNet on custom dataset

This is short description of training your own custom Net based on your image dataset using pre-trained CaffeNet model.

This repo contains all required Python and shell scripts for pretraining and training stage, not optimized and could be cleaner code.

  1. Collect all your images for test and valuation process and put them in Test and Train folder, each class of images should be placed as subfolder in these two folders. Example, two classes used for your model, cars and bikes : Train/cars, Train/bikes etc.

  2. First, create your own train.txt and val.txt files using train_val.py script. The content of these txt files will be as the example:

.
+-- train.txt
|   +-- Train/bike/bike.jpg 0
|   +-- Train/car/car.jpg 1
+-- test.txt
|   +-- Test/bike/bike.jpg 0
|   +-- Test/car/car.jpg 1

The images are labeled as class numbers. If names of images contain spaces, could be removed using remove_spaces.py.

  1. The second stage is to create leveldb libraries using create_leveldb.sh, just change the required paths inside the script.

  2. After that, compute the mean using make_imagenet_mean.sh, the imagenet_mean.binaryproto file will be created.

  3. Create your proto files, examples are provided, you should have train & val proto files and solver proto file for setting training parameters (momentum, decay, snapshots, no. of iterations etc.). Change the num_output in fully-connected layer for custom number of classes, for example if you are recognizing only bikes and cars num_output = 2.

  4. The next step is to start training the Net, using finetune_imagenet.sh, gpu or cpu, the log of training will be placed in output_finetune.txt.

  5. After the training is done, caffemodel files will be generated, snapshots after every 1000th iteration.

  6. To test the net you can write simpe Python script, bunch of examples are provided, example.

There are few more Python scripts for plotting errors and accuracy out of the log file, for example progres_plot.py to plot accuracy, usage from terminal python progress_plot.py /path/to/output_finetune.txt.

Also, there is example of plotting top-1 & top-5 accuracy using error_plot.py, plots examples in the Plots directory.

Example visualizing filtered images throughout the layers, visualize_layers.py, usage of script provided with example of leaf as an input image. All layers in the Net model could be visualize using visual.py, example in Plots directory.

Further improvements and suggestions are welcome.

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.