Jangai commited on
Commit
70548b8
·
verified ·
1 Parent(s): 7d27275

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -18,12 +18,14 @@ model = ViTForImageClassification.from_pretrained(model_name)
18
  def predict(image):
19
  try:
20
  logging.info("Received image of type: %s", type(image))
 
21
  # Convert the dictionary to a PIL image
22
  if isinstance(image, dict):
23
- logging.debug("Converting dictionary to NumPy array...")
24
- image = np.array(image['image_data'])
 
25
  logging.debug("Converting NumPy array to PIL image...")
26
- image = Image.fromarray(image.astype('uint8'), 'RGB')
27
  logging.debug("Image converted successfully.")
28
 
29
  logging.info("Processing image...")
 
18
  def predict(image):
19
  try:
20
  logging.info("Received image of type: %s", type(image))
21
+ logging.debug("Image content: %s", image)
22
  # Convert the dictionary to a PIL image
23
  if isinstance(image, dict):
24
+ image = image['image']
25
+ logging.debug("Converting to NumPy array...")
26
+ image = np.array(image).astype('uint8')
27
  logging.debug("Converting NumPy array to PIL image...")
28
+ image = Image.fromarray(image, 'RGB')
29
  logging.debug("Image converted successfully.")
30
 
31
  logging.info("Processing image...")