Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Either may not work properly with Pipeline #36

Closed
johnnychen94 opened this issue Dec 20, 2019 · 4 comments
Closed

Either may not work properly with Pipeline #36

johnnychen94 opened this issue Dec 20, 2019 · 4 comments
Assignees
Labels

Comments

@johnnychen94
Copy link
Collaborator

johnnychen94 commented Dec 20, 2019

For the following three seeming "equivalent" operations, the first one randomly changes the image size...

For img = testimage("cameraman"):

  • augment(img, Either(Rotate90()) |> FlipY()) returns image of size (512, 512) or (513, 512)
  • augment(img, Rotate90() |> FlipY()) returns image of size (512, 512)
  • augment(augment(img, Either(Rotate90())), FlipY()) returns image of size (512, 512)
@johnnychen94 johnnychen94 self-assigned this Dec 20, 2019
@johnnychen94
Copy link
Collaborator Author

Without any evidence, this issue might be related to the unrolling part of lazy operations in augment_impl.

A workaround is to insert a CacheImage operation after Either to "enforce eager mode", e.g., augment(img, Either(Rotate90()) |> CacheImage() |> FlipY())

@Evizero
Copy link
Owner

Evizero commented Jan 31, 2020

yea. Rotate90 and NoOp only share the affine option for lazy. and there is likely some rounding error when rotating

@barucden
Copy link
Collaborator

barucden commented Aug 9, 2021

I could not reproduce on the current master. Is it possible that it has been fixed?

julia> using Augmentor, TestImages

julia> img = TestImages.testimage("cameraman");

julia> a(img) = augment(img, Either(Rotate90()) |> FlipY())
a (generic function with 1 method)

julia> b(img) = augment(img, Rotate90() |> FlipY())
b (generic function with 1 method)

julia> c(img) = augment(augment(img, Either(Rotate90())), FlipY())
c (generic function with 1 method)

julia> unique!([size(a(img)) for i in 1:1000])
1-element Vector{Tuple{Int64, Int64}}:
 (512, 512)

julia> unique!([size(b(img)) for i in 1:1000])
1-element Vector{Tuple{Int64, Int64}}:
 (512, 512)

julia> unique!([size(c(img)) for i in 1:1000])
1-element Vector{Tuple{Int64, Int64}}:
 (512, 512)

@johnnychen94
Copy link
Collaborator Author

johnnychen94 commented Aug 9, 2021

Great! I didn't notice this was fixed but it might be related to the discretization trick in ImageTransformations: JuliaImages/ImageTransformations.jl#107 and JuliaImages/ImageTransformations.jl#114 This might only happen when the affine method is called. Another similar issue is #77

An upcoming change in ImageTransformations@v0.9 is JuliaImages/ImageTransformations.jl#143

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants