ezAhmed commited on
Commit
d71a6b0
·
verified ·
1 Parent(s): 8805312

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -86,6 +86,14 @@ def preprocess_image(image):
86
  """
87
  Preprocess image for model prediction.
88
  """
 
 
 
 
 
 
 
 
89
  # Convert to RGB if necessary
90
  if image.mode != 'RGB':
91
  image = image.convert('RGB')
 
86
  """
87
  Preprocess image for model prediction.
88
  """
89
+ # Handle different input types
90
+ if isinstance(image, str):
91
+ # If it's a file path or URL, load it
92
+ image = Image.open(image)
93
+ elif not isinstance(image, Image.Image):
94
+ # If it's a numpy array, convert to PIL
95
+ image = Image.fromarray(image)
96
+
97
  # Convert to RGB if necessary
98
  if image.mode != 'RGB':
99
  image = image.convert('RGB')