I am currently working on a face detection application using RCNN algorithm. The code in developed in dlib-19.2 C++. My Operating System is Windows 10 Home Edition. The framework is Qt 5.7.
My 781 images (height:228 and width:307) inside are inside a vector called "images"
std::vector<matrix<rgb_pixel>> images;
Afterwards, I split "images" into two vectors: One containing the training images (389 in total) and the testing images (391 in total):
std::vector<dlib::matrix<dlib::rgb_pixel>> training_images(images.begin(), images.begin() + half_size);
std::vector<dlib::matrix<dlib::rgb_pixel>> testing_images(images.begin() + half_size, images.end());
Then, I tried to train the RCNN network using the train() function:
template <long num_filters, typename SUBNET> using con5d = con<num_filters,5,5,2,2,SUBNET>;
template <long num_filters, typename SUBNET> using con3 = con<num_filters,3,3,1,1,SUBNET>;
template <typename SUBNET> using downsampler = relu<bn_con<con5d<32, relu<bn_con<con5d<32, relu<bn_con<con5d<32,SUBNET>>>>>>>>>;
template <typename SUBNET> using rcon3 = relu<bn_con<con3<32,SUBNET>>>;
using net_type = loss_binary_log<con<1,6,6,1,1,rcon3<rcon3<rcon3<downsampler<input_rgb_image_pyramid<pyramid_down<6>>>>>>>>;
net_type net;
dnn_trainer<net_type> trainer(net);
trainer.set_learning_rate(0.01);
trainer.set_min_learning_rate(0.00001);
trainer.set_mini_batch_size(5);
trainer.be_verbose();
trainer.train(training_images, training_labels);
However, this does not work. The following error appears every single time I run the code:
Error detected at line 179. Error detected in file ../../Desktop/dlib-19.2/dlib/dnn/loss.h. Error detected in function double dlib::loss_binary_log_::compute_loss_value_and_gradient(const dlib::tensor&, const_label_iterator, SUBNET&) const [with const_label_iterator = __gnu_cxx::__normal_iterator >; SUBNET = dlib::dimpl::subnet_wrapper, dlib::add_layer, dlib::add_layer, dlib::add_layer, dlib::add_layer, dlib::add_layer, dlib::add_layer, dlib::add_layer, dlib::add_layer, dlib::add_layer, dlib::add_layer, dlib::add_layer, dlib::add_layer, dlib::input_rgb_image_pyramid >, void>, void>, void>, void>, void>, void>, void>, void>, void>, void>, void>, void>, void>, void>, void>, void>, void>, void>, void>, true, void>].
Failing expression was output_tensor.nr() == 1 && output_tensor.nc() == 1 && output_tensor.k() == 1.
I really do not know what is going on. Could you help me please ?
Thank you very much for all your answers.
Aucun commentaire:
Enregistrer un commentaire