question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reorder channel layer for smooth native RGB - BGR

See original GitHub issue

This is a commonly performed operation in image processing making it a good fit for keras-cv. While this is not a super complicated operation (it’s really just a lambda into a tf.gather) the resulting code is more readable. Let’s include this in keras-cv.

Originally discussed here: https://github.com/keras-team/keras/issues/15705

Re the design of the layer signature…

The current proposal is to implement a layer that looks like this:

rgb2bgr_layer = tf.keras.layers.ReorderChannel(order=[2, 1, 0], axis=-1)

Perhaps we actually may want to use a einsum inspired syntax, such as:

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

This would be really readable to anyone stumbling upon a new codebase, and generalizes quite well to any number of channels.

Please feel free to comment below with any additional thoughts

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:25 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
LukeWoodcommented, Jan 25, 2022

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.

1reaction
bhackcommented, Dec 8, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there any reason for changing the channels order of an ...
Specifically, if a neural network was trained in BGR ordering, if you loaded in images in RGB format then the reversal of the...
Read more >
GStreamer Plugin Details - NVIDIA Documentation Center
The low-level library (libnvds_infer) operates on any of INT8 RGB, BGR, or GRAY data with ... Specifies the data type and order for...
Read more >
Basic Image Processing In Python - Part 1 | Codementor
imread loads image as RGB (or RGBA), but OpenCV assumes the image to be BGR or BGRA (BGR is the default OpenCV colour...
Read more >
What is the difference between splitting an image in ... - Quora
Split : When you split an RGB (or BGR) image into its constituent channels, you get 3 images of equal size for each...
Read more >
AIC - River Thames Conditions - Environment Agency - GOV.UK
Charreaux 2000, Idtv rikstv samsung, Car change of ownership form download, ... Nathan milikowsky business, Taskar eason, Solid signal tv antenna, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found