Skip to content

Commit bee1f43

Browse files
committed
fix figures in augmentation how-to
1 parent 1e9873f commit bee1f43

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

docs/howto/augmentvision.md

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,30 @@
33
Data augmentation is important to train models with good generalization ability, especially when the size of your dataset is limited. FastAI.jl gives you high-level helpers to use data augmentation in vision learning methods, but also allows directly using [DataAugmentation.jl](https://github.com/lorenzoh/DataAugmentation.jl), the underlying data augmentation library.
44

55
By default, the only augmentation that will be used in computer vision tasks is a random crop, meaning that after images, keypoints and masks are resized to a similar size a random portion will be cropped during training. We can demonstrate this on the image classification task.
6-
{cell=main output=false result=false style="display:none;"}
7-
```julia
8-
using Images: load
9-
function showfig(f)
10-
save("fig.png", f)
11-
load("fig.png")
12-
end
13-
```
146

157
{cell=main result=false output=false}
168
```julia
179
using FastAI
18-
using CairoMakie
10+
using CairoMakie; CairoMakie.activate!(type="png")
1911

2012
dir = joinpath(datasetpath("dogscats"), "train")
2113
data = loadtaskdata(dir, ImageClassificationTask)
2214
classes = Datasets.getclassesclassification(dir)
2315
method = ImageClassification(classes, (100, 128))
2416
xs, ys = FastAI.makebatch(method, data, fill(4, 9))
25-
f = FastAI.plotbatch(method, xs, ys)
26-
```
27-
{cell=main output=false style="display:none;"}
28-
```julia
29-
showfig(f)
17+
FastAI.plotbatch(method, xs, ys)
3018
```
3119

3220

3321
Most learning methods let you pass additional augmentations as keyword arguments. For example, `ImageClassification` takes the `aug_projection` and `aug_image` arguments. FastAI.jl provides the [`augs_projection`](#) helper to quickly construct a set of projective data augmentations.
3422

35-
{cell=main result=false}
23+
{cell=main}
3624
```julia
3725
method2 = ImageClassification(classes, (100, 128), aug_projection=augs_projection())
3826
xs2, ys2 = FastAI.makebatch(method2, data, fill(4, 9))
3927
f = FastAI.plotbatch(method2, xs2, ys2)
4028
```
41-
{cell=main output=false style="display:none;"}
42-
```julia
43-
showfig(f)
44-
```
29+
4530

4631
Likewise, there is an [`augs_lighting`](#) helper that adds contrast and brightness augmentation:
4732

@@ -51,7 +36,7 @@ method3 = ImageClassification(
5136
classes, (100, 128),
5237
aug_projection=augs_projection(), aug_image=augs_lighting())
5338
xs3, ys3 = FastAI.makebatch(method3, data, fill(4, 9))
54-
f = FastAI.plotbatch(method3, xs3, ys3)
39+
FastAI.plotbatch(method3, xs3, ys3)
5540
```
5641

5742
## Augmentation in custom learning methods

0 commit comments

Comments
 (0)