mirror of
https://gitcode.com/gh_mirrors/ope/OpenFace.git
synced 2026-05-15 19:57:53 +00:00
Simplified validator model.
This commit is contained in:
@@ -887,78 +887,42 @@ double DetectionValidator::CheckCNN_tbb(const cv::Mat_<double>& warped_img, int
|
||||
outputs[0] = outputs[0] + output;
|
||||
}
|
||||
|
||||
if(cnn_convolutional_layers[view_id][cnn_layer][0].size() > 20)
|
||||
|
||||
// TBB pass for the remaining kernels, empirically helps with layers with more kernels
|
||||
tbb::parallel_for(1, (int)cnn_convolutional_layers[view_id][cnn_layer][in].size(), [&](int k) {
|
||||
{
|
||||
// TBB pass for the remaining kernels, empirically helps with layers with more kernels
|
||||
tbb::parallel_for(1, (int)cnn_convolutional_layers[view_id][cnn_layer][in].size(), [&](int k) {
|
||||
cv::Mat_<float> kernel = cnn_convolutional_layers[view_id][cnn_layer][in][k];
|
||||
|
||||
// The convolution (with precomputation)
|
||||
cv::Mat_<float> output;
|
||||
if (cnn_convolutional_layers_dft[view_id][cnn_layer][in][k].second.empty()) // This will only be needed during the first pass
|
||||
{
|
||||
cv::Mat_<float> kernel = cnn_convolutional_layers[view_id][cnn_layer][in][k];
|
||||
std::map<int, cv::Mat_<double> > precomputed_dft;
|
||||
|
||||
// The convolution (with precomputation)
|
||||
cv::Mat_<float> output;
|
||||
if (cnn_convolutional_layers_dft[view_id][cnn_layer][in][k].second.empty()) // This will only be needed during the first pass
|
||||
{
|
||||
std::map<int, cv::Mat_<double> > precomputed_dft;
|
||||
LandmarkDetector::matchTemplate_m(input_image, input_image_dft, integral_image, integral_image_sq, kernel, precomputed_dft, output, CV_TM_CCORR);
|
||||
|
||||
LandmarkDetector::matchTemplate_m(input_image, input_image_dft, integral_image, integral_image_sq, kernel, precomputed_dft, output, CV_TM_CCORR);
|
||||
|
||||
cnn_convolutional_layers_dft[view_id][cnn_layer][in][k].first = precomputed_dft.begin()->first;
|
||||
cnn_convolutional_layers_dft[view_id][cnn_layer][in][k].second = precomputed_dft.begin()->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::map<int, cv::Mat_<double> > precomputed_dft;
|
||||
precomputed_dft[cnn_convolutional_layers_dft[view_id][cnn_layer][in][k].first] = cnn_convolutional_layers_dft[view_id][cnn_layer][in][k].second;
|
||||
LandmarkDetector::matchTemplate_m(input_image, input_image_dft, integral_image, integral_image_sq, kernel, precomputed_dft, output, CV_TM_CCORR);
|
||||
}
|
||||
|
||||
// Combining the maps
|
||||
if (in == 0)
|
||||
{
|
||||
outputs[k] = output;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputs[k] = outputs[k] + output;
|
||||
}
|
||||
cnn_convolutional_layers_dft[view_id][cnn_layer][in][k].first = precomputed_dft.begin()->first;
|
||||
cnn_convolutional_layers_dft[view_id][cnn_layer][in][k].second = precomputed_dft.begin()->second;
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t k = 1; k < cnn_convolutional_layers[view_id][cnn_layer][in].size(); ++k)
|
||||
else
|
||||
{
|
||||
cv::Mat_<float> kernel = cnn_convolutional_layers[view_id][cnn_layer][in][k];
|
||||
std::map<int, cv::Mat_<double> > precomputed_dft;
|
||||
precomputed_dft[cnn_convolutional_layers_dft[view_id][cnn_layer][in][k].first] = cnn_convolutional_layers_dft[view_id][cnn_layer][in][k].second;
|
||||
LandmarkDetector::matchTemplate_m(input_image, input_image_dft, integral_image, integral_image_sq, kernel, precomputed_dft, output, CV_TM_CCORR);
|
||||
}
|
||||
|
||||
// The convolution (with precomputation)
|
||||
cv::Mat_<float> output;
|
||||
if (cnn_convolutional_layers_dft[view_id][cnn_layer][in][k].second.empty()) // This will only be needed during the first pass
|
||||
{
|
||||
std::map<int, cv::Mat_<double> > precomputed_dft;
|
||||
|
||||
LandmarkDetector::matchTemplate_m(input_image, input_image_dft, integral_image, integral_image_sq, kernel, precomputed_dft, output, CV_TM_CCORR);
|
||||
|
||||
cnn_convolutional_layers_dft[view_id][cnn_layer][in][k].first = precomputed_dft.begin()->first;
|
||||
cnn_convolutional_layers_dft[view_id][cnn_layer][in][k].second = precomputed_dft.begin()->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::map<int, cv::Mat_<double> > precomputed_dft;
|
||||
precomputed_dft[cnn_convolutional_layers_dft[view_id][cnn_layer][in][k].first] = cnn_convolutional_layers_dft[view_id][cnn_layer][in][k].second;
|
||||
LandmarkDetector::matchTemplate_m(input_image, input_image_dft, integral_image, integral_image_sq, kernel, precomputed_dft, output, CV_TM_CCORR);
|
||||
}
|
||||
|
||||
// Combining the maps
|
||||
if (in == 0)
|
||||
{
|
||||
outputs[k] = output;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputs[k] = outputs[k] + output;
|
||||
}
|
||||
// Combining the maps
|
||||
if (in == 0)
|
||||
{
|
||||
outputs[k] = output;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputs[k] = outputs[k] + output;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
for (size_t k = 0; k < cnn_convolutional_layers[view_id][cnn_layer][0].size(); ++k)
|
||||
|
||||
Reference in New Issue
Block a user