Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,28 +1,38 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
|
| 3 |
import pickle
|
| 4 |
-
with open('modelo.pkl', 'rb') as file:
|
| 5 |
knn = pickle.load(file)
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
def modelo(sepal_length, sepal_width, petal_length, petal_width):
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
|
| 12 |
interfaz = gr.Interface(
|
| 13 |
fn=modelo,
|
| 14 |
inputs=[
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
],
|
| 20 |
-
outputs=
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
theme = 'peach'
|
| 26 |
)
|
| 27 |
|
| 28 |
-
interfaz.launch()
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import numpy as np
|
| 3 |
+
from sklearn.neighbors import KNeighborsClassifier
|
| 4 |
|
| 5 |
import pickle
|
| 6 |
+
with open('modelo (3).pkl', 'rb') as file:
|
| 7 |
knn = pickle.load(file)
|
| 8 |
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
# Crear un modelo KNN de ejemplo para que funcione el c贸digo
|
| 12 |
+
#knn = KNeighborsClassifier(n_neighbors=3)
|
| 13 |
+
#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]])
|
| 14 |
+
#y = np.array([0, 1, 2])
|
| 15 |
+
#knn.fit(X, y)
|
| 16 |
+
|
| 17 |
def modelo(sepal_length, sepal_width, petal_length, petal_width):
|
| 18 |
+
species = ['Iris-Setosa', 'Iris-Versicolour', 'Iris-Virginica']
|
| 19 |
+
i = knn.predict([[sepal_length, sepal_width, petal_length, petal_width]])[0]
|
| 20 |
+
return species[i]
|
| 21 |
|
| 22 |
interfaz = gr.Interface(
|
| 23 |
fn=modelo,
|
| 24 |
inputs=[
|
| 25 |
+
gr.Slider(label='Sepal Length', minimum=0.0, maximum=8.0, step=0.1),
|
| 26 |
+
gr.Slider(label='Sepal Width', minimum=0.0, maximum=8.0, step=0.1),
|
| 27 |
+
gr.Slider(label='Petal Length', minimum=0.0, maximum=8.0, step=0.1),
|
| 28 |
+
gr.Slider(label='Petal Width', minimum=0.0, maximum=8.0, step=0.1),
|
| 29 |
],
|
| 30 |
+
outputs=gr.Textbox(label='Specie'),
|
| 31 |
+
title='Detector de especies de iris',
|
| 32 |
+
description='Este modelo est谩 desarrollado para la clasificaci贸n de flores de la especie Iris.',
|
| 33 |
+
article='Aplicaci贸n desarrollada con fines docentes en el curso Saturdays.ai',
|
| 34 |
+
theme='peach'
|
|
|
|
| 35 |
)
|
| 36 |
|
| 37 |
+
interfaz.launch()
|
| 38 |
+
|