# import spacy.cli # spacy.cli.download("ja_core_news_sm") # spacy.cli.download("zh_core_web_sm") import os os.environ["TF_USE_LEGACY_KERAS"] = "1" import spacy_udpipe spacy_udpipe.download("ja") spacy_udpipe.download("zh") from ui.layout import build_ui from logic.data_utils import load_concepts, load_metadata from config.settings import HF_API_TOKEN, HF_DATASET_NAME from retinaface import RetinaFace import numpy as np def warmup_face_detector(): """Warm up RetinaFace weights to avoid first-call latency.""" try: dummy = np.zeros((256, 256, 3), dtype=np.uint8) RetinaFace.detect_faces(dummy) except Exception as exc: # Avoid crashing app startup if warmup fails. print(f"[warmup] RetinaFace warmup failed: {exc}") warmup_face_detector() concepts = load_concepts() metadata = load_metadata() demo = build_ui(concepts, metadata, HF_API_TOKEN, HF_DATASET_NAME) demo.queue(max_size=30, default_concurrency_limit=3) # Enable queue system with max 30 requests # demo.launch() demo.launch(debug=False) demo.close() # gr.close_all()