Update app.py
Browse files
app.py
CHANGED
|
@@ -29,10 +29,13 @@ model_path = hf_hub_download(repo_id="Daniel00611/InceptionV3_72", filename="Inc
|
|
| 29 |
model = load_model(model_path)
|
| 30 |
|
| 31 |
def preprocess_image(img, target_size=(299, 299)):
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
| 36 |
return img_array
|
| 37 |
|
| 38 |
# Modelo para recibir la imagen en formato Base64
|
|
|
|
| 29 |
model = load_model(model_path)
|
| 30 |
|
| 31 |
def preprocess_image(img, target_size=(299, 299)):
|
| 32 |
+
# Convertir a RGB si la imagen no est谩 en ese formato
|
| 33 |
+
if img.mode != "RGB":
|
| 34 |
+
img = img.convert("RGB")
|
| 35 |
+
img = img.resize(target_size)
|
| 36 |
+
img_array = img_to_array(img)
|
| 37 |
+
img_array = np.expand_dims(img_array, axis=0)
|
| 38 |
+
img_array = preprocess_input(img_array)
|
| 39 |
return img_array
|
| 40 |
|
| 41 |
# Modelo para recibir la imagen en formato Base64
|