This package is a Quality of Life improvement when prototyping and processing Tensor objects from the pyTorch library.
The TensorType class is a Pipeline for preprocessing tensors automatically, and include multiple utility methods.
You can add TensorTypes together to have a longer preprocessing pipeline.
myTensorType + myOtherTensorType
For example, this code
fake_image = model(torch.unsqueeze(real_image, 0).cuda()).cpu().detach().numpy()
can be replaced by
fake_image = SingleDisplayableImage<<model(ModelInputFormat<<real_image)
All of these should be pretty telling by their name, if you know pyTorch.
TensorType.shape: the input will be viewed as this shape
TensorType.transforms: a list of functions that will be applied at the end
TorchType.to_batch: will unsqueeze the data into a batch with a single sample
TorchType.device: transfers the tensor to a device
TorchType.from_single_value: creates a uniform tensor from a single value
TorchType.random_values: creates a tensor from
TensorType.to_numpy: outputs a numpy array
TensorType.detach: detachs the tensor from the graph
from TTT import TensorType as TT