Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -35,12 +35,32 @@ import torch.nn.functional as F
|
|
35 |
#learner = from_pretrained_fastai(repo_id)
|
36 |
|
37 |
from huggingface_hub import from_pretrained_fastai
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
import torchvision.transforms as transforms
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
-
|
|
|
|
|
|
|
44 |
|
45 |
class TargetMaskConvertTransform(ItemTransform):
|
46 |
def __init__(self):
|
|
|
35 |
#learner = from_pretrained_fastai(repo_id)
|
36 |
|
37 |
from huggingface_hub import from_pretrained_fastai
|
|
|
|
|
|
|
38 |
import torchvision.transforms as transforms
|
39 |
+
from transforms import ItemTransform
|
40 |
+
|
41 |
+
from albumentations import (
|
42 |
+
Compose,
|
43 |
+
OneOf,
|
44 |
+
ElasticTransform,
|
45 |
+
GridDistortion,
|
46 |
+
OpticalDistortion,
|
47 |
+
HorizontalFlip,
|
48 |
+
Rotate,
|
49 |
+
Transpose,
|
50 |
+
CLAHE,
|
51 |
+
ShiftScaleRotate
|
52 |
+
)
|
53 |
+
|
54 |
+
class SegmentationAlbumentationsTransform(ItemTransform):
|
55 |
+
split_idx = 0
|
56 |
+
|
57 |
+
def __init__(self, aug):
|
58 |
+
self.aug = aug
|
59 |
|
60 |
+
def encodes(self, x):
|
61 |
+
img,mask = x
|
62 |
+
aug = self.aug(image=np.array(img), mask=np.array(mask))
|
63 |
+
return PILImage.create(aug["image"]), PILMask.create(aug["mask"])
|
64 |
|
65 |
class TargetMaskConvertTransform(ItemTransform):
|
66 |
def __init__(self):
|