Conversation
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Also include ToNumpyD, ToNumpyDict, TorchVisionD, and TorchVisionDict Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
|
How about changing this: And then this: if isinstance(img, PILImage.Image):
return img
if isinstance(img, torch.Tensor):
img = img.detach().cpu().numpy()
return PILImage.fromarray(img)to this: if not has_pil:
raise RuntimeError("ToPIL requires pillow to be installed")
if isinstance(img, PILImage.Image):
return img
if isinstance(img, torch.Tensor):
img = img.detach().cpu().numpy()
return PILImage.fromarray(img)And then any tests can have the decorator added Is that what you're looking for? |
|
Your tests would also need to use |
thanks please add the relevant tests to this list: https://github.com/Project-MONAI/MONAI/blob/master/tests/min_tests.py#L29 so that they'll be skipped in the minimal test pipeline |
|
Thank you @rijobro and @wyli! |
|
It fails at load_submodule, where more submodules have error than ["monai.engines", "monai.handlers] Line 135 in 9ae3005 |
sorry it's incorrect. perhaps it's because of this |
@wyli, sure, but how it can solve the issue with MONAI/tests/test_pil_reader.py Line 18 in 9ae3005 |
could remove all type hints with |
Exactly, that's the problem. Does anyone know a better solution for this? which is not particular to PIL. It's a pity to remove type checking for this. @Nic-Ma @rijobro @wyli |
I fixed it by keeping type checking as follow: if TYPE_CHECKING:
from PIL.Image import Image as PILImageImage
from PIL.Image import fromarray as PILImageFromArray
has_pil = True
else:
PILImageFromArray, has_pil = optional_import("PIL.Image", name="fromarray")
PILImageImage, _ = optional_import("PIL.Image", name="Image") |
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Fixes #1638
Description
Add ToPIL and ToPILD along with the unittests
Status
Ready/Work in progress/Hold
Types of changes
./runtests.sh --codeformat --coverage../runtests.sh --quick.make htmlcommand in thedocs/folder.