Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,12 +13,10 @@ class_labels = joblib.load("class_labels.pkl")
|
|
| 13 |
feature_extractor = VGG16(weights="imagenet", include_top=False, input_shape=(224, 224, 3))
|
| 14 |
|
| 15 |
def extract_features(image):
|
| 16 |
-
"""
|
| 17 |
-
image = cv2.resize(image, (
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
features = feature_extractor.predict(image)
|
| 21 |
-
return features.flatten().reshape(1, -1) # Reshape to match model input
|
| 22 |
|
| 23 |
def predict_animal(image):
|
| 24 |
"""Preprocess the image and make a prediction."""
|
|
|
|
| 13 |
feature_extractor = VGG16(weights="imagenet", include_top=False, input_shape=(224, 224, 3))
|
| 14 |
|
| 15 |
def extract_features(image):
|
| 16 |
+
"""Manually reshape the image into the expected feature vector size."""
|
| 17 |
+
image = cv2.resize(image, (64, 32)) # Resize to the shape used in training
|
| 18 |
+
features = image.flatten().reshape(1, -1) # Flatten to match model input size
|
| 19 |
+
return features
|
|
|
|
|
|
|
| 20 |
|
| 21 |
def predict_animal(image):
|
| 22 |
"""Preprocess the image and make a prediction."""
|