import subprocess # Define the list of libraries to install libraries = [ 'gradio', 'tensorflow', 'numpy', 'Pillow', 'opencv-python-headless', # This installs OpenCV without GUI support ] # Install each library using pip for library in libraries: try: subprocess.check_call(['pip', 'install', library]) except subprocess.CalledProcessError as e: print(f"Error installing {library}: {e}") import gradio as gr import tensorflow as tf import numpy as np from PIL import Image import io # Load the pre-trained TensorFlow model model = tf.keras.models.load_model("dentella.h5") # Define the function to predict the teeth health def predict_teeth_health(image): # Convert the PIL image object to a file-like object image_bytes = io.BytesIO() image.save(image_bytes, format="JPEG") # Load the image from the file-like object image = tf.keras.preprocessing.image.load_img(image_bytes, target_size=(256, 256)) image = tf.keras.preprocessing.image.img_to_array(image) image = np.expand_dims(image, axis=0) # Make a prediction prediction = model.predict(image) # Get the probability of being 'Good' probability_good = prediction[0][0] # Assuming it's a binary classification # Return the predicted class name if probability_good > 0.5: return f"Predicted: Your Teeth are Good And You Don't Need To Visit Doctor" else: return f"Predicted: Your Teeth are Bad And You Need To Visit Doctor" # Define the Gradio interface iface = gr.Interface( fn=predict_teeth_health, inputs=gr.Image(type="pil"), outputs="text", title="