Ich versuche, eine bereits trainierte caffemodel.h5-Datei auf CIFAR10-Daten bereitzustellen.Fehler beim Klassifizieren von CIFAR10-Daten in C++ mit einem Caffemodell
Hier ist die Netzwerk-Prototxt-Datei.
name: "CIFAR10_quick_test"
input: "data"
input_dim: 10
input_dim: 3
input_dim: 32
input_dim: 32
layer {
name: "conv1"
type: "Convolution"
bottom: "data"
top: "conv1"
param {
lr_mult: 1
}
param {
lr_mult: 2
}
convolution_param {
num_output: 32
pad: 2
kernel_size: 5
stride: 1
}
}
layer {
name: "pool1"
type: "Pooling"
bottom: "conv1"
top: "pool1"
pooling_param {
pool: MAX
kernel_size: 3
stride: 2
}
}
layer {
name: "relu1"
type: "ReLU"
bottom: "pool1"
top: "pool1"
}
layer {
name: "conv2"
type: "Convolution"
bottom: "pool1"
top: "conv2"
param {
lr_mult: 1
}
param {
lr_mult: 2
}
convolution_param {
num_output: 32
pad: 2
kernel_size: 5
stride: 1
}
}
layer {
name: "relu2"
type: "ReLU"
bottom: "conv2"
top: "conv2"
}
layer {
name: "pool2"
type: "Pooling"
bottom: "conv2"
top: "pool2"
pooling_param {
pool: AVE
kernel_size: 3
stride: 2
}
}
layer {
name: "conv3"
type: "Convolution"
bottom: "pool2"
top: "conv3"
param {
lr_mult: 1
}
param {
lr_mult: 2
}
convolution_param {
num_output: 64
pad: 2
kernel_size: 5
stride: 1
}
}
layer {
name: "relu3"
type: "ReLU"
bottom: "conv3"
top: "conv3"
}
layer {
name: "pool3"
type: "Pooling"
bottom: "conv3"
top: "pool3"
pooling_param {
pool: AVE
kernel_size: 3
stride: 2
}
}
layer {
name: "ip1"
type: "InnerProduct"
bottom: "pool3"
top: "ip1"
param {
lr_mult: 1
}
param {
lr_mult: 2
}
inner_product_param {
num_output: 64
}
}
layer {
name: "ip2"
type: "InnerProduct"
bottom: "ip1"
top: "ip2"
param {
lr_mult: 1
}
param {
lr_mult: 2
}
inner_product_param {
num_output: 10
}
}
layer {
name: "prob"
type: "Softmax"
bottom: "ip2"
top: "prob"
}
Und hier ist der C++ Code mit OpenCV des DNN-Modul, in dem ich die caffemodel.h5 zu verwenden Ich versuche, ein Flugzeug zu klassifizieren.
Diese Methode funktionierte gut für das Training von LeNet auf der MNIST-Ziffernklassifikation. Ich erhalte jedoch einen Fehler beim Ausführen der Ausgabe hier.
OpenCV Error: Assertion failed (!bias || blobs.size() == 2) in ConvolutionLayer, file /home/Downloads/opencv-3.1.0/opencv_contrib/modules/dnn/src/layers/convolution_layer.cpp, line 62
terminate called after throwing an instance of 'cv::Exception'
what(): /home/Downloads/opencv-3.1.0/opencv_contrib/modules/dnn/src/layers/convolution_layer.cpp:62: error: (-215) !bias || blobs.size() == 2 in function ConvolutionLayer
Aborted
Benötigen Sie Hilfe bei der Ermittlung des Problems hier. statt .caffemodel.h5
Im solver.prototxt
Änderung snapshot_format: HDF5
-snapshot_format: BINARYPROTO
Haben Sie das Modell als 'binaryproto' anstelle von' hdf5' gespeichert? (das ist die Erweiterung '.caffemodel' nur und nicht' .caffemodel.h5')? Ich habe ähnliche Probleme mit hdf5 gespeicherten Modellen erlebt. – Shai
Nein, da das Modell als .caffemodel.h5 gespeichert wurde. Ich trainierte mit dieser [link] (http://caffe.berkeleyvision.org/gerathered/examples/cifar10.html) Gibt es einen Umweg beim Speichern des Modells als .caffemodel und nicht .caffemodel.h5? – vikiboy
In dem von Ihnen verwendeten 'solver.prototxt' ändern Sie [' snapshot_format: HDF5'] (https://github.com/BVLC/caffe/blob/master/examples/cifar10/cifar10_full_solver.prototxt#L24) zu [' snapshot_format: BINARYPROTO'] (https://github.com/BVLC/caffe/blob/master/src/caffe/proto/caffe.proto#L194) – Shai