Ahmed235 commited on
Commit
b26294d
1 Parent(s): 289c895

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -20
app.py CHANGED
@@ -26,29 +26,22 @@ def predict_image(image):
26
  # Make a prediction
27
  prediction = model.predict(image)
28
 
29
- # Get the probability of being 'Good'
30
- probability_good = prediction[0][0] # Assuming it's a binary classification
31
- probability_good = str(probability_good)
32
- # Define the prediction result
33
- result = {
34
- "prediction": probability_good
35
- }
36
-
37
- return result
38
- #predictions = tf.nn.softmax(outputs.logits, axis=-1)
39
- #predicted_class = np.argmax(predictions)
40
- #if predicted_class == 0:
41
- #predict_label = "Clean"
42
- #else:
43
- #predict_label = "Carries"
44
- #confidence = float(np.max(predictions))
45
- #prediction_dict = {"prediction": predict_label, "confidence": confidence}
46
- #return prediction_dict
47
-
48
 
49
 
50
  # Create the interface
51
- input_interface = gr.Image(type = "pil")
52
  output_interface = "json"
53
 
54
  iface = gr.Interface(
 
26
  # Make a prediction
27
  prediction = model.predict(image)
28
 
29
+ # Get the probability of being 'Clean' or 'Carries'
30
+ probabilities = tf.nn.softmax(prediction, axis=-1)
31
+ predicted_class_index = np.argmax(probabilities)
32
+ if predicted_class_index == 0:
33
+ predicted_label = "Clean"
34
+ else:
35
+ predicted_label = "Carries"
36
+ confidence = float(np.max(probabilities))
37
+ confidence = str(confidence)
38
+ # Print the predicted label and evaluation
39
+ # Return the prediction result as a dictionary
40
+ return {"Predicted Label:", predicted_label, f"Evaluate the topic according to {predicted_label} is: {confidence}"}
 
 
 
 
 
 
 
41
 
42
 
43
  # Create the interface
44
+ input_interface = gr.Image(type="pil")
45
  output_interface = "json"
46
 
47
  iface = gr.Interface(