import gradio as gr import numpy as np import pickle # Load model with open("iris_model.pkl", "rb") as f: model = pickle.load(f) # Define prediction function def predict(sepal_length, sepal_width, petal_length, petal_width): input_data = np.array([[sepal_length, sepal_width, petal_length, petal_width]]) prediction = model.predict(input_data)[0] species = ["Setosa 🌼", "Versicolor 🌷", "Virginica 🌹"] return f"The predicted species is: **{species[prediction]}**" # Create the app layout with gr.Blocks(theme="soft") as demo: gr.Markdown("# 🌺 Iris Flower Classifier") gr.Markdown("Enter the flower measurements below to predict its species using a trained Machine Learning model.") with gr.Row(): sepal_length = gr.Number(label="📏 Sepal Length (cm)") sepal_width = gr.Number(label="📏 Sepal Width (cm)") with gr.Row(): petal_length = gr.Number(label="🌸 Petal Length (cm)") petal_width = gr.Number(label="🌸 Petal Width (cm)") predict_btn = gr.Button("🔍 Predict Species") output = gr.Markdown() predict_btn.click(fn=predict, inputs=[sepal_length, sepal_width, petal_length, petal_width], outputs=output) # Launch the app demo.launch()