Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,31 @@
|
|
| 1 |
from huggingface_hub import from_pretrained_fastai
|
| 2 |
import gradio as gr
|
| 3 |
from fastai.vision.all import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
class TargetMaskConvertTransform(ItemTransform):
|
| 6 |
def __init__(self):
|
|
|
|
| 1 |
from huggingface_hub import from_pretrained_fastai
|
| 2 |
import gradio as gr
|
| 3 |
from fastai.vision.all import *
|
| 4 |
+
from albumentations import (
|
| 5 |
+
Compose,
|
| 6 |
+
OneOf,
|
| 7 |
+
ElasticTransform,
|
| 8 |
+
GridDistortion,
|
| 9 |
+
OpticalDistortion,
|
| 10 |
+
HorizontalFlip,
|
| 11 |
+
VerticalFlip,
|
| 12 |
+
Rotate,
|
| 13 |
+
Transpose,
|
| 14 |
+
CLAHE,
|
| 15 |
+
ShiftScaleRotate,
|
| 16 |
+
RandomScale
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
class SegmentationAlbumentationsTransform(ItemTransform):
|
| 20 |
+
split_idx = 0
|
| 21 |
+
|
| 22 |
+
def __init__(self, aug):
|
| 23 |
+
self.aug = aug
|
| 24 |
+
|
| 25 |
+
def encodes(self, x):
|
| 26 |
+
img,mask = x
|
| 27 |
+
aug = self.aug(image=np.array(img), mask=np.array(mask))
|
| 28 |
+
return PILImage.create(aug["image"]), PILMask.create(aug["mask"])
|
| 29 |
|
| 30 |
class TargetMaskConvertTransform(ItemTransform):
|
| 31 |
def __init__(self):
|