Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -80,8 +80,8 @@ model = model.cpu()
|
|
| 80 |
|
| 81 |
# Definimos una función que se encarga de llevar a cabo las predicciones
|
| 82 |
def predict(img_ruta):
|
| 83 |
-
|
| 84 |
-
img = img_ruta
|
| 85 |
image = transforms.Resize((480,640))(img)
|
| 86 |
tensor = transform_image(image=image)
|
| 87 |
model.to(device)
|
|
@@ -98,9 +98,7 @@ def predict(img_ruta):
|
|
| 98 |
return Image.fromarray(mask.astype('uint8'))
|
| 99 |
|
| 100 |
|
| 101 |
-
#img = PILImage.create(img)
|
| 102 |
-
# pred,pred_idx,probs = learner.predict(img)
|
| 103 |
-
# return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 104 |
|
| 105 |
# Creamos la interfaz y la lanzamos.
|
| 106 |
-
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(480, 640)), outputs=gr.inputs.Image(shape=(480, 640))).launch(share=False) #,examples=['color_155.jpg','color_154 (1).jpg']
|
|
|
|
| 80 |
|
| 81 |
# Definimos una función que se encarga de llevar a cabo las predicciones
|
| 82 |
def predict(img_ruta):
|
| 83 |
+
img = PIL.Image.open(img_ruta) #esto si el parámetro de entrada es una ruta a una imagen
|
| 84 |
+
# img = img_ruta # esto si el parámetro de entrada es una imagen
|
| 85 |
image = transforms.Resize((480,640))(img)
|
| 86 |
tensor = transform_image(image=image)
|
| 87 |
model.to(device)
|
|
|
|
| 98 |
return Image.fromarray(mask.astype('uint8'))
|
| 99 |
|
| 100 |
|
| 101 |
+
#img = PILImage.create(img) #igual hay que usar esto en vez de PIL.Image.open
|
|
|
|
|
|
|
| 102 |
|
| 103 |
# Creamos la interfaz y la lanzamos.
|
| 104 |
+
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(480, 640)), outputs=gr.inputs.Image(shape=(480, 640)), examples=['color_155.jpg','color_154 (1).jpg']).launch(share=False) #,examples=['color_155.jpg','color_154 (1).jpg']
|