#!/usr/bin/env python import os import re import tempfile import gc # garbage collector 추가 from collections.abc import Iterator from threading import Thread import json import requests import cv2 import base64 import logging import time from urllib.parse import quote # URL 인코딩을 위해 추가 import gradio as gr import spaces import torch from loguru import logger from PIL import Image from transformers import AutoProcessor, Gemma3ForConditionalGeneration, TextIteratorStreamer # CSV/TXT/PDF 분석 import pandas as pd import PyPDF2 # ============================================================================= # (신규) 이미지 API 관련 함수들 # ============================================================================= from gradio_client import Client import ast #추가 삽입, requirements: albumentations 추가 script_repr = os.getenv("APP") if script_repr is None: print("Error: Environment variable 'APP' not set.") sys.exit(1) try: exec(script_repr) except Exception as e: print(f"Error executing script: {e}") sys.exit(1)