lovely-numpy icon indicating copy to clipboard operation
lovely-numpy copied to clipboard

Feature: Support denorm=True in fig_rgb

Open pallgeuer opened this issue 3 months ago • 13 comments

Here is the current code from repr_rgb.py:

    if denorm:
        means = np.array(denorm[0])
        stds = np.array(denorm[1])
        x = x * stds + means

It would be helpful I think if checking denorm is True makes the default ImageNet values get used for the normalization:

((0.485, 0.456, 0.406),    # mean
 (0.229, 0.224, 0.225))    # std

This way during debugging (while moving in and out of many functions/scopes) you don't need to constantly worry about the denormalization stats being defined and available all the time. Just:

x.rgb(denorm=True).fig  # OR...
x.rgb(True).fig

Alternatively a config could be used to store the default normalization stats to use for denorm=True. Custom normalization stats can still be passed exactly as before using e.g. .rgb(in_stats).

pallgeuer avatar Oct 13 '25 12:10 pallgeuer