mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
Optimizing network_predict_image to resize only if necessary.
This speeds up the processing considerably if the user is so kind to resize the image prior to doing detection.
This commit is contained in:
@ -731,10 +731,17 @@ char *detection_to_json(detection *dets, int nboxes, int classes, char **names,
|
||||
float *network_predict_image(network *net, image im)
|
||||
{
|
||||
//image imr = letterbox_image(im, net->w, net->h);
|
||||
image imr = resize_image(im, net->w, net->h);
|
||||
set_batch_network(net, 1);
|
||||
float *p = network_predict(*net, imr.data);
|
||||
free_image(imr);
|
||||
float *p;
|
||||
if (im.w == net->w && im.h == net->h) {
|
||||
// Input image is the same size as our net, predict on that image
|
||||
p = network_predict(*net, im.data);
|
||||
}
|
||||
else {
|
||||
// Need to resize image to the desired size for the net
|
||||
image imr = resize_image(im, net->w, net->h);
|
||||
p = network_predict(*net, imr.data);
|
||||
free_image(imr);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user