OmarEllethy commited on
Commit
fa27cf0
1 Parent(s): 565c7cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -8
app.py CHANGED
@@ -1,3 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  import tensorflow as tf
3
  import numpy as np
@@ -5,7 +24,7 @@ from PIL import Image
5
  import io
6
 
7
  # Load the pre-trained TensorFlow model
8
- model = tf.keras.models.load_model("/content/models/imageclassifier.h5")
9
 
10
  # Define the function to predict the teeth health
11
  def predict_teeth_health(image):
@@ -24,18 +43,19 @@ def predict_teeth_health(image):
24
  # Get the probability of being 'Good'
25
  probability_good = prediction[0][0] # Assuming it's a binary classification
26
 
27
- # Return the predicted class name
28
- if probability_good > 0.5:
29
- return f"Predicted: Your Teeth are Good And You Don't Need To Visit Doctor"
30
- else:
31
- return f"Predicted: Your Teeth are Bad And You Need To Visit Doctor"
 
32
 
33
  # Define the Gradio interface
34
  iface = gr.Interface(
35
  fn=predict_teeth_health,
36
  inputs=gr.Image(type="pil"),
37
- outputs="text",
38
- title="<h1 style='color: lightgreen; text-align: center;'>Dentella</h1>",
39
  )
40
 
41
  # Deploy the Gradio interface using Gradio's hosting service
 
1
+ import subprocess
2
+
3
+ # Define the list of libraries to install
4
+ libraries = [
5
+ 'gradio',
6
+ 'tensorflow',
7
+ 'numpy',
8
+ 'Pillow',
9
+ 'opencv-python-headless',
10
+ 'Flask' # Add Flask here
11
+ ]
12
+
13
+ # Install each library using pip
14
+ for library in libraries:
15
+ try:
16
+ subprocess.check_call(['pip', 'install', library])
17
+ except subprocess.CalledProcessError as e:
18
+ print(f"Error installing {library}: {e}")
19
+
20
  import gradio as gr
21
  import tensorflow as tf
22
  import numpy as np
 
24
  import io
25
 
26
  # Load the pre-trained TensorFlow model
27
+ model = tf.keras.models.load_model("imageclassifier.h5")
28
 
29
  # Define the function to predict the teeth health
30
  def predict_teeth_health(image):
 
43
  # Get the probability of being 'Good'
44
  probability_good = prediction[0][0] # Assuming it's a binary classification
45
 
46
+ # Define the prediction result
47
+ result = {
48
+ "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"
49
+ }
50
+
51
+ return result
52
 
53
  # Define the Gradio interface
54
  iface = gr.Interface(
55
  fn=predict_teeth_health,
56
  inputs=gr.Image(type="pil"),
57
+ outputs="json",
58
+ 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>",
59
  )
60
 
61
  # Deploy the Gradio interface using Gradio's hosting service