Update app.py
Browse files
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 |
-
|
24 |
-
|
|
|
25 |
logging.debug("Converting NumPy array to PIL image...")
|
26 |
-
image = Image.fromarray(image
|
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...")
|