Downloads · 30 days
0
ritzugrandett/modelo_telefono
modelo_telefono is a machine learning model from ritzugrandett. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
import gradio as gr import numpy as np from tensorflow.keras.preprocessing import image from tensorflow.keras.applications.vgg16 import preprocessinput
Downloads · 30 days
0
Access
Public
Updated Oct 13, 2024
Repo size
41.5 MB
Likes
0
Public
Click a slice to open those files.
.h541.5 MB · 100%
From the Hugging Face model README
import gradio as gr import numpy as np from tensorflow.keras.preprocessing import image from tensorflow.keras.applications.vgg16 import preprocess_input
def clasificar_imagen(img): # Convertir la imagen a un array numpy si es necesario img = img.resize((150, 150)) # Ajustar el tamaño de la imagen si es necesario img = np.array(img) # Convertir la imagen a un array numpy img = img.reshape(1, 150, 150, 3) # Asegurarse de que la imagen tenga la forma correcta img = preprocess_input(img) # Preprocesar la imagen
# Realizar la predicción
prediccion = model.predict(img)[0][0] # Asegúrate de que la predicción sea un número
# Verificar el valor de la predicción y retornar el resultado
if prediccion > 0.5:
return {"Roto": prediccion, "No Roto": 1 - prediccion}
else:
return {"Roto": prediccion, "No Roto": 1 - prediccion}
iface = gr.Interface( fn=clasificar_imagen, inputs=gr.Image(type="pil"), # Removed 'shape' argument, as it is likely not supported outputs=gr.Label(num_top_classes=2), # Gradio espera un diccionario con etiquetas ).launch()