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.

Update low-level functional transforms with value_range

See original GitHub issue

Following https://github.com/pytorch/vision/pull/5500#discussion_r816599553 we may want to update low-level functional transforms with value_range argument to avoid implicit hard-coded max range definition:

  • 255 for uint8
  • 1.0 for float

Today this is done for

We can introduce new argument value_range and use it explicitly for these ops. In general we can think of value_range as a tuple (min, max) which would cover majority of imagery where channels ranges are similar. There could be however other type of images (e.g. think of non-RGB color spaces or particular imagery) where value ranges could vary per channel, thus we may need to represent value_range as a list of 2-tuples: [(min_1, max_1), (min_2, max_2), …]

cc @bjuncek @datumbox

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
vfdev-5commented, Mar 8, 2022

I think the reason is that torch script does not support global. We could do however something like:


def convert_image_dtype(image: torch.Tensor, dtype: torch.dtype = torch.float) -> torch.Tensor:

    # ...
    _max_values: Dict[torch.dtype, int] = {
        torch.uint8: 255,
        torch.int8: 127,
        torch.int16: int(2 ** 15),
        torch.int32: int(2 ** 31),
        torch.int64: int(2 ** 63),
        ...
    }

    input_max = _max_values[image.dtype]

@datumbox do you think it worth a change ?

EDIT: updated 256 -> 255

1reaction
datumboxcommented, Mar 10, 2022

I think we should close this for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transforming and augmenting images - PyTorch
Most transform classes have a function equivalent: functional transforms give fine-grained control over the transformations. This is useful if you have to ...
Read more >
ImageMagick Examples -- Image Transformations
The " -raise " operator is such a simple image transformation, ... 'N' means the function will go around the circle 'N' times...
Read more >
font-variation-settings - CSS: Cascading Style Sheets | MDN
The font-variation-settings CSS property provides low-level control over variable font characteristics, by specifying the four letter axis ...
Read more >
Examples - Palantir
Alternatively, you can define a more general low-level Transform and ... To define a high-level Transform , you define a compute function that...
Read more >
Transformations — navis 1.3.1 documentation
0, navis includes functions that let you transform and mirror spatial data (e.g. neurons). This new functionality broadly splits into high and low...
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