diff --git a/dlib/dnn/input.h b/dlib/dnn/input.h index 95e0a8b7d..52fcee0dd 100644 --- a/dlib/dnn/input.h +++ b/dlib/dnn/input.h @@ -567,15 +567,21 @@ namespace dlib } - matrix img; - create_tiled_pyramid(*ibegin, img, data.annotation().get>()); - nr = img.nr(); - nc = img.nc(); - data.set_size(std::distance(ibegin,iend), 3, nr, nc); + std::vector> imgs(std::distance(ibegin,iend)); + parallel_for(0, imgs.size(), [&](long i){ + std::vector rects; + if (i == 0) + create_tiled_pyramid(ibegin[i], imgs[i], data.annotation().get>()); + else + create_tiled_pyramid(ibegin[i], imgs[i], rects); + }); + nr = imgs[0].nr(); + nc = imgs[0].nc(); + data.set_size(imgs.size(), 3, nr, nc); const size_t offset = nr*nc; auto ptr = data.host(); - while(true) + for (auto&& img : imgs) { for (long r = 0; r < nr; ++r) { @@ -592,11 +598,6 @@ namespace dlib } } ptr += offset*(data.k()-1); - - ++ibegin; - if (ibegin == iend) - break; - create_tiled_pyramid(*ibegin, img, data.annotation().get>()); } }