Hi every one ,
I fine-tuned googlenet to classify images into three type of objects (Lamborghini ,cylinder head and a piece of plane )
link to the dataset . I have split the data set as the following , 4998 for training and 1002 for testing .
I set batch_size during training to 8 and to 10 during testing .
I renamed the last three fully connected layers , changed num_output to 3 and set lr_mult to 10 and 20 .
that is the config of my solver.prototxt :
net:"/home/jaba/caffe/data/diota_model/train_val.prototxt"
test_iter: 100
test_interval: 100
base_lr: 0.001
lr_policy: "step"
gamma: 0.1
stepsize: 500
display: 50
max_iter: 10000
momentum: 0.9
weight_decay: 0.0005
snapshot: 200
snapshot_prefix:"/home/jaba/caffe/data/diota_model/train_val.prototxt"
solver_mode: GPU
After training , I got 99 % as accuracy ( you can check the log file ) .
But , the problem is when I deploy the model I did not get 99 % . In fact , I tried to test my model on val_lmdb directory using this script :
import os
import glob
import cv2
import caffe
import lmdb
import numpy as np
from caffe.proto import caffe_pb2
MODEL_FILE ='deploy.prototxt'
PRETRAINED='train_val.prototxt_iter_200.caffemodel'
caffe.set_mode_cpu()
#load_model
net = caffe.Net(MODEL_FILE, PRETRAINED, caffe.TEST)
#load input and configure preprocessing
mean_file = np.array([104,117,123])
transformer = caffe.io.Transformer({'data': net.blobs['data'].data.shape})
transformer.set_mean('data', mean_file)
transformer.set_transpose('data', (2,0,1))
transformer.set_channel_swap('data', (2,1,0))
transformer.set_raw_scale('data', 255.0)
#fixing the batch size
net.blobs['data'].reshape(1,3,227,227)
lmdb_env=lmdb.open('/home/bme/jaba/test/val_lmdb')
lmdb_txn=lmdb_env.begin()
lmdb_cursor=lmdb_txn.cursor()
datum=caffe_pb2.Datum()
for key,value in lmdb_cursor:
datum.ParseFromString(value)
label=datum.label
data=caffe.io.datum_to_array(datum)
image=np.transpose(data,(1,2,0))
net.blobs['data'].data[...]=transformer.preprocess('data',image)
out=net.forward()
out_put=out['prob'].argmax()
print('{},{}'.format(key,label))
print 'prediction :::'+ str( out_put)
After executing this script on val_lmdb directory , I did not get accuracy 99 % as expect
Would you tell me why I have a result like this ? 99 % accuracy but when I test on val_lmdb not the same accuracy ?
Thanks in advance !
thanks