import numpy as np import cv2 from PIL import Image, ImageEnhance from io import BytesIO from pdf2image import convert_from_path import json from gapi_client import get_genai_client from utils import extract_json_from_output # Global GenAI client CLIENT = None def init_genai(): """ Initialize the global GenAI client with the provided API key. """ global CLIENT CLIENT = get_genai_client() def parse_all_answers(image_input: Image.Image) -> str: """ Extracts answers from a full answer-sheet image using Gemini. Returns the raw JSON string from the model. """ output_format = ''' Answer in the following JSON format. Do not write anything else: { "Paper name": {"name": ""}, "Answers": { "1": "