Converts from a PIL image to a tensor.
(x)
| 18 | |
| 19 | |
| 20 | def from_pil_image(x): |
| 21 | """Converts from a PIL image to a tensor.""" |
| 22 | x = TF.to_tensor(x) |
| 23 | if x.ndim == 2: |
| 24 | x = x[..., None] |
| 25 | return x * 2 - 1 |
| 26 | |
| 27 | |
| 28 | def to_pil_image(x): |
nothing calls this directly
no outgoing calls
no test coverage detected