sharktide commited on
Commit
edecd42
·
1 Parent(s): 450e7c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -4
app.py CHANGED
@@ -12,7 +12,6 @@ from fastapi.middleware.cors import CORSMiddleware
12
 
13
  # Load your trained model
14
  model = tf.keras.models.load_model('recyclebot.keras')
15
- model2 = tf.keras.models.load_model('72-75.keras')
16
 
17
  # Define class names for predictions (this should be the same as in your local code)
18
  CLASSES = ['Glass', 'Metal', 'Paperboard', 'Plastic-Polystyrene', 'Plastic-Regular']
@@ -57,14 +56,12 @@ async def predict(file: UploadFile = File(...)): #async def predict(request: R
57
  try:
58
  img_array = preprocess_image(file.file) # Preprocess the image
59
  prediction1 = model.predict(img_array) # Get predictions
60
- prediction1 = model2.predict(img_array) # Get predictions
61
 
62
  weight_1 = 0.6
63
  weight_2 = 0.4
64
 
65
- final_preds = final_preds = (weight_1 * prediction1 + weight_2 * prediction2)
66
  # Get the index of the highest probability class (like np.argmax on local machine)
67
- predicted_class_idx = np.argmax(final_preds, axis=1)[0] # Get predicted class index
68
 
69
  # Map the predicted index to the class name (like final_class = CLASSES[np.argmax(final_preds)])
70
  predicted_class = CLASSES[predicted_class_idx] # Convert to class name
 
12
 
13
  # Load your trained model
14
  model = tf.keras.models.load_model('recyclebot.keras')
 
15
 
16
  # Define class names for predictions (this should be the same as in your local code)
17
  CLASSES = ['Glass', 'Metal', 'Paperboard', 'Plastic-Polystyrene', 'Plastic-Regular']
 
56
  try:
57
  img_array = preprocess_image(file.file) # Preprocess the image
58
  prediction1 = model.predict(img_array) # Get predictions
 
59
 
60
  weight_1 = 0.6
61
  weight_2 = 0.4
62
 
 
63
  # Get the index of the highest probability class (like np.argmax on local machine)
64
+ predicted_class_idx = np.argmax(prediction1, axis=1)[0] # Get predicted class index
65
 
66
  # Map the predicted index to the class name (like final_class = CLASSES[np.argmax(final_preds)])
67
  predicted_class = CLASSES[predicted_class_idx] # Convert to class name