MCPcopy Create free account
hub / github.com/Alibaba-NLP/ViDoRAG / _encode_image

Function _encode_image

llms/llm.py:10–19  ·  view source on GitHub ↗
(image_path)

Source from the content-addressed store, hash-verified

8
9
10def _encode_image(image_path):
11 if isinstance(image_path,Image.Image):
12 buffered = io.BytesIO()
13 image_path.save(buffered, format="JPEG")
14 img_data = buffered.getvalue()
15 base64_encoded = base64.b64encode(img_data).decode("utf-8")
16 return base64_encoded
17 else:
18 with open(image_path, "rb") as image_file:
19 return base64.b64encode(image_file.read()).decode("utf-8")
20
21class Qwen_VL_2_5:
22 def __init__(self, model_name="Qwen/Qwen2.5-VL-7B-Instruct"):

Callers 1

generateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected