Skip to content

Instantly share code, notes, and snippets.

@max-unfinity
max-unfinity / show_tensor_script.py
Created August 10, 2023 07:00
Convenient function for visualizing tensors of any format
import numpy as np
import torch
import torchvision
from matplotlib import pyplot as plt
# from PIL import Image
def show_tensor(
tensor,
@max-unfinity
max-unfinity / show_tensor.py
Last active May 22, 2023 12:00
Convenient function for visualizing tensors of any shape, supports batch_size.
import numpy as np
import torch
import torchvision
from matplotlib import pyplot as plt
# from PIL import Image
def show_tensor(tensor, transpose=None, normalize=None, figsize=(10,10), nrow=None, padding=2, verbose=True, **kwargs):
"""Convenient function for visualizing tensors of any shape, supports batch_size."""
if not isinstance(tensor, torch.Tensor):