sunil18p31a0101 commited on
Commit
4c7b492
·
verified ·
1 Parent(s): 9ef0568

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -23,12 +23,16 @@ def predict(image):
23
  preprocessed = preprocess_image(image)
24
  # Make predictions
25
  predictions = model.predict(preprocessed)
26
- # Get the predicted class index (with the highest probability)
27
- predicted_class = np.argmax(predictions, axis=-1)[0]
28
  # Define the class labels (you can update these with your actual class names)
29
  class_labels = ['Class 1', 'Class 2', 'Class 3', 'Class 4', 'Class 5']
30
- # Return the predicted class with the highest probability
31
- return class_labels[predicted_class], predictions[0][predicted_class]
 
 
 
 
 
32
 
33
  # Gradio interface
34
  interface = gr.Interface(
 
23
  preprocessed = preprocess_image(image)
24
  # Make predictions
25
  predictions = model.predict(preprocessed)
26
+
 
27
  # Define the class labels (you can update these with your actual class names)
28
  class_labels = ['Class 1', 'Class 2', 'Class 3', 'Class 4', 'Class 5']
29
+
30
+ # Create a dictionary with class labels as keys and probabilities as values
31
+ prediction_dict = {class_labels[i]: float(predictions[0][i]) for i in range(len(class_labels))}
32
+
33
+ # Get the predicted class with the highest probability
34
+ predicted_class = class_labels[np.argmax(predictions, axis=-1)[0]]
35
+ return predicted_class, prediction_dict
36
 
37
  # Gradio interface
38
  interface = gr.Interface(