| import gradio as gr | |
| import pickle | |
| import numpy as np | |
| # Load the trained model | |
| with open('model.pkl', 'rb') as f: | |
| model = pickle.load(f) | |
| 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) | |
| return prediction[0] | |
| interface = gr.Interface( | |
| fn=predict, | |
| inputs=["number", "number", "number", "number"], | |
| outputs="text", | |
| title="Iris Flower Classifier", | |
| description="Enter the features of the iris flower to predict its species." | |
| ) | |
| interface.launch() | |