Legola commited on
Commit
a6f7fc9
·
1 Parent(s): b1dd78e

Update model.py

Browse files
Files changed (1) hide show
  1. model.py +5 -0
model.py CHANGED
@@ -65,6 +65,9 @@ cnn_normalization_std = torch.tensor([0.229, 0.224, 0.225])
65
  # return image
66
 
67
  def image_transform(image):
 
 
 
68
  if isinstance(image, str):
69
  # If image is a path to a file, open it using PIL
70
  with open(image, "rb") as f:
@@ -72,12 +75,14 @@ def image_transform(image):
72
  else:
73
  # If image is already a PIL image, just convert it to RGB mode
74
  image = image.convert('RGB')
 
75
  # Apply the same transformations as before
76
  image = transform(image).unsqueeze(0)
77
  return image
78
 
79
 
80
 
 
81
  #Defining a model
82
  cnn = models.vgg19(pretrained=True).features.eval()
83
 
 
65
  # return image
66
 
67
  def image_transform(image):
68
+ if image is None:
69
+ return None
70
+
71
  if isinstance(image, str):
72
  # If image is a path to a file, open it using PIL
73
  with open(image, "rb") as f:
 
75
  else:
76
  # If image is already a PIL image, just convert it to RGB mode
77
  image = image.convert('RGB')
78
+
79
  # Apply the same transformations as before
80
  image = transform(image).unsqueeze(0)
81
  return image
82
 
83
 
84
 
85
+
86
  #Defining a model
87
  cnn = models.vgg19(pretrained=True).features.eval()
88