Return ``(raw_bytes, mime_type)`` for a remote URL or a local file path.
(image: str)
| 60 | # Vision-language judge (Google Gemini official API) |
| 61 | # --------------------------------------------------------------------------- # |
| 62 | def _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 | |
| 75 | class GeminiJudge: |