MCPcopy Create free account
hub / github.com/CompVis/zigma / to_tensor

Function to_tensor

datasets/video_utils.py:148–163  ·  view source on GitHub ↗

Convert tensor data type from uint8 to float, divide value by 255.0 and permute the dimensions of clip tensor Args: clip (torch.tensor, dtype=torch.uint8): Size is (T, C, H, W) Return: clip (torch.tensor, dtype=torch.float): Size is (T, C, H, W)

(clip)

Source from the content-addressed store, hash-verified

146
147
148def to_tensor(clip):
149 """
150 Convert tensor data type from uint8 to float, divide value by 255.0 and
151 permute the dimensions of clip tensor
152 Args:
153 clip (torch.tensor, dtype=torch.uint8): Size is (T, C, H, W)
154 Return:
155 clip (torch.tensor, dtype=torch.float): Size is (T, C, H, W)
156 """
157 _is_tensor_video_clip(clip)
158 if not clip.dtype == torch.uint8:
159 raise TypeError(
160 "clip tensor should have data type uint8. Got %s" % str(clip.dtype)
161 )
162 # return clip.float().permute(3, 0, 1, 2) / 255.0
163 return clip.float() / 255.0
164
165
166def normalize(clip, mean, std, inplace=False):

Callers 1

__call__Method · 0.85

Calls 1

_is_tensor_video_clipFunction · 0.85

Tested by

no test coverage detected