This is my train.prototxt. And this is my deploy.prototxt.
When I want to load my deploy file I get this error:
File "./python/caffe/classifier.py", line 29, in __init__ in_ = self.inputs[0] IndexError: list index out of range
So, I removed the data layer:
F1117 23:16:09.485153 21910 insert_splits.cpp:35] Unknown bottom blob 'data' (layer 'conv1', bottom index 0) *** Check failure stack trace: ***
Than, I removed bottom: "data"
from conv1 layer.
After it, I got this error:
F1117 23:17:15.363919 21935 insert_splits.cpp:35] Unknown bottom blob 'label' (layer 'loss', bottom index 1) *** Check failure stack trace: ***
I removed bottom: "label"
from loss layer. And I got this error:
I1117 23:19:11.171021 21962 layer_factory.hpp:76] Creating layer conv1 I1117 23:19:11.171036 21962 net.cpp:110] Creating Layer conv1 I1117 23:19:11.171041 21962 net.cpp:433] conv1 -> conv1 F1117 23:19:11.171061 21962 layer.hpp:379] Check failed: MinBottomBlobs() <= bottom.size() (1 vs. 0) Convolution Layer takes at least 1 bottom blob(s) as input. *** Check failure stack trace: ***
What should I do to fix it and create my deploy file?
There are two main differences between a "train" prototxt and a "deploy" one:
1. Inputs: While for training data is fixed to a pre-processed training dataset (lmdb/HDF5 etc.), deploying the net require it to process other inputs in a more "random" fashion.
Therefore, the first change is to remove the input layers (layers that push "data" and "labels" during TRAIN and TEST phases). To replace the input layers you need to add the following declaration:
input: "data"
input_shape: { dim:1 dim:3 dim:224 dim:224 }
This declaration does not provide the actual data for the net, but it tells the net what shape to expect, allowing caffe to pre-allocate necessary resources.
2. Loss: the top most layers in a training prototxt define the loss function for the training. This usually involve the ground truth labels. When deploying the net, you no longer have access to these labels. Thus loss layers should be converted to "prediction" outputs. For example, a "SoftmaxWithLoss" layer should be converted to a simple "Softmax" layer that outputs class probability instead of log-likelihood loss. Some other loss layers already have predictions as inputs, thus it is sufficient just to remove them.
Update: see this tutorial for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With