"DEBUG"] = "0" os.environ[
๐บ View channels
from lovely_grad import monkey_patch
chans
chans (x:tinygrad.tensor.Tensor, cmap:str='twilight', cm_below:str='blue', cm_above:str='red', cm_ninf:str='cyan', cm_pinf:str='fuchsia', cm_nan:str='yellow', view_width:int=966, gutter_px:int=3, frame_px:int=1, scale:int=1, cl:Any=False, ax:Optional[matplotlib.axes._axes.Axes]=None)
Map tensor values to colors. RGB[A] color is added as channel-last
Type | Default | Details | |
---|---|---|---|
x | Tensor | Input, shape=([โฆ], H, W) | |
cmap | str | twilight | Use matplotlib colormap by this name |
cm_below | str | blue | Color for values below -1 |
cm_above | str | red | Color for values above 1 |
cm_ninf | str | cyan | Color for -inf values |
cm_pinf | str | fuchsia | Color for +inf values |
cm_nan | str | yellow | Color for NaN values |
view_width | int | 966 | Try to produce an image at most this wide |
gutter_px | int | 3 | Draw write gutters when tiling the images |
frame_px | int | 1 | Draw black frame around each image |
scale | int | 1 | |
cl | typing.Any | False | |
ax | typing.Optional[matplotlib.axes._axes.Axes] | None | |
Returns | ChanProxy |
= ( (0.485, 0.456, 0.406), (0.229, 0.224, 0.225) )
in_stats
= np.load("mysteryman.npy")
np_image = (np_image * np.array(in_stats[1])[:,None,None])
np_image += np.array(in_stats[0])[:,None,None]
np_image
= np_image.astype(np.float32)
np_image
= Tensor(np_image)
image
image.rgb
chans(image)
# In R
0,0:32,32:64] = -1.1 # Below min
np_image[0,0:32,96:128] = 1.1 # Above max
np_image[# In G
1,0:32,64:96] = float("nan")
np_image[# In B
2,0:32,0:32] = float("-inf")
np_image[2,0:32,128:128+32] = float("+inf")
np_image[
="viridis", cm_below="black", cm_above="white") chans(Tensor(np_image), cmap
# 4 images, stacked 2x2
*4).reshape(2,2,3,196,196)) chans(Tensor([np_image]