Skip to content

Commit fb8aab2

Browse files
committed
fix links add docs
1 parent ebeb620 commit fb8aab2

File tree

13 files changed

+79
-18
lines changed

13 files changed

+79
-18
lines changed

docs/src/buffering.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@ apply!(buffer, tfm, item)
99

1010
However, for some transformations, a different buffer is needed. [`Sequence`](@ref), for example, needs to reuse all intermediate results. That is why the buffer creation can be customized:
1111

12-
- [`makebuffer`](@ref)`(tfm, item)` creates a buffer `buf` that can be used in an `apply!` call: `apply!(buf, tfm, item)`.
12+
- [`DataAugmentation.makebuffer`](@ref)`(tfm, item)` creates a buffer `buf` that can be used in an `apply!` call: `apply!(buf, tfm, item)`.
1313

1414
---
1515

16-
Managing the buffers manually quickly becomes tedious. For convenience, this library implements [`Buffered`](@ref), a transformation wrapper that will use a buffer internally. `btfm = Buffered(tfm)` will create a buffer the first time it is `apply`ed and then use it by internally calling `apply!`.
16+
Managing the buffers manually quickly becomes tedious. For convenience, this library implements [`DataAugmentation.Buffered`](@ref), a transformation wrapper that will use a buffer internally. `btfm = Buffered(tfm)` will create a buffer the first time it is `apply`ed and then use it by internally calling `apply!`.
1717

1818
```julia
1919
buffered = Buffered(tfm)
2020
buffer = apply(tfm, item) # uses apply! internally
2121
```
2222

23-
Since `Buffered` only stores one buffer, you may run into problems when using it in a multi-threading context where different threads invalidate the buffer before it can be used. In that case, you can use [`BufferedThreadsafe`](@ref), a version of `Buffered` that keeps a separate buffer for every thread.
23+
Since `Buffered` only stores one buffer, you may run into problems when using it in a multi-threading context where different threads invalidate the buffer before it can be used. In that case, you can use [`DataAugmentation.BufferedThreadsafe`](@ref), a version of `Buffered` that keeps a separate buffer for every thread.
24+
25+
```@docs
26+
DataAugmentation.Buffered
27+
DataAugmentation.BufferedThreadsafe
28+
```

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The above example is simple, but there are more requirements of data augmentatio
2121
A transformation is stochastic (as opposed to deterministic) if it produces different outputs based on some random state.
2222
This randomness can become a problem when applying an transformation to an aligned pair of input and target. If we have an image and a corresponding segmentation mask, using different scaling factors results in misalignment of the two; the segmentation no longer matches up with the image pixels.
2323

24-
To handle this, the random state is explicitly passed to the transformations, rendering them deterministic. A generator for the random state can be defined with [`getrandstate`](@ref)`(tfm)` and passed to `apply` with the `randstate` keyword argument.
24+
To handle this, the random state is explicitly passed to the transformations, rendering them deterministic. A generator for the random state can be defined with [`DataAugmentation.getrandstate`](@ref)`(tfm)` and passed to `apply` with the `randstate` keyword argument.
2525

2626
### Composition
2727

docs/src/iteminterface.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ struct MyItem <: Item
2020
end
2121
```
2222

23-
The only function that is expected to be implemented is [`itemdata`](@ref), which simply returns the wrapped data. If, as above, you simply call the field holding the data `data`, you do not need to implement it. The same goes for the [`setdata`](@ref) helper.
23+
The only function that is expected to be implemented is [`itemdata`](@ref), which simply returns the wrapped data. If, as above, you simply call the field holding the data `data`, you do not need to implement it. The same goes for the [`DataAugmentation.setdata`](@ref) helper.
2424

2525
For some items, it also makes sense to implement the following:
2626

27-
- [`showitem!`](@ref)`(img, item::I)` creates a visual representation of an item on top of `img`.
27+
- [`DataAugmentation.showitem!`](@ref)`(img, item::I)` creates a visual representation of an item on top of `img`.

docs/src/preprocessing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This library also implements some general transformations useful for getting data ready to be put into a model.
44

5-
- [`ToEltype`](@ref)`(T)` converts the element type of any [`AbstractArrayItem`](@ref) to `T`.
5+
- [`ToEltype`](@ref)`(T)` converts the element type of any [`DataAugmentation.AbstractArrayItem`](@ref) to `T`.
66
- [`ImageToTensor`](@ref) converts an image to an `ArrayItem` with another dimension for the color channels
77
- [`Normalize`](@ref) normalizes image tensors
88
- [`OneHot`](@ref) to one-hot encode multi-class masks ([`MaskMulti`](@ref)s)

docs/src/projective/intro.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ By default, the bounds of a projected item will be chosen so they still encase a
3030

3131
## Projective transformations interface
3232

33-
The abstract type [`ProjectiveTransform`](@ref) represents a projective transformation.
34-
A `ProjectiveTransform` needs to implement [`getprojection`](@ref)`(tfm, bounds; randstate)` that should return a `Transformation` from [CoordinateTransformations.jl](https://github.com/JuliaGeometry/CoordinateTransformations.jl).
33+
The abstract type [`DataAugmentation.ProjectiveTransform`](@ref) represents a projective transformation.
34+
A `ProjectiveTransform` needs to implement [`DataAugmentation.getprojection`](@ref)`(tfm, bounds; randstate)` that should return a `Transformation` from [CoordinateTransformations.jl](https://github.com/JuliaGeometry/CoordinateTransformations.jl).
3535

3636
To add support for projective transformations to an item `I`, you need to implement
3737

docs/src/ref.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,47 @@ Crop
1212
Rotate
1313
itemdata
1414
showitems
15+
16+
DataAugmentation.AbstractArrayItem
17+
DataAugmentation.AbstractItem
18+
DataAugmentation.ArrayItem
19+
DataAugmentation.Categorify
20+
DataAugmentation.ComposedProjectiveTransform
21+
DataAugmentation.FillMissing
22+
DataAugmentation.Identity
23+
DataAugmentation.Item
24+
DataAugmentation.ItemWrapper
25+
DataAugmentation.MapElem
26+
DataAugmentation.Normalize
27+
DataAugmentation.NormalizeRow
28+
DataAugmentation.OneHot
29+
DataAugmentation.PinOrigin
30+
DataAugmentation.ProjectiveTransform
31+
DataAugmentation.ResizePadDivisible
32+
DataAugmentation.ScaleFixed
33+
DataAugmentation.Sequence
34+
DataAugmentation.ToEltype
35+
DataAugmentation.Transform
36+
DataAugmentation.Zoom
37+
DataAugmentation.apply
38+
DataAugmentation.apply!
39+
DataAugmentation.boundsof
40+
DataAugmentation.centered
41+
DataAugmentation.compose
42+
DataAugmentation.getbounds
43+
DataAugmentation.getprojection
44+
DataAugmentation.getrandstate
45+
DataAugmentation.makebuffer
46+
DataAugmentation.offsetcropbounds
47+
DataAugmentation.project
48+
DataAugmentation.project!
49+
DataAugmentation.projectionbounds
50+
DataAugmentation.setdata
51+
DataAugmentation.showitem!
52+
DataAugmentation.testapply
53+
DataAugmentation.testapply!
54+
DataAugmentation.testitem
55+
DataAugmentation.testprojective
56+
DataAugmentation.threepointwarpaffine
57+
DataAugmentation.transformbounds
1558
```

docs/src/tfminterface.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ A transformation is a type that subtypes [`Transform`](@ref). The only *required
1717

1818
You may additionally also implement:
1919

20-
- [`getrandstate`](@ref)`(tfm)` for *stochastic* transformations
20+
- [`DataAugmentation.getrandstate`](@ref)`(tfm)` for *stochastic* transformations
2121

2222
Generates random state to be used inside `apply`. Calling `apply(tfm, item)` is equivalent to
2323
`apply(tfm, item; randstate = getrandstate(tfm))`. It defaults to `nothing`, so we need not implement it for deterministic transformations.
@@ -27,7 +27,7 @@ You may additionally also implement:
2727
Buffered version of `apply` that mutates `bufitem`. If not implemented,
2828
falls back to regular `apply`.
2929

30-
- [`compose`](@ref)`(tfm1, tfm2)` for custom *composition* with other transformations
30+
- [`DataAugmentation.compose`](@ref)`(tfm1, tfm2)` for custom *composition* with other transformations
3131

3232
Composes transformations. By default, returns a [`Sequence`](@ref) transformation that applies the transformations one after the other.
3333

@@ -43,7 +43,7 @@ struct MapElem <: Transform
4343
end
4444
```
4545

46-
The `apply` implementation dispatches on [`AbstractArrayItem`](@ref), an abstract item type for items that wrap arrays. Note that the `randstate` keyword argument needs to be given even for implementations of deterministic transformations. We also make use of the [`setdata`](@ref) helper to update the item data.
46+
The `apply` implementation dispatches on [`DataAugmentation.AbstractArrayItem`](@ref), an abstract item type for items that wrap arrays. Note that the `randstate` keyword argument needs to be given even for implementations of deterministic transformations. We also make use of the [`DataAugmentation.setdata`](@ref) helper to update the item data.
4747

4848
```julia
4949
function apply(tfm::MapElem, item::AbstractArrayItem; randstate = nothing)

docs/src/transformations.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,7 @@ tfm = Maybe(FlipX())
7171
titems = [apply(tfm, item) for _ in 1:8]
7272
showgrid(titems; ncol = 4, npad = 16)
7373
```
74+
75+
```@docs
76+
DataAugmentation.ImageToTensor
77+
```

src/base.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,11 @@ compose(::Identity, ::Identity) = Identity()
110110
compose(tfm::Transform, ::Identity) = tfm
111111
compose(::Identity, tfm::Transform) = tfm
112112

113-
# Lastly, [`setdata`](@ref) provides a convenient way to create a copy
114-
# of an item, replacing only the wrapped data. This relies on the
115-
# wrapped data field being named `data`, though.
116-
113+
"""
114+
Provides a convenient way to create a copy
115+
of an item, replacing only the wrapped data. This relies on the
116+
wrapped data field being named `data`, though.
117+
"""
117118
function setdata(item::Item, data)
118119
item = Setfield.@set item.data = data
119120
return item

src/buffered.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ end
4141

4242
# ## Buffered transforms
4343

44+
"""
45+
Buffer to store transform results
46+
"""
4447
mutable struct Buffered{T<:Transform} <: Transform
4548
tfm::T
4649
buffers::Dict
@@ -73,6 +76,9 @@ function apply!(buf, buffered::Buffered, items::T; randstate = getrandstate(buff
7376
end
7477

7578

79+
"""
80+
Buffer to store transform results (threadsafe)
81+
"""
7682
struct BufferedThreadsafe <: Transform
7783
buffereds::Vector{Buffered}
7884
function BufferedThreadsafe(tfm; n = Threads.nthreads())

src/projective/affine.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ end
108108

109109
Zoom(scales::NTuple{2, T} = (1., 1.2)) where T = Zoom(Uniform(scales[1], scales[2]))
110110

111+
"""
112+
Return random state of the transform
113+
"""
111114
getrandstate(tfm::Zoom) = rand(tfm.dist)
112115

113116
function getprojection(tfm::Zoom, bounds::Bounds{N}; randstate = getrandstate(tfm)) where N

src/projective/base.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
abstract type ProjectiveTransform <: Transform
33
44
Abstract supertype for projective transformations. See
5-
[Projective transformations](../docs/projective/interface.md).
65
"""
76
abstract type ProjectiveTransform <: Transform end
87

src/projective/warp.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ end
3232
"""
3333
threepointwarpaffine(srcps, dstps)
3434
35-
Calculate an affine [`CoordinateTransformations.LinearMap`](@ref)
35+
Calculate an affine `CoordinateTransformations.LinearMap`
3636
from 3 source points to 3 destination points.
3737
3838
Adapted from [CoordinateTransformations.jl#30](https://github.com/JuliaGeometry/CoordinateTransformations.jl/issues/30#issuecomment-610337378).

0 commit comments

Comments
 (0)