From e3904aebfd41f61843bfe339bd06c616f796ffe8 Mon Sep 17 00:00:00 2001 From: Brandon Haynes Date: Mon, 13 Aug 2018 09:49:18 -0700 Subject: [PATCH] Don't resize when image is already scaled to network size --- src/network.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/network.c b/src/network.c index aaab7997..6d24ec11 100644 --- a/src/network.c +++ b/src/network.c @@ -578,10 +578,12 @@ void free_detections(detection *dets, int n) float *network_predict_image(network *net, image im) { - image imr = letterbox_image(im, net->w, net->h); + bool resize = im.w != net->w || im.h != net->h; + image imr = resize ? letterbox_image(im, net->w, net->h) : im; set_batch_network(net, 1); float *p = network_predict(net, imr.data); - free_image(imr); + if(resize) + free_image(imr); return p; }