-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR introduces support for segmentation masks. The key principle is that we do not apply some operations on segmentation masks.* Introduce `SemanticWrapper` and `Mask` Co-authored-by: Johnny Chen <[email protected]>
- Loading branch information
1 parent
3c62635
commit b5251ac
Showing
19 changed files
with
314 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Semantic Wrappers | ||
|
||
Semantic wrappers are used to define a meaning of an input and | ||
consequently, determine what operations can be applied on that input. | ||
|
||
Each semantic wrapper is expected to implement constructor which takes | ||
the original object and wraps it, and the [`Augmentor.unwrap`](@ref) method, | ||
which returns the wrapped object. I.e., for a wrapper `W`, the following holds: | ||
`obj == unwrap(W(obj))`. | ||
|
||
To prevent name conflicts, it is suggested not to export any semantic wrappers. | ||
|
||
```@docs | ||
Augmentor.SemanticWrapper | ||
Augmentor.unwrap | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
abstract type Operation end | ||
abstract type ImageOperation <: Operation end | ||
abstract type AffineOperation <: ImageOperation end | ||
abstract type ColorOperation <: ImageOperation end | ||
abstract type Pipeline end | ||
const AbstractPipeline = Union{Pipeline,Tuple{Vararg{Operation}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
A SemanticWrapper determines the semantics of data that it wraps. | ||
Any subtype needs to implement function `unwrap(wrapper)` that returns the | ||
wrapped data. | ||
""" | ||
abstract type SemanticWrapper end | ||
|
||
""" | ||
Mask wraps a segmentation mask. | ||
""" | ||
struct Mask{AT<:AbstractArray} <: SemanticWrapper | ||
img::AT | ||
end | ||
|
||
""" | ||
unwrap(sw::SemanticWrapper) | ||
Returns the original object. | ||
""" | ||
unwrap(m::Mask) = m.img | ||
|
||
""" | ||
shouldapply(op, wrapper) | ||
shouldapply(typeof(op), typeof(wrapper)) | ||
Determines if operation `op` should be applied to semantic wrapper `wrapper`. | ||
""" | ||
shouldapply(op::Operation, what::SemanticWrapper) = shouldapply(typeof(op), typeof(what)) | ||
shouldapply(::Type{<:ImageOperation}, ::Type{<:SemanticWrapper}) = Val(true) | ||
shouldapply(::Type{<:ColorOperation}, ::Type{<:Mask}) = Val(false) | ||
# By default any operation is applicable to any semantic wrapper. Add new | ||
# methods to this function to define exceptions. | ||
|
||
# Allows doing `unwrap.(augment(img, Mask(img2), pl))` | ||
unwrap(A::AbstractArray) = A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.