You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/02/13 16:10:20 UTC

[GitHub] [incubator-tvm] vizero1 opened a new issue #4875: Image preprocessing for darknet takes too long

vizero1 opened a new issue #4875: Image preprocessing for darknet takes too long
URL: https://github.com/apache/incubator-tvm/issues/4875
 
 
   Hi,
   
   I was working on this tutorial https://docs.tvm.ai/tutorials/frontend/from_darknet.html#sphx-glr-tutorials-frontend-from-darknet-py and it seems that the preprocessing of the image takes several seconds. 
   I did a few tests and most of the time is spend on this function in tvm/relay/testing/darknet.py
   
   `def _resize_image(img, w_in, h_in):
       """Resize the image to the given height and width."""
       imc, imh, imw = img.shape
       h_in = int(h_in)
       w_in = int(w_in)
       part = np.zeros((imc, imh, w_in))
       resized = np.zeros((imc, h_in, w_in))
       w_scale = (imw - 1) / (w_in - 1)
       h_scale = (imh - 1) / (h_in - 1)
       for k in range(imc):
           for j in range(imh):
               for c in range(w_in):
                   if c == w_in - 1 or imw == 1:
                       part[k][j][c] = img[k][j][imw - 1]
                   else:
                       fdx, idx = math.modf(c * w_scale)
                       part[k][j][c] = (1 - fdx) * img[k][j][int(idx)] + \
                                               fdx * img[k][j][int(idx) + 1]
       for k in range(imc):
           for j in range(h_in):
               fdy, idy = math.modf(j * h_scale)
               for c in range(w_in):
                   resized[k][j][c] = (1 - fdy)*part[k][int(idy)][c]
               if (j == h_in - 1) or (imh == 1):
                   continue
               for c in range(w_in):
                   resized[k][j][c] += fdy * part[k][int(idy) + 1][c]
       return resized`
   
   Is there any specific reason why the script is not using the opencv.resize function and instead has an own implementation which takes much more time?
   I just rewrote the image processing part by using the opencv resize function and now it takes less than 1 second.
   I am interested if there is any idea behind this specific implementation.
   If not I would create a PR.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] vizero1 commented on issue #4875: Use opencv function for resize

Posted by GitBox <gi...@apache.org>.
vizero1 commented on issue #4875: Use opencv function for resize
URL: https://github.com/apache/incubator-tvm/issues/4875#issuecomment-589610458
 
 
   PR is here:
   https://github.com/apache/incubator-tvm/pull/4883

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] tqchen closed issue #4875: Use opencv function for resize

Posted by GitBox <gi...@apache.org>.
tqchen closed issue #4875: Use opencv function for resize
URL: https://github.com/apache/incubator-tvm/issues/4875
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] tqchen commented on issue #4875: Image preprocessing for darknet takes too long

Posted by GitBox <gi...@apache.org>.
tqchen commented on issue #4875: Image preprocessing for darknet takes too long
URL: https://github.com/apache/incubator-tvm/issues/4875#issuecomment-585876040
 
 
   A PR is more than welcomed

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services