MCPcopy Index your code
hub / github.com/Hunyuan-PromptEnhancer/PromptEnhancer / _load_image_bytes

Function _load_image_bytes

t2i_keypoints_eval.py:62–72  ·  view source on GitHub ↗

Return ``(raw_bytes, mime_type)`` for a remote URL or a local file path.

(image: str)

Source from the content-addressed store, hash-verified

60# Vision-language judge (Google Gemini official API)
61# --------------------------------------------------------------------------- #
62def _load_image_bytes(image: str) -> tuple[bytes, str]:
63 """Return ``(raw_bytes, mime_type)`` for a remote URL or a local file path."""
64 if image.startswith(("http://", "https://")):
65 resp = requests.get(image, timeout=60)
66 resp.raise_for_status()
67 mime_type = resp.headers.get("Content-Type") or guess_type(image)[0]
68 return resp.content, mime_type or "image/jpeg"
69
70 with open(image, "rb") as f:
71 data = f.read()
72 return data, guess_type(image)[0] or "image/jpeg"
73
74
75class GeminiJudge:

Callers 1

__call__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected