Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,25 @@ from PIL import Image
|
|
| 5 |
from huggingface_hub import hf_hub_download
|
| 6 |
import torchvision.transforms as transforms
|
| 7 |
import torch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# Cargar modelo desde Hugging Face Hub
|
| 10 |
model_path = hf_hub_download(repo_id="PablitoGil14/AP-Practica3", filename="model.pkl")
|
|
|
|
| 5 |
from huggingface_hub import hf_hub_download
|
| 6 |
import torchvision.transforms as transforms
|
| 7 |
import torch
|
| 8 |
+
from albumentations import (
|
| 9 |
+
Compose,
|
| 10 |
+
HorizontalFlip,
|
| 11 |
+
Rotate,
|
| 12 |
+
GridDistortion
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
class SegmentationAlbumentationsTransform(ItemTransform):
|
| 16 |
+
split_idx = 0
|
| 17 |
+
|
| 18 |
+
def __init__(self, aug):
|
| 19 |
+
self.aug = aug
|
| 20 |
+
|
| 21 |
+
def encodes(self, x):
|
| 22 |
+
img,mask = x
|
| 23 |
+
aug = self.aug(image=np.array(img), mask=np.array(mask))
|
| 24 |
+
return PILImage.create(aug["image"]), PILMask.create(aug["mask"])
|
| 25 |
+
|
| 26 |
+
|
| 27 |
|
| 28 |
# Cargar modelo desde Hugging Face Hub
|
| 29 |
model_path = hf_hub_download(repo_id="PablitoGil14/AP-Practica3", filename="model.pkl")
|