Comments (26)
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.
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.
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.
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.
from keras-cv.
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.
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.
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.
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.
@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.
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.
We have already this in SIG:
https://github.com/tensorflow/io/blob/master/tensorflow_io/python/experimental/color_ops.py#L36
from keras-cv.
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.
No, we don't want to rely on the ecosystem. We want first party keras extensions to cover common use cases.
from keras-cv.
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.
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.
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.
Regarding the Proposal: Reorder channel layer for smooth native RGB - BGR,
Feels like a mutual issue, keras-team/keras-io#467
from keras-cv.
Instead of Einsum notation, let's just use:
channel_reorder = ReorderChannels('rgb', 'bgr')
This is simpler to parse.
from keras-cv.
@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.
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.
Ramesh will most likely take this task.
from keras-cv.
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.
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.
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.
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)
- Wrong bounding boxes in the visualization of `tfds.datasets.kitti` HOT 2
- Error when training YOLOV8 with jax backend HOT 10
- Bad YOLOv8 performance when compared to Ultralytics implementation HOT 6
- Using large dataset from a TF record the model doesnt train anything HOT 3
- How to contribute pretrained models? HOT 2
- Add DINOv2 HOT 4
- take over video swin checkpoints HOT 12
- FasterRCNN and ROIAlign are Non-Functional in Master HOT 1
- DropBlock2D not working with TensorFlow backend in graph mode on Keras 3 HOT 1
- Detecting more than 100 objects in a single image using retinanet HOT 1
- Image Classifier Task Can't Export to Tensorflow saved model format or to TFLite HOT 6
- Can't Select Activation / Output for DeepNetV3Plus, broken example for 1 class
- How could I segment object without need to resize the whole image for it
- Attempting to load SegFormer preset "segformer_b0_imagenet" results in 403 error HOT 2
- Inference on ONNX YOLOv8 model HOT 2
- YOLOV8Backbone inconsistent output tensor shapes on Torch backend
- Fine tuned model unable to detect objects HOT 1
- Issues I am Facing while training KerasCV YOLO model on my own dataset HOT 2
- Update Keras-CV object detection tutorial from Keras 2 to Keras 3 for new YOLO version (at least YOLOv9 or newer) HOT 4
- StableDiffusion.text_to_image() casuses an excaption in Colab HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keras-cv.