Spaces:
Sleeping
Sleeping
import numpy as np | |
import torch | |
def th2np(tensor): | |
if isinstance(tensor, np.ndarray): | |
return tensor | |
if isinstance(tensor, torch.Tensor): | |
return tensor.detach().cpu().numpy() | |