Train on INRIA dataset

304 views
Skip to first unread message

Вадим Дрозд

unread,
Feb 22, 2015, 7:10:07 AM2/22/15
to caffe...@googlegroups.com
 Hi there!

I want to try train some base classifier pedestrian / non pedestrian, and i have some troubles.

First of all I prepared database (get originals from http://pascal.inrialpes.fr/data/human/), croped it to 128x64 and converted to grayscale.

Second I  created a database using convert_imageset with flags: gray and shuffle.

After that modified ImageNet solver and net, just changing data layers and last layers:

layers {
  name
: "data"
  type
: DATA
  top
: "data"
  top
: "label"
  data_param
{
    source
: "/home/vadym/Work/Odesk/caffe-master/INRIA/inria_train_lmdb"
    backend
: LMDB
    batch_size
: 64
 
}
  transform_param
{
    scale
: 0.00390625
 
}
  include
: { phase: TRAIN }
}
layers
{
  name
: "data"
  type
: DATA
  top
: "data"
  top
: "label"
  data_param
{
    source
: "/home/vadym/Work/Odesk/caffe-master/INRIA/inria_test_lmdb"
    backend
: LMDB
    batch_size
: 64
 
}
  transform_param
{
    scale
: 0.00390625
 
}
  include
: { phase: TEST }
}
...

layers
{
  name
: "fc8"
  type
: INNER_PRODUCT
  bottom
: "fc7"
  top
: "fc8"
  blobs_lr
: 1
  blobs_lr
: 2
  weight_decay
: 1
  weight_decay
: 0
  inner_product_param
{
    num_output
: 2    <-  2 classes for person and non person
    weight_filler
{
      type
: "gaussian"
      std
: 0.01
   
}
    bias_filler
{
      type
: "constant"
      value
: 0
   
}
 
}
}
...


I start training net and try to test some of snapshots in the morning (net trained all night on CPU).
But i always get the same result for almost of pictures:

Class 1 is: 0.789131
Class 2 is: 0.210869



My test code is:

#define CPU_ONLY

#include <cstring>
#include <cstdlib>
#include <vector>

#include <string>
#include <iostream>
#include <stdio.h>

#include "caffe/caffe.hpp"
#include "caffe/util/io.hpp"
#include "caffe/blob.hpp"
#include <caffe/proto/caffe.pb.h>

using namespace caffe;
using namespace std;


int main(int argc, char** argv)
{

   
Caffe::set_mode(Caffe::CPU);

   
//get the net
   
Net<float> caffe_test_net("caffe-master/INRIA/train_INRIA_2_deploy.prototxt");

   
//get trained net
    caffe_test_net
.CopyTrainedLayersFrom("caffe-master/INRIA/INRIA_caffenet_train_2_iter_2300.caffemodel");

   
//get datum
   
Datum datum;
   
if (!ReadImageToDatum(argv[1], 1, 128, 64, false, &datum))
        LOG
(ERROR) << "Error during file reading";

   
//get the blob
   
Blob<float>* blob = new Blob<float>(1, datum.channels(), datum.height(), datum.width());

    vector
<float> float_data;
   
const int data_size = datum.channels() * datum.height() * datum.width();
   
string const char_data = datum.data();
   
assert(char_data.size() == data_size);

   
for (int i = 0; i < data_size; i++)
        float_data
.push_back((float(char_data[i]) + 128.0) / 256.0);

   
//set data into blob
    blob
->set_cpu_data(float_data.data());


    vector
<Blob<float>*> bottom;
    bottom
.push_back(blob);
   
float type = 0.0;

   
const vector<Blob<float>*>& result = caffe_test_net.Forward(bottom, &type);

    cout
<< "Class 1 is: " << result[0]->cpu_data()[0] << endl;
    cout
<< "Class 2 is: " << result[0]->cpu_data()[1] << endl;

   
return 0;
}

And i have some question:

1) Do I need to use
    scale
: 0.00390625 
for data_layer?
2) Maybe, due to another size of data (128x60) parameters of second and another layers should be changed?
3) Or maybe I do incorrect test?

Thank you!

Abdullah Giray YAĞLIKÇI

unread,
Feb 28, 2016, 5:33:16 PM2/28/16
to Caffe Users
Hi Вадим, 

Unfortunately I don't have an answer for your question, but I have a question for you. 

Training prototype for INRIA dataset requires the file inria_train_lmdb as well as test prototype requires inria_test_lmdb. However I couldn't find those database files in the official page of INRIA dataset. 
Could you please share, how you generated/found your files, with me?

Thanks 
Giray 
Reply all
Reply to author
Forward
0 new messages