code: def predict_image(self, img, save_preview=False, return_str=True):
      img = self.transform(img)
  
      if save_preview:
          pil_img = transforms.ToPILImage()(img)
          pil_img.save("preview.jpg")
  
      img = torch.unsqueeze(img, 0).to(self.device)
  
      # Predict and get the corresponding label identifier
      pred = self.model(img)
  
      if return_str:
          # Get string label from index
          return self.config["id2label"][
              str(torch.max(pred, 1)[1].item())
          ]
      else:
          labels = list(self.config["label2id"].keys())
          softmax = torch.nn.Softmax(dim=0)
          probabilities = torch.mul(softmax(pred[0]), 100).tolist()
          return dict(zip(labels, probabilities))
  
file_path: HugsVision/build/lib/hugsvision/inference/TorchVisionClassifierInference.py
imports: import json
  import torch
  from torchvision import transforms
  from PIL import Image
label_desc: Use image node_id 2 for calling the TorchVisionClassifierInference obj's underlying member method code with example usage: obj.predict_image(img, save_preview, return_str) and returns: self, dict