MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / ToPIL

Class ToPIL

monai/transforms/utility/array.py:553–568  ·  view source on GitHub ↗

Converts the input image (in the form of NumPy array or PyTorch Tensor) to PIL image

Source from the content-addressed store, hash-verified

551
552
553class ToPIL(Transform):
554 """
555 Converts the input image (in the form of NumPy array or PyTorch Tensor) to PIL image
556 """
557
558 backend = [TransformBackends.NUMPY]
559
560 def __call__(self, img):
561 """
562 Apply the transform to `img`.
563 """
564 if isinstance(img, PILImageImage):
565 return img
566 if isinstance(img, torch.Tensor):
567 img = img.detach().cpu().numpy()
568 return pil_image_fromarray(img)
569
570
571class Transpose(Transform):

Callers 2

__init__Method · 0.90
test_valueMethod · 0.90

Calls

no outgoing calls

Tested by 1

test_valueMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…