OmarEllethy commited on
Commit
ada111e
1 Parent(s): bf8fdc4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -23,21 +23,18 @@ def predict_image(image):
23
  image = tf.keras.preprocessing.image.img_to_array(image)
24
  image = np.expand_dims(image, axis=0)
25
 
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
- predicted_probability = probabilities[0][0] * 100 # Convert to percentage
35
- else:
36
- predicted_label = "Carries"
37
- predicted_probability = probabilities[0][1] * 100 # Convert to percentage
38
 
39
- # Return the prediction result as a dictionary
40
- return {"Predicted Label": predicted_label, "Evaluate the teeth": f"{predicted_probability:.2f}%"}
 
 
 
 
41
 
42
 
43
  # Create the interface
@@ -48,7 +45,7 @@ iface = gr.Interface(
48
  fn=predict_image,
49
  inputs=input_interface,
50
  outputs=output_interface,
51
- title="<h1 style='color: lightgreen; text-align: center;'>Dentella</h1><p style='text-align: center; color: skyblue; font-size: 30px;'>Please Enter Your Teeth Here...</p>",)
52
 
53
 
54
  # Launch the interface
 
23
  image = tf.keras.preprocessing.image.img_to_array(image)
24
  image = np.expand_dims(image, axis=0)
25
 
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
 
32
+ # Define the prediction result
33
+ result = {
34
+ "prediction": "Your Teeth are Good & You Don't Need To Visit Doctor" if probability_good > 0.5 else "Your Teeth are Bad & You Need To Visit Doctor"
35
+ }
36
+
37
+ return result
38
 
39
 
40
  # Create the interface
 
45
  fn=predict_image,
46
  inputs=input_interface,
47
  outputs=output_interface,
48
+ title="<h1 style='color: lightgreen; text-align: center;'>Dentella</h1><p style='text-align: left; color: skyblue; font-size: 25px;'>Please Enter Your Teeth Here...</p>",)
49
 
50
 
51
  # Launch the interface