Spaces:
Sleeping
Sleeping
Update app.py
Browse filesRectificación de código
app.py
CHANGED
|
@@ -1,27 +1,24 @@
|
|
| 1 |
-
#IMPORTACIONES
|
| 2 |
-
|
| 3 |
import gradio as gr
|
| 4 |
import numpy as np
|
| 5 |
import pickle
|
| 6 |
-
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
model = load_model(model_path)
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
pickle.dump(scaler,fichero)
|
| 16 |
-
fichero.close()
|
| 17 |
|
|
|
|
| 18 |
|
| 19 |
#Escribo el escalador en el fichero
|
| 20 |
-
scaler_path = "scaler.pckl"
|
| 21 |
with open(scaler_path, "wb") as fichero:
|
| 22 |
pickle.dump(scaler,fichero)
|
| 23 |
fichero.close()
|
| 24 |
|
|
|
|
| 25 |
# Clases del modelo
|
| 26 |
clases = ['Setosa', 'Versicolor', 'Virginica']
|
| 27 |
|
|
@@ -41,11 +38,11 @@ def clasificar(sepalo_largo, sepalo_ancho, petalo_largo, petalo_ancho):
|
|
| 41 |
|
| 42 |
#Salida de la imágen en función de la clase predicha
|
| 43 |
if clase_predicha == "Setosa":
|
| 44 |
-
imagen = "Iris_setosa.jpg" #ruta donde esta la imágen
|
| 45 |
elif clase_predicha == "Versicolor":
|
| 46 |
-
imagen = "Iris_versicolor.jpg"
|
| 47 |
else:
|
| 48 |
-
imagen = "Iris_virginica.jpg"
|
| 49 |
|
| 50 |
return clase_predicha, imagen
|
| 51 |
|
|
@@ -73,4 +70,4 @@ demo = gr.Interface(
|
|
| 73 |
|
| 74 |
# Lanzar la interfaz
|
| 75 |
if __name__ == "__main__":
|
| 76 |
-
demo.launch(share=True)
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import numpy as np
|
| 3 |
import pickle
|
| 4 |
+
import tensorflow as tf
|
| 5 |
|
| 6 |
+
model_path = "modelo_flowers/modeloIris-Daniela.h5"
|
| 7 |
+
model = tf.keras.models.load_model(model_path)
|
|
|
|
| 8 |
|
| 9 |
+
model.save("modelo_flowers/modeloIris-Daniela.h5")
|
| 10 |
+
|
| 11 |
+
scaler = pickle.load(open("modelo_flowers/scaler.pckl","rb")) #rb en modo lectura
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
fichero = open("modelo_flowers/scaler.pckl","wb")
|
| 14 |
|
| 15 |
#Escribo el escalador en el fichero
|
| 16 |
+
scaler_path = "modelo_flowers/scaler.pckl"
|
| 17 |
with open(scaler_path, "wb") as fichero:
|
| 18 |
pickle.dump(scaler,fichero)
|
| 19 |
fichero.close()
|
| 20 |
|
| 21 |
+
|
| 22 |
# Clases del modelo
|
| 23 |
clases = ['Setosa', 'Versicolor', 'Virginica']
|
| 24 |
|
|
|
|
| 38 |
|
| 39 |
#Salida de la imágen en función de la clase predicha
|
| 40 |
if clase_predicha == "Setosa":
|
| 41 |
+
imagen = "imagenes/Iris_setosa.jpg" #ruta donde esta la imágen
|
| 42 |
elif clase_predicha == "Versicolor":
|
| 43 |
+
imagen = "imagenes/Iris_versicolor.jpg"
|
| 44 |
else:
|
| 45 |
+
imagen = "imagenes/Iris_virginica.jpg"
|
| 46 |
|
| 47 |
return clase_predicha, imagen
|
| 48 |
|
|
|
|
| 70 |
|
| 71 |
# Lanzar la interfaz
|
| 72 |
if __name__ == "__main__":
|
| 73 |
+
demo.launch(debug=True,share=True)
|