parameters: (self, img)
return_statement: return img, [ratio_h, ratio_w]
docstring: resize image to a size multiple of 32 which is required by the network
          args:
              img(array): array with shape [h, w, c]
          return(tuple):
              img, (ratio_h, ratio_w)
docstring_summary: resize image to a size multiple of 32 which is required by the network
          args:
              img(array): array with shape [h, w, c]
          return(tuple):
              img, (ratio_h, ratio_w)
docstring_tokens: resize image to a size multiple of 32 which is required by the network args : img ( array ) : array with shape [ h w c ] return ( tuple ) : img ( ratio_h ratio_w )
function: def resize_image_type0(self, img):
          """
          resize image to a size multiple of 32 which is required by the network
          args:
              img(array): array with shape [h, w, c]
          return(tuple):
              img, (ratio_h, ratio_w)
          """
          limit_side_len = self.limit_side_len
          h, w, c = img.shape
  
          # limit the max side
          if self.limit_type == 'max':
              if max(h, w) > limit_side_len:
                  if h > w:
                      ratio = float(limit_side_len) / h
                  else:
                      ratio = float(limit_side_len) / w
              else:
                  ratio = 1.
          elif self.limit_type == 'min':
              if min(h, w) < limit_side_len:
                  if h < w:
                      ratio = float(limit_side_len) / h
                  else:
                      ratio = float(limit_side_len) / w
              else:
                  ratio = 1.
          elif self.limit_type == 'resize_long':
              ratio = float(limit_side_len) / max(h, w)
          else:
              raise Exception('not support limit type, image ')
          resize_h = int(h * ratio)
          resize_w = int(w * ratio)
  
          resize_h = max(int(round(resize_h / 32) * 32), 32)
          resize_w = max(int(round(resize_w / 32) * 32), 32)
  
          try:
              if int(resize_w) <= 0 or int(resize_h) <= 0:
                  return None, (None, None)
              img = cv2.resize(img, (int(resize_w), int(resize_h)))
          except:
              print(img.shape, resize_w, resize_h)
              sys.exit(0)
          ratio_h = resize_h / float(h)
          ratio_w = resize_w / float(w)
          return img, [ratio_h, ratio_w]
function_tokens: def resize_image_type0 ( self , img ) : limit_side_len = self . limit_side_len h , w , c = img . shape # limit the max side if self . limit_type == 'max' : if max ( h , w ) > limit_side_len : if h > w : ratio = float ( limit_side_len ) / h else : ratio = float ( limit_side_len ) / w else : ratio = 1. elif self . limit_type == 'min' : if min ( h , w ) < limit_side_len : if h < w : ratio = float ( limit_side_len ) / h else : ratio = float ( limit_side_len ) / w else : ratio = 1. elif self . limit_type == 'resize_long' : ratio = float ( limit_side_len ) / max ( h , w ) else : raise Exception ( 'not support limit type, image ' ) resize_h = int ( h * ratio ) resize_w = int ( w * ratio ) resize_h = max ( int ( round ( resize_h / 32 ) * 32 ) , 32 ) resize_w = max ( int ( round ( resize_w / 32 ) * 32 ) , 32 ) try : if int ( resize_w ) <= 0 or int ( resize_h ) <= 0 : return None , ( None , None ) img = cv2 . resize ( img , ( int ( resize_w ) , int ( resize_h ) ) ) except : print ( img . shape , resize_w , resize_h ) sys . exit ( 0 ) ratio_h = resize_h / float ( h ) ratio_w = resize_w / float ( w ) return img , [ ratio_h , ratio_w ]