Giter Site home page Giter Site logo

Comments (26)

bhack avatar bhack commented on August 20, 2024 1

This seems only about reordering but more in general we have many colorspace conversions in:

https://github.com/tensorflow/io/blob/v0.20.0/tensorflow_io/python/experimental/color_ops.py#L20

from keras-cv.

LukeWood avatar LukeWood commented on August 20, 2024 1

I'd be fond of the API:

rgb2bgr_layer = keras_cv.layers.ReorderChannel('rgb->bgr', axis=-1)

I think we could include this if someone wanted to contribute it.

from keras-cv.

piEsposito avatar piEsposito commented on August 20, 2024

I see. The idea here is to enable BGR-RGB conversion on the model serving bundle, so we don't have to manipulate images "by hand" when serving it in any scenario.

from keras-cv.

bhack avatar bhack commented on August 20, 2024

I understand that this is at Keras layer level implementation but about lowlevel reusable components Remember that we had already another color space overlapping other then with Tensorflow IO SIG also with TF Graphics:

tensorflow/graphics#107
https://www.tensorflow.org/graphics/api_docs/python/tfg/image/color_space

from keras-cv.

piEsposito avatar piEsposito commented on August 20, 2024

from keras-cv.

bhack avatar bhack commented on August 20, 2024

I see. In that case, that’s just me trying to export and deploy my models
without rechanneling my images out of the model.

I understand and it could be useful here. The only problem that I want to highlight is that I prefer to not going again to have a proliferation/duplication of low level ops/API in every SIG.

from keras-cv.

piEsposito avatar piEsposito commented on August 20, 2024

I agree with you. What do you think would be the best solution for that? I think that we should have a keras layer for that, but avoiding redundancy of implementations :D.

from keras-cv.

LukeWood avatar LukeWood commented on August 20, 2024

If the parsing of the einsum notation is too verbose/unreadable, we can just have it work like a transpose op where you pass the channel ordering in a list.

from keras-cv.

ariG23498 avatar ariG23498 commented on August 20, 2024

Hey folks,

The RGB-BGR operation is very easily possible with the tf.keras.layers.Permute. Would we want to wrap with with the einsum notation as suggested by @LukeWood?

from keras-cv.

LukeWood avatar LukeWood commented on August 20, 2024

@ariG23498, could you post an example of RGB->BGR w/ permute? Thanks! I believe Francois thought this layer would be useful, maybe we can just have some examples showing how to use permute though if it’s possible.

from keras-cv.

ariG23498 avatar ariG23498 commented on August 20, 2024

Hey @LukeWood
I was wrong with my thoughts. Permute is a useful layer for converting between channel_first and channel_last. I apologize for my comment earlier.

The layer that I am thinking of should be structured like this.

rgb_bgr_layer = keras.layers.Lambda(function=lambda x: x[..., -1::-1])

WDYT?

from keras-cv.

bhack avatar bhack commented on August 20, 2024

We have already this in SIG:

https://github.com/tensorflow/io/blob/master/tensorflow_io/python/experimental/color_ops.py#L36

from keras-cv.

bhack avatar bhack commented on August 20, 2024

If we don't want to depend on ecosystem we could just try to copy and adopt these ops chain in layers or in our private API.

from keras-cv.

LukeWood avatar LukeWood commented on August 20, 2024

No, we don't want to rely on the ecosystem. We want first party keras extensions to cover common use cases.

from keras-cv.

bhack avatar bhack commented on August 20, 2024

It is what I have suggested. I think copy these in private api in a colorspace utils file it could be useful.
E.g. If in another layer you need to do something more than color conversion or in visualizzation it could be still useful to have as an API other then only embedded as a layer componet.

from keras-cv.

LukeWood avatar LukeWood commented on August 20, 2024

I don't think we need to copy these utils as I think we want to do something distinct. This is a generic ReorderChannels layer. It will take an arbitrary ordering and return a new one. The linked function only does RGB->BGR.

from keras-cv.

bhack avatar bhack commented on August 20, 2024

I think that they do more as If you see the whole file they are covering also many color space conversions that It is more than just channel reordering (unstack, stack):

rgb2bgr_layer = tf.keras.layers.ReorderChannel('rgb->bgr', axis=-1)

But probably we are not interested to have other colorspace transformations.

from keras-cv.

innat avatar innat commented on August 20, 2024

Regarding the Proposal: Reorder channel layer for smooth native RGB - BGR,

Feels like a mutual issue, keras-team/keras-io#467

from keras-cv.

LukeWood avatar LukeWood commented on August 20, 2024

Instead of Einsum notation, let's just use:

channel_reorder = ReorderChannels('rgb', 'bgr')

This is simpler to parse.

from keras-cv.

innat avatar innat commented on August 20, 2024

@LukeWood @bhack
If it's only about rgb-bgr transformation, why if we just include tf.image.rgb_to_bgr function - like we have tf.image.rgb_to_grayscale, tf.image.yuv_to_rgb?

from keras-cv.

LukeWood avatar LukeWood commented on August 20, 2024

It's an arbitrary transformation regarding the ordering of channels.

If we want to include RGBtoGrayscale that would probably need to be it's own layer, same with yuv_to_rgb. These are more complex transformations than a simple permutation shift. Feel free to open an issue for RGBtoGrayscale layer. Not so sure about yuv_to_rgb, but if the community shows need for it we can include it.

from keras-cv.

LukeWood avatar LukeWood commented on August 20, 2024

Ramesh will most likely take this task.

from keras-cv.

piEsposito avatar piEsposito commented on August 20, 2024

I think reorder channels would have a more general purpose, so we could build that and on top of that the rgb to bgr to rgb transformations.

from keras-cv.

innat avatar innat commented on August 20, 2024

Yes, it should be general-purpose. It should support the basic color transformations listed here https://github.com/tensorflow/io/blob/master/tensorflow_io/python/experimental/color_ops.py

(shouldn't be limited to rgb/bgr, IMO)

channel_reorder = ReorderChannels(format='rgb_to_bgr')( tensor )
channel_reorder = ReorderChannels(format='rgb_to_rgba')( tensor )
channel_reorder = ReorderChannels(format='bgr_to_rgb')( tensor )
channel_reorder = ReorderChannels(format='rgb_to_ycbcr')( tensor )
...

from keras-cv.

LukeWood avatar LukeWood commented on August 20, 2024

sure, as far as implementation goes maybe a

channel_reorder = ReorderChannels(from='rgb', to='ycbcr')( tensor )

makes more sense. In this case, the layer is more of a FormatChange than a ReorderChannels

from keras-cv.

LukeWood avatar LukeWood commented on August 20, 2024

Does not seem like this is a priority on the immediate roadmap - might as well close until theres a strong need.

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.