MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / image_to_nhwc

Function image_to_nhwc

tensorpack/callbacks/monitor.py:30–42  ·  view source on GitHub ↗
(arr)

Source from the content-addressed store, hash-verified

28
29
30def image_to_nhwc(arr):
31 if arr.ndim == 4:
32 pass
33 elif arr.ndim == 3:
34 if arr.shape[-1] in [1, 3, 4]:
35 arr = arr[np.newaxis, :]
36 else:
37 arr = arr[:, :, :, np.newaxis]
38 elif arr.ndim == 2:
39 arr = arr[np.newaxis, :, :, np.newaxis]
40 else:
41 raise ValueError("Array of shape {} is not an image!".format(arr.shape))
42 return arr
43
44
45class MonitorBase(Callback):

Callers 1

put_imageMethod · 0.85

Calls 1

formatMethod · 0.80

Tested by

no test coverage detected