Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import numpy as np | |
| from sklearn.neighbors import KNeighborsClassifier | |
| import pickle | |
| with open('modelo (3).pkl', 'rb') as file: | |
| knn = pickle.load(file) | |
| # Crear un modelo KNN de ejemplo para que funcione el c贸digo | |
| #knn = KNeighborsClassifier(n_neighbors=3) | |
| #X = np.array([[6.7, 3.0, 5.2, 2.3], [4.7, 3.2, 1.3, 0.2], [5.0, 3.6, 1.4, 0.2]]) | |
| #y = np.array([0, 1, 2]) | |
| #knn.fit(X, y) | |
| def modelo(sepal_length, sepal_width, petal_length, petal_width): | |
| species = ['Iris-Setosa', 'Iris-Versicolour', 'Iris-Virginica'] | |
| i = knn.predict([[sepal_length, sepal_width, petal_length, petal_width]])[0] | |
| return species[i] | |
| interfaz = gr.Interface( | |
| fn=modelo, | |
| inputs=[ | |
| gr.Slider(label='Sepal Length', minimum=0.0, maximum=8.0, step=0.1), | |
| gr.Slider(label='Sepal Width', minimum=0.0, maximum=8.0, step=0.1), | |
| gr.Slider(label='Petal Length', minimum=0.0, maximum=8.0, step=0.1), | |
| gr.Slider(label='Petal Width', minimum=0.0, maximum=8.0, step=0.1), | |
| ], | |
| outputs=gr.Textbox(label='Specie'), | |
| title='Detector de especies de iris', | |
| description='Este modelo est谩 desarrollado para la clasificaci贸n de flores de la especie Iris.', | |
| article= 'Autor: <a href=\"https://huggingface.co/Antonio49\">Antonio Fern谩ndez</a> de <a href=\"https://saturdays.ai/\">SaturdaysAI</a>. Aplicaci贸n desarrollada con fines docentes', | |
| theme='peach', | |
| examples = [[5,7,0,0], | |
| [0,1,2,8]] | |
| ) | |
| interfaz.launch() | |