MCPcopy Create free account
hub / github.com/pytorch/tutorials / convert_image_np

Function convert_image_np

intermediate_source/spatial_transformer_tutorial.py:213–220  ·  view source on GitHub ↗

Convert a Tensor to numpy image.

(inp)

Source from the content-addressed store, hash-verified

211
212
213def convert_image_np(inp):
214 """Convert a Tensor to numpy image."""
215 inp = inp.numpy().transpose((1, 2, 0))
216 mean = np.array([0.485, 0.456, 0.406])
217 std = np.array([0.229, 0.224, 0.225])
218 inp = std * inp + mean
219 inp = np.clip(inp, 0, 1)
220 return inp
221
222# We want to visualize the output of the spatial transformers layer
223# after the training, we visualize a batch of input images and

Callers 1

visualize_stnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected