parameters: (self, im)
return_statement: return pred
docstring: 预测
docstring_summary: 预测
docstring_tokens: 预测
function: def predict_rbg(self, im):
          """
          预测
          """
          scale = im.size[1] * 1.0 / self.size_h
          w = im.size[0] / scale
          w = int(w)
          img = im.resize((w, self.size_h), Image.BILINEAR)
  
          if w < self.size_w:
              imgnew = Image.new('RGB', (self.size_w, self.size_h), (255))
              imgnew.paste(img, (0, 0, w, self.size_h))
          else :
              imgnew = img.crop((0, 0, self.size_w,   self.size_h))
  
          img = np.array(imgnew, dtype=np.float32)
  
          img -= 127.5
          img /= 127.5
          image = img.transpose(2, 0, 1)
          transformed_image = np.expand_dims(image, axis=0)
  
  
          preds = self.sess.run(["out"], {"input": transformed_image.astype(np.float32)})
  
          pred = np.argmax(preds[0])
  
          return pred
function_tokens: def predict_rbg ( self , im ) : scale = im . size [ 1 ] * 1.0 / self . size_h w = im . size [ 0 ] / scale w = int ( w ) img = im . resize ( ( w , self . size_h ) , Image . BILINEAR ) if w < self . size_w : imgnew = Image . new ( 'RGB' , ( self . size_w , self . size_h ) , ( 255 ) ) imgnew . paste ( img , ( 0 , 0 , w , self . size_h ) ) else : imgnew = img . crop ( ( 0 , 0 , self . size_w , self . size_h ) ) img = np . array ( imgnew , dtype = np . float32 ) img -= 127.5 img /= 127.5 image = img . transpose ( 2 , 0 , 1 ) transformed_image = np . expand_dims ( image , axis = 0 ) preds = self . sess . run ( [ "out" ] , { "input" : transformed_image . astype ( np . float32 ) } ) pred = np . argmax ( preds [ 0 ] ) return pred