MCPcopy Index your code
hub / github.com/abetlen/llama-cpp-python / _load_image

Method _load_image

llama_cpp/llama_chat_format.py:3125–3137  ·  view source on GitHub ↗
(image_url: str)

Source from the content-addressed store, hash-verified

3123
3124 @staticmethod
3125 def _load_image(image_url: str) -> bytes:
3126 # TODO: Add Pillow support for other image formats beyond (jpg, png)
3127 if image_url.startswith("data:"):
3128 import base64
3129
3130 image_bytes = base64.b64decode(image_url.split(",")[1])
3131 return image_bytes
3132 else:
3133 import urllib.request
3134
3135 with urllib.request.urlopen(image_url) as f:
3136 image_bytes = f.read()
3137 return image_bytes
3138
3139 @staticmethod
3140 def get_image_urls(messages: List[llama_types.ChatCompletionRequestMessage]):

Callers 1

load_imageMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected