Load an image from the given file path or base64 encoded data. Args: image_path (str): The path to the image file or base64 encoded data. Returns: Image: The loaded image.
(self, image_path: str)
| 852 | ) |
| 853 | |
| 854 | def load_image(self, image_path: str): |
| 855 | """ |
| 856 | Load an image from the given file path or base64 encoded data. |
| 857 | |
| 858 | Args: |
| 859 | image_path (str): The path to the image file or base64 encoded data. |
| 860 | |
| 861 | Returns: |
| 862 | Image: The loaded image. |
| 863 | """ |
| 864 | try: |
| 865 | |
| 866 | image_data = base64.b64decode(image_path) |
| 867 | image = Image.open(io.BytesIO(image_data)) |
| 868 | return image |
| 869 | except Exception as e: |
| 870 | print(f"Error loading image {image_path}: {e}", file=sys.stderr) |
| 871 | return None |
| 872 | |
| 873 | def load_video(self, video_path: str): |
| 874 | """ |