rocioadlc commited on
Commit
5701965
1 Parent(s): 010ec49

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -20
app.py CHANGED
@@ -49,18 +49,7 @@ from PIL import Image
49
  model1 = from_pretrained_keras("rocioadlc/modelo")
50
 
51
  # Define class labels
52
- class_labels = ['battery',
53
- 'biological',
54
- 'brown-glass',
55
- 'cardboard',
56
- 'clothes',
57
- 'green-glass',
58
- 'metal',
59
- 'paper',
60
- 'plastic',
61
- 'shoes',
62
- 'trash',
63
- 'white-glass']
64
 
65
  # Function to predict image label and score
66
  def predict_image(input):
@@ -75,15 +64,12 @@ def predict_image(input):
75
  # Predict using the model
76
  predictions = model1.predict(image_array)
77
 
78
- # Get the predicted class label
79
- predicted_class_index = tf.argmax(predictions, axis=1).numpy()[0]
80
- predicted_class_label = class_labels[predicted_class_index]
81
 
82
- # Get the confidence score of the predicted class
83
- confidence_score = predictions[0][predicted_class_index]
84
-
85
- # Return predicted class label and confidence score
86
- return {predicted_class_label: confidence_score}
87
 
88
 
89
  loader = WebBaseLoader(["https://www.epa.gov/recycle/frequent-questions-recycling", "https://www.whitehorsedc.gov.uk/vale-of-white-horse-district-council/recycling-rubbish-and-waste/lets-get-real-about-recycling/", "https://www.teimas.com/blog/13-preguntas-y-respuestas-sobre-la-ley-de-residuos-07-2022", "https://www.molok.com/es/blog/gestion-de-residuos-solidos-urbanos-rsu-10-dudas-comunes"])
 
49
  model1 = from_pretrained_keras("rocioadlc/modelo")
50
 
51
  # Define class labels
52
+ class_labels = ['cardboard', 'glass', 'metal', 'paper', 'plastic', 'trash']
 
 
 
 
 
 
 
 
 
 
 
53
 
54
  # Function to predict image label and score
55
  def predict_image(input):
 
64
  # Predict using the model
65
  predictions = model1.predict(image_array)
66
 
67
+ category_scores = {}
68
+ for i, class_label in enumerate(class_labels):
69
+ category_scores[class_label] = predictions[0][i].item()
70
 
71
+ return category_scores
72
+
 
 
 
73
 
74
 
75
  loader = WebBaseLoader(["https://www.epa.gov/recycle/frequent-questions-recycling", "https://www.whitehorsedc.gov.uk/vale-of-white-horse-district-council/recycling-rubbish-and-waste/lets-get-real-about-recycling/", "https://www.teimas.com/blog/13-preguntas-y-respuestas-sobre-la-ley-de-residuos-07-2022", "https://www.molok.com/es/blog/gestion-de-residuos-solidos-urbanos-rsu-10-dudas-comunes"])