original_docstring: Use a pre-training model to extract features.
  
      Args:
  
          net: Pre-training model.
  
          img_path: The path of the image.
  
          use_gpu: Whether to use GPU or not.
  
      Returns:
  
          Extracted features.
      
docstring: Use a pre-training model to extract features.
docstring_tokens: Use a pre - training model to extract features .
code: def extractor(net, img_path, use_gpu=True):
      '''Use a pre-training model to extract features.
  
      Args:
  
          net: Pre-training model.
  
          img_path: The path of the image.
  
          use_gpu: Whether to use GPU or not.
  
      Returns:
  
          Extracted features.
      '''
      transform = transforms.Compose([
          transforms.Resize(224),
         transforms.ToTensor()]
      )
  
      img = Image.open(img_path)
      img = transform(img)
  
      x = Variable(torch.unsqueeze(img, dim=0).float(), requires_grad=False)
  
      if use_gpu == True:
          x = x.cuda()
          net = net.cuda()
  
      y = net(x).cpu()
      y = torch.squeeze(y)
      y = y.data.numpy()
      return y
code_tokens: def extractor ( net , img_path , use_gpu = True ) : transform = transforms . Compose ( [ transforms . Resize ( 224 ) , transforms . ToTensor ( ) ] ) img = Image . open ( img_path ) img = transform ( img ) x = Variable ( torch . unsqueeze ( img , dim = 0 ) . float ( ) , requires_grad = False ) if use_gpu == True : x = x . cuda ( ) net = net . cuda ( ) y = net ( x ) . cpu ( ) y = torch . squeeze ( y ) y = y . data . numpy ( ) return y
short_docstring: Use a pre-training model to extract features.
short_docstring_tokens: Use a pre - training model to extract features .
comment: '''Use a pre-training model to extract features.
  
      Args:
  
          net: Pre-training model.
  
          img_path: The path of the image.
  
          use_gpu: Whether to use GPU or not.
  
      Returns:
  
          Extracted features.
      '''