(img)
| 209 | |
| 210 | |
| 211 | def to_numpy_array(img) -> np.ndarray: |
| 212 | if not is_valid_image(img): |
| 213 | raise ValueError(f"Invalid image type: {type(img)}") |
| 214 | |
| 215 | if is_vision_available() and isinstance(img, PIL.Image.Image): |
| 216 | return np.array(img) |
| 217 | return to_numpy(img) |
| 218 | |
| 219 | |
| 220 | def infer_channel_dimension_format( |
no test coverage detected