added augment demo images

This commit is contained in:
sugarme 2021-05-22 21:49:31 +10:00
parent 7292c3575e
commit e49f0eab20
4 changed files with 6 additions and 3 deletions

View File

@ -28,4 +28,7 @@ There are 2 APIs (`aug.Compose` and `aug.OneOf`) to compose augmentation methods
```
![transformed images](augment.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

View File

@ -16,8 +16,8 @@ func main() {
panic(err)
}
device := gotch.CudaIfAvailable()
// device := gotch.CPU
// device := gotch.CudaIfAvailable()
device := gotch.CPU
imgTs := img.MustTo(device, true)
// t, err := aug.Compose(aug.WithResize(512, 512)) // NOTE. WithResize just works on CPU.
// t, err := aug.Compose(aug.WithRandRotate(0, 360), aug.WithColorJitter(0.3, 0.3, 0.3, 0.4))
@ -37,6 +37,7 @@ func main() {
// t, err := aug.Compose(aug.WithNormalize(aug.WithNormalizeMean([]float64{0.485, 0.456, 0.406}), aug.WithNormalizeStd([]float64{0.229, 0.224, 0.225})))
t, err := aug.Compose(
aug.WithResize(200, 200),
aug.WithRandomVFlip(0.5),
aug.WithRandomHFlip(0.5),
aug.WithRandomCutout(),

View File

@ -761,7 +761,6 @@ func applyGridTransform(x, gridInput *ts.Tensor, mode string, fillValue []float6
addTs := mask.MustMul1(ts.FloatScalar(-1), false).MustAdd1(ts.FloatScalar(1.0), true).MustMul(fillImg, true)
imgOut := image.MustMul(mask, true).MustAdd(addTs, true)
addTs.MustDrop()
image.MustDrop()
mask.MustDrop()
fillImg.MustDrop()