Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,6 +13,7 @@ from pathlib import Path
|
|
| 13 |
import random
|
| 14 |
import PIL
|
| 15 |
|
|
|
|
| 16 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 17 |
def transform_image(image):
|
| 18 |
my_transforms = transforms.Compose([transforms.ToTensor(),
|
|
@@ -70,6 +71,7 @@ class SegmentationAlbumentationsTransform(ItemTransform):
|
|
| 70 |
aug = self.aug(image=np.array(img), mask=np.array(mask))
|
| 71 |
return PILImage.create(aug["image"]), PILMask.create(aug["mask"])
|
| 72 |
|
|
|
|
| 73 |
repo_id = "luisvarona/Practica3"
|
| 74 |
learn = from_pretrained_fastai(repo_id)
|
| 75 |
model = learn.model
|
|
@@ -99,4 +101,4 @@ def predict(img):
|
|
| 99 |
# return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 100 |
|
| 101 |
# Creamos la interfaz y la lanzamos.
|
| 102 |
-
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(640, 480)), outputs=gr.inputs.Image(shape=(649, 480)),examples=['
|
|
|
|
| 13 |
import random
|
| 14 |
import PIL
|
| 15 |
|
| 16 |
+
#Primero definimos todas las funciones, clases y variables que sopn necesarias para que esto funcione
|
| 17 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 18 |
def transform_image(image):
|
| 19 |
my_transforms = transforms.Compose([transforms.ToTensor(),
|
|
|
|
| 71 |
aug = self.aug(image=np.array(img), mask=np.array(mask))
|
| 72 |
return PILImage.create(aug["image"]), PILMask.create(aug["mask"])
|
| 73 |
|
| 74 |
+
#Cargamos el modelo
|
| 75 |
repo_id = "luisvarona/Practica3"
|
| 76 |
learn = from_pretrained_fastai(repo_id)
|
| 77 |
model = learn.model
|
|
|
|
| 101 |
# return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 102 |
|
| 103 |
# Creamos la interfaz y la lanzamos.
|
| 104 |
+
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(640, 480)), outputs=gr.inputs.Image(shape=(649, 480)),examples=['color_155.jpg','color_154 (1).jpg']).launch(share=False)
|