Spaces:
Runtime error
Runtime error
import base64 | |
from io import BytesIO | |
# pip3 install pillow | |
from PIL import Image | |
import re | |
def base64_to_image(base64_str): | |
base64_data = re.sub('^data:image/.+;base64,', '', base64_str) | |
byte_data = base64.b64decode(base64_data) | |
image_data = BytesIO(byte_data) | |
img = Image.open(image_data) | |
return img | |