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

integration with Flux #56

Open
CarloLucibello opened this issue Oct 13, 2021 · 2 comments
Open

integration with Flux #56

CarloLucibello opened this issue Oct 13, 2021 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@CarloLucibello
Copy link
Member

It would be helpful to add to the documentation an example of integration of DataAugmentation.jl in a pure Flux pipeline,
e.g. https://github.com/FluxML/model-zoo/blob/master/vision/vgg_cifar10/vgg_cifar10.jl

An alternative is to modify the model zoo example by adding data augmentation, which is quite standard on CIFAR10. If could do that if you can provide some indirections.

@lorenzoh
Copy link
Member

Most flexible way to drop DataAugmentation.jl into any workflow is to write a function that augments a single image and use that in the rest of the workflow. For example:

using DataAugmentation

function augmentimage(img, sz; augmentations = DataAugmentation.Identity())
    tfm = RandomResizeCrop(sz) |> augmentations
    return apply(tf, Image(img)) |> itemdata
end

How to integrate with the rest of the workflow depends on what other tools you're using, for example:

  • use in an iterator comprehension with Flux.DataLoader
  • mapobs over a data container and use with DataLoaders.DataLoader

Hope this helps, let me know if you need any other pointers.

@lorenzoh lorenzoh added the documentation Improvements or additions to documentation label Mar 13, 2022
@adrhill
Copy link
Collaborator

adrhill commented Feb 8, 2024

As far as I can tell, outputs of DataAugmentations.jl are in Images.jl's HWC (height, width, color-channels) format, whereas Flux generally recommends WHCN, e.g. in the Conv docstring:

Image data should be stored in WHCN order (width, height, channels, batch).

The pretrained models in Metalhead.jl also require inputs in WHCN format.

It would therefore be nice to have Transformations that:

  1. permute the height and width dimensions
  2. add a batch dimension

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

No branches or pull requests

3 participants