(parsed_url: str)
| 102 | |
| 103 | |
| 104 | def load_base64_image(parsed_url: str) -> Image.Image: |
| 105 | data_spec, data = parsed_url.path.split(",", 1) |
| 106 | media_type, data_type = data_spec.split(";", 1) |
| 107 | |
| 108 | if data_type != "base64": |
| 109 | msg = "Only base64 data URLs are supported for now." |
| 110 | raise NotImplementedError(msg) |
| 111 | |
| 112 | content = base64.b64decode(data) |
| 113 | image = _load_and_convert_image(BytesIO(content)) |
| 114 | return image |
| 115 | |
| 116 | |
| 117 | def load_base64_image_embeds(str_content: str) -> torch.Tensor: |
no test coverage detected