Update app.py
Browse files
app.py
CHANGED
|
@@ -16,6 +16,12 @@ from albumentations import (
|
|
| 16 |
ShiftScaleRotate
|
| 17 |
)
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
class SegmentationAlbumentationsTransform(ItemTransform):
|
| 20 |
split_idx = 0
|
| 21 |
|
|
@@ -27,6 +33,11 @@ class SegmentationAlbumentationsTransform(ItemTransform):
|
|
| 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):
|
| 32 |
pass
|
|
|
|
| 16 |
ShiftScaleRotate
|
| 17 |
)
|
| 18 |
|
| 19 |
+
def get_y_fn (x):
|
| 20 |
+
return Path(str(x).replace("Images","Labels").replace("color","gt").replace(".jpg",".png"))
|
| 21 |
+
|
| 22 |
+
def ParentSplitter(x):
|
| 23 |
+
return Path(x).parent.name==test_name
|
| 24 |
+
|
| 25 |
class SegmentationAlbumentationsTransform(ItemTransform):
|
| 26 |
split_idx = 0
|
| 27 |
|
|
|
|
| 33 |
aug = self.aug(image=np.array(img), mask=np.array(mask))
|
| 34 |
return PILImage.create(aug["image"]), PILMask.create(aug["mask"])
|
| 35 |
|
| 36 |
+
transforms=Compose([HorizontalFlip(p=0.5),
|
| 37 |
+
Rotate(p=0.40,limit=10),GridDistortion()
|
| 38 |
+
],p=1)
|
| 39 |
+
transformPipeline=SegmentationAlbumentationsTransform(transforms)
|
| 40 |
+
|
| 41 |
class TargetMaskConvertTransform(ItemTransform):
|
| 42 |
def __init__(self):
|
| 43 |
pass
|