Args: clip (torch.tensor): Video clip to be normalized. Size is (T, C, H, W) mean (tuple): pixel RGB mean. Size is (3) std (tuple): pixel standard deviation. Size is (3) Returns: normalized clip (torch.tensor): Size is (T, C, H, W)
(clip, mean, std, inplace=False)
| 164 | |
| 165 | |
| 166 | def normalize(clip, mean, std, inplace=False): |
| 167 | """ |
| 168 | Args: |
| 169 | clip (torch.tensor): Video clip to be normalized. Size is (T, C, H, W) |
| 170 | mean (tuple): pixel RGB mean. Size is (3) |
| 171 | std (tuple): pixel standard deviation. Size is (3) |
| 172 | Returns: |
| 173 | normalized clip (torch.tensor): Size is (T, C, H, W) |
| 174 | """ |
| 175 | if not _is_tensor_video_clip(clip): |
| 176 | raise ValueError("clip should be a 4D torch.tensor") |
| 177 | if not inplace: |
| 178 | clip = clip.clone() |
| 179 | mean = torch.as_tensor(mean, dtype=clip.dtype, device=clip.device) |
| 180 | # print(mean) |
| 181 | std = torch.as_tensor(std, dtype=clip.dtype, device=clip.device) |
| 182 | clip.sub_(mean[:, None, None, None]).div_(std[:, None, None, None]) |
| 183 | return clip |
| 184 | |
| 185 | |
| 186 | def hflip(clip): |
no test coverage detected