MuhammadKhuram commited on
Commit
19c83b9
·
verified ·
1 Parent(s): eee3a97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -4,10 +4,13 @@ import numpy as np
4
  from PIL import Image
5
  from tensorflow.keras.preprocessing.image import load_img, img_to_array
6
  from tensorflow.keras.applications.resnet50 import ResNet50, preprocess_input
 
 
 
7
 
8
  # Load the trained KNN model and class names
9
- knn = joblib.load('knn_model.pkl') # Replace with the correct path
10
- class_names = joblib.load('class_names.pkl') # Replace with the correct path
11
 
12
  # Function to extract features using ResNet50
13
  def extract_features(img):
 
4
  from PIL import Image
5
  from tensorflow.keras.preprocessing.image import load_img, img_to_array
6
  from tensorflow.keras.applications.resnet50 import ResNet50, preprocess_input
7
+ import os
8
+
9
+ BASE_DIR = os.path.dirname(__file__)
10
 
11
  # Load the trained KNN model and class names
12
+ knn = joblib.load(os.path.join(BASE_DIR, 'knn_model.pkl'))
13
+ class_names = joblib.load(os.path.join(BASE_DIR, 'class_names.pkl'))
14
 
15
  # Function to extract features using ResNet50
16
  def extract_features(img):