Giter Club home page Giter Club logo

Comments (17)

LukeWood avatar LukeWood commented on July 29, 2024 2

Thanks @innat! I’ll take a look at this early next week.

from keras-cv.

bhack avatar bhack commented on July 29, 2024 1

We could port these from:
https://github.com/tensorflow/models/blob/master/official/vision/beta/ops/augment.py#L20

from keras-cv.

innat avatar innat commented on July 29, 2024

@LukeWood
The above implementation of mixup - cutmix should be the most optimized. Here is another implementation, a very basic starter of it. CutMix - MixUp.ipynb

rand_cutmix
download

rand_mixup
download

from keras-cv.

LukeWood avatar LukeWood commented on July 29, 2024

Began in PR #22

from keras-cv.

LukeWood avatar LukeWood commented on July 29, 2024

@bhack does label smoothing need to inherently be a part of MixUp & CutMix? (I'm not intimately familiar with the operations)

from keras-cv.

bhack avatar bhack commented on July 29, 2024

@LukeWood No but in the original papers they are using the label smoothing regularization as one of the experiment to improve the performance.

immagine

As you can see in the table Cutmix+Shakedrop has a better result in the original paper on CIFAR-100

We had Skaedrop in research at:
https://github.com/tensorflow/models/blob/master/research/autoaugment/shake_drop.py

Label smoothing is mainly from 2016:
https://arxiv.org/abs/1512.00567

As Cutmix (2019) was cited by other 940 papers now it is hard to understand what is a stable SOA.

Probably at API level we could try to design a pluggable composition for different regularizers if this is still a stable pattern in SOA.

from keras-cv.

LukeWood avatar LukeWood commented on July 29, 2024

Thanks for the info, I'll see if I can figure out exactly what we would want this layer to do.

Keras loss functions already smooth labels, so perhaps we don't need to accept labels as an argument regardless? https://www.tensorflow.org/api_docs/python/tf/keras/losses/BinaryCrossentropy

I'll do some further reading and look into everything the labels are used for internally.

from keras-cv.

bhack avatar bhack commented on July 29, 2024

Keras loss functions already smooth labels, so perhaps we don't need to accept labels as an argument regardless?

Do you need to apply the conditional at https://github.com/tensorflow/models/blob/master/official/vision/beta/ops/augment.py#L2219 ? I don't know if in the loss it is too late..

from keras-cv.

LukeWood avatar LukeWood commented on July 29, 2024

Ah Yeah, I think you are right.

One issue I am attempting to account for is composability. I.e.

preprocessing_model.add(RandomCrop())
preprocessing_model.add(RandomMixUp())

note randomCrop.call only receives images as an input, whereas right now RandomMixUp requires both images & labels. The standard is to only receive the x to a preprocessing layer, but if MixUp and CutMix require labels then maybe they’ll need to deviate from the standard a bit.

https://keras.io/guides/preprocessing_layers/

from keras-cv.

LukeWood avatar LukeWood commented on July 29, 2024

@mattdangerw are there any KPLS as of now that rely on label information?

from keras-cv.

bhack avatar bhack commented on July 29, 2024

I think the problem is that generally sample and label pair manipulation was more relegated to the tf.data API.
But here ware are going to manipulate sample a label pairs to create virtual and a sort of interclass samples.

from keras-cv.

bhack avatar bhack commented on July 29, 2024

E.g. check the dataset API example at:
https://keras.io/examples/vision/cutmix/

from keras-cv.

LukeWood avatar LukeWood commented on July 29, 2024

@bhack I went ahead and created PR #24 this morning. Since there's no way to avoid having to have two inputs & two outputs I went ahead and included label smoothing, with it disabled by default. I think this is a happy medium as it won't surprise users, but it's still an option. I'll create a RandomCutMix layer next.

from keras-cv.

LukeWood avatar LukeWood commented on July 29, 2024

Hey @bhack if you have any time a review here would be really helpful. Thanks, and no worries if you don't have the time!

from keras-cv.

mattdangerw avatar mattdangerw commented on July 29, 2024

@LukeWood no we don't have any preprocessing layers that depend on layer information. We do have a hashed crossing layer which takes multiple inputs as a tuple, but not really the same.

I am not sure if it would better to accept two separate inputs as you are doing in the PR currently, or to take in a single input that needs to be a (x, y) tuple.

Either way, doing this would restrict this layer to being something that needs to applied outside a model (e.g. a dataset.map), or to a subclassed model. I do not believe we have any way to access label data from layers inside a Functional/Sequential model.fit call. Though there has I believe been some discussion of it in the past (@fchollet might know more).

from keras-cv.

LukeWood avatar LukeWood commented on July 29, 2024

Perhaps a preprocessing model could be defined with an input for the labels as well here if the users want.

I am not sure if it would better to accept two separate inputs as you are doing in the PR currently, or to take in a single input that needs to be a (x, y) tuple.

thanks for the heads up, I updated it to take a tuple.

Though there has I believe been some discussion of it in the past (@fchollet might know more).

yeah there are some interesting regularization losses that actually require label information that would be great to be able to add from inside of Keras layers instead of just at the end of the model.

from keras-cv.

innat avatar innat commented on July 29, 2024

hey @LukeWood. Just to add two cents on this augmentation.

Currently, this aug can be applied to classification tasks but as the kerascv sets the target to general vision task, that's why to support vision tasks like object detection, we may need to add utility to accept the bbox_params argument too.

example of mixup-object-detection - region=full-images
image

example of mixup-object-detection - region=random
image

example of cutmix-object-detection
Screenshot 2022-01-08 214414

ref: https://www.kaggle.com/ankursingh12/data-augmentation-for-object-detection
ref: https://www.kaggle.com/shonenkov/oof-evaluation-mixup-efficientdet

from keras-cv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.