mjolnir1122 commited on
Commit
e5828a5
·
verified ·
1 Parent(s): 148a113

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
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
- """Extracts features using the same model used during training (VGG16 in this case)."""
17
- image = cv2.resize(image, (224, 224)) # Resize image to 224x224
18
- image = np.expand_dims(image, axis=0) # Add batch dimension
19
- image = preprocess_input(image) # Apply VGG16 preprocessing
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."""