Hi,
I have developed a caffe classification model based on my customized training data. Then I am trying to use this model to classify a given image. I gave below commands and I got an error while I tried to classify:
Command: ./myresults/test_net.bin \
myresults/imagenet_deploy.prototxt \
myresults/caffe_imagenet_train_iter_4500.caffemodel \
data/ilsvrc12/newimagenet_mean.binaryproto \
data/ilsvrc12/my_synset_words.txt \
examples/images/cat.jpg
Error:Cannot copy param 0 weights from layer 'fc6'; shape mismatch. Source param shape is 2 50 (100); target param shape is 2 72 (144). To learn this layer's parameters from scratch rather than copying from a saved net, rename the layer.
*** Check failure stack trace: ***
@ 0x7f1e8b0a7daa (unknown)
@ 0x7f1e8b0a7ce4 (unknown)
@ 0x7f1e8b0a76e6 (unknown)
@ 0x7f1e8b0aa687 (unknown)
@ 0x7f1e8b430f67 caffe::Net<>::CopyTrainedLayersFrom()
@ 0x7f1e8b43b162 caffe::Net<>::CopyTrainedLayersFromBinaryProto()
@ 0x7f1e8b43b1c6 caffe::Net<>::CopyTrainedLayersFrom()
@ 0x406e35 Classifier::Classifier()
@ 0x403eab main
@ 0x7f1e89ac3ec5 (unknown)
@ 0x40434e (unknown)
@ (nil) (unknown)
Aborted (core dumped)
I used below processing to create my customized model (
https://github.com/BVLC/caffe/issues/550):
"
I'm not very knowledgeable as I just got started using Caffe as well, so folks should feel free to jump in and correct me. The documentation for the general procedure of training with your data is here: http://caffe.berkeleyvision.org/imagenet_training.html , and you will be able to do all your training by copying and modifying the files in CAFFE_ROOT_DIR/examples/imagenet, which we will call the imagenet directory. Using the imagenet architecture should yield decent out of the box results for categorizing images.
To summarize, the steps I followed to train Caffe were:
Group your data into a training folder and a testing folder. Caffe will train on one set of images and test it's accuracy on the other set of images. Your data should be formatted to be 256x256 color jpeg files. For each set, create a text file specifying the categories that the pictures belong to. This text file is formatted like so,
/home/my_test_dir/picture-foo.jpg 0
/home/my_test_dir/picture-foo1.jpg 1
where picture-foo belongs to category 0 and picture-foo1 belongs to category 1.
Now copy and modify create_imagenet.sh from the imagenet directory, changing the arguments to point to your folders and text files. Run create_imagenet.sh and it will generate training and testing leveldb directories. Caffe will work with these leveldb directories from now on.
Copy and modify make_imagenet_mean.sh from the imagenet directory, changing the arguments to point at your spanking new leveldb folders. This will generate mean.prototxt files that caffe uses to normalize images, improving your results. I would recommend specifying absolute paths for everything to minimize headaches.
Copy and modify imagenet_{deploy,solver,train,val}.prototxt. You'll want to change the source and mean_file parameters in imagenet_{train,val} to point to your leveldbs and your mean.prototxt files (again, absolute paths). You may also want to change the batch_size parameter based on the hardware that you'll be running caffe on. Lastly, change the solver.prototxt file to point to your newly modified train and val prototxt files! I believe you can leave deploy.prototxt alone.
Take a step back and make sure you haven't missed anything. You will have deploy, solver, train, and val prototxt files; two image mean binaryproto files; one train_leveldb folder, and one val_leveldb folder. That's two folders and six files in total.
You guessed it- copy and modify train_imagenet.sh! Point it to your solver prototxt file.
Run the modified train_imagenet script. This will periodically spit out solverstate files and data files with names like caffe_train_iter_#.
After training terminates, you can find a script in CAFFE_ROOT_DIR/build/tools called test_net.bin. test_net.bin will take your val.prototxt, a caffe_train_iter_# data file, and the number of testing iterations as arguments. It will tell you how your trained network is doing."
Any help is much appreciated. I am new to caffe and struggling a lot :(
Thanks