Converts from a tensor to a PIL image.
(x)
| 26 | |
| 27 | |
| 28 | def to_pil_image(x): |
| 29 | """Converts from a tensor to a PIL image.""" |
| 30 | if x.ndim == 4: |
| 31 | assert x.shape[0] == 1 |
| 32 | x = x[0] |
| 33 | if x.shape[0] == 1: |
| 34 | x = x[0] |
| 35 | return TF.to_pil_image((x.clamp(-1, 1) + 1) / 2) |
| 36 | |
| 37 | |
| 38 | def hf_datasets_augs_helper(examples, transform, image_key, mode='RGB'): |
nothing calls this directly
no outgoing calls
no test coverage detected