title: TypeError: a bytes-like object is required, not 'JpegImageFile'
body: <p>I was trying to predict the image with the trained model.
  Libraries Imported</p>
  <pre><code>import numpy as np 
  import pandas as pd 
  import seaborn as sns
  import cv2
  import matplotlib.pyplot as plt
  from PIL import Image
  %matplotlib inline
  import os
  import random 
  
  import torch 
  import torch.nn as nn
  from torch import cuda,optim 
  from torchvision import models,datasets,transforms
  from torch.utils.data import DataLoader
  from torchvision.utils import make_grid
  </code></pre>
  <p>The Code is As Follows</p>
  <pre><code>Classes = ['Mask','NoMask']
  
  def predict(img, pil=False):
      
      if not pil:
          im = Image.fromarray(img)
          
      trans = transforms.Compose([transforms.Resize(target_size), transforms.ToTensor(),
                                 transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])])
      im = trans(im)
      im = im.unsqueeze(0)
      im = im.to(device)
      model.eval()
      output = model(im)
  #     print(output)
      pred = output &gt;= 0.5
      c = classes[pred.item()]
      return c
  
  img = Image.open('/content/drive/MyDrive/img1.jpg')
  ans = predict(img)
  print(ans)
  
  </code></pre>
  <p>May I know where i had to change my code to avoid the error i had encountered.</p>
  <p>The Traceback I Encountered is
  <a href="https://i.stack.imgur.com/nV4cK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nV4cK.png" alt="enter image description here" /></a></p>