import tensorflow as tf print("TensorFlow is installed:", tf.__version__) import gradio as gr import tensorflow as tf import numpy as np from PIL import Image # Load trained model model = tf.keras.models.load_model("eurosat_cnn_model.h5") # Define class labels class_labels = [ "AnnualCrop", "Forest", "Highway", "Industrial", "Pasture", "PermanentCrop", "Residential", "River", "SeaLake", "HerbaceousVegetation" ] # Function to process image and make predictions def predict_image(image): image = image.resize((64, 64)) # Resize image img_array = np.array(image) / 255.0 # Normalize img_array = np.expand_dims(img_array, axis=0) # Add batch dimension prediction = model.predict(img_array) # Predict return {class_labels[i]: float(prediction[0][i]) for i in range(len(class_labels))} # Create Gradio Interface iface = gr.Interface(fn=predict_image, inputs="image", outputs="label") iface.launch()