Add multimodal support (llama.cpp) (#7027)

This commit is contained in:
oobabooga 2025-08-10 01:27:25 -03:00 committed by GitHub
parent eb16f64017
commit d86b0ec010
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 86 additions and 18 deletions

View file

@ -11,6 +11,15 @@ from PIL import Image
from modules.logging_colors import logger
def convert_pil_to_base64(image: Image.Image) -> str:
"""Converts a PIL Image to a base64 encoded string."""
buffered = io.BytesIO()
# Save image to an in-memory bytes buffer in PNG format
image.save(buffered, format="PNG")
# Encode the bytes to a base64 string
return base64.b64encode(buffered.getvalue()).decode('utf-8')
def decode_base64_image(base64_string: str) -> Image.Image:
"""Decodes a base64 string to a PIL Image."""
try: