from gradio import Interface, Image, Label import tensorflow as tf # Load your TensorFlow model model = tf.keras.models.load_model("bird_species_classification_model.h5") # Define your class names if needed class_names = ['ABBOTTS BABBLER', 'ABBOTTS BOOBY', 'ABYSSINIAN GROUND HORNBILL', 'AFRICAN CROWNED CRANE', 'AFRICAN EMERALD CUCKOO', 'AFRICAN FIREFINCH', 'AFRICAN OYSTER CATCHER', 'AFRICAN PIED HORNBILL', 'AFRICAN PYGMY GOOSE', 'ALBATROSS', 'ALBERTS TOWHEE', 'ALEXANDRINE PARAKEET', 'ALPINE CHOUGH', 'ALTAMIRA YELLOWTHROAT', 'AMERICAN AVOCET', 'AMERICAN BITTERN', 'AMERICAN COOT', 'AMERICAN FLAMINGO', 'AMERICAN GOLDFINCH', 'AMERICAN KESTREL'] # Function to make predictions def classify_image(image): # Preprocess the image img = tf.image.resize(image, (224, 224)) img = tf.expand_dims(img, 0) # Add batch dimension # Make prediction prediction = model.predict(img) predicted_class = class_names[prediction.argmax()] return predicted_class # Gradio interface image = Image() # Remove the `shape` argument label = Label() # Create interface interface = Interface(classify_image, image, label, title="Bird Species Classification", description="Upload an image of a bird to classify its species.").launch()