amirTamer commited on
Commit
beb5958
·
1 Parent(s): ea44574
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -63,7 +63,8 @@ knn_binary_model = None
63
  # Multimode models are not inserted yet.
64
  gnb_multimode_model = load_pickle_file('gnbMulti.pkl')
65
  gnb_multimode_model = gnb_multimode_model["model"]
66
- dt_multimode_model = None
 
67
  svm_multimode_model = None
68
  logreg_multimode_model = None
69
  knn_multimode_model = None
@@ -94,8 +95,9 @@ def preprocess_image(image, model_choice, mode_choice):
94
  image_hog = image_hog.reshape(1, -1)
95
  image_pca = pca_multi.transform(image_hog)
96
  return image_pca
97
- image_hog = image_hog.reshape(1, -1)
98
- return image_hog
 
99
 
100
 
101
  def classify_binary_gnb(image):
@@ -163,9 +165,6 @@ def classify_multimode_gnb(image):
163
 
164
 
165
  def classify_multimode_dt(image):
166
- if dt_multimode_model is None:
167
- return "Decision Tree Multimode model placeholder: model is not inserted yet."
168
-
169
  processed_image = preprocess_image(image, "DT", "Multimode")
170
  prediction = dt_multimode_model.predict(processed_image)
171
  return "Decision Tree Multimode prediction: " + str(prediction[0])
 
63
  # Multimode models are not inserted yet.
64
  gnb_multimode_model = load_pickle_file('gnbMulti.pkl')
65
  gnb_multimode_model = gnb_multimode_model["model"]
66
+ dt_multimode_model = load_pickle_file('dt_Multi.pkl')
67
+ dt_multimode_model = dt_multimode_model['model']
68
  svm_multimode_model = None
69
  logreg_multimode_model = None
70
  knn_multimode_model = None
 
95
  image_hog = image_hog.reshape(1, -1)
96
  image_pca = pca_multi.transform(image_hog)
97
  return image_pca
98
+ elif model_choice == "DT":
99
+ image_hog = image_hog.reshape(1, -1)
100
+ return image_hog
101
 
102
 
103
  def classify_binary_gnb(image):
 
165
 
166
 
167
  def classify_multimode_dt(image):
 
 
 
168
  processed_image = preprocess_image(image, "DT", "Multimode")
169
  prediction = dt_multimode_model.predict(processed_image)
170
  return "Decision Tree Multimode prediction: " + str(prediction[0])