import sys import os # Add the current directory to sys.path so we can import backend sys.path.append(os.getcwd()) print("Importing backend.model_handler...", flush=True) from backend.model_handler import model_handler print("\nChecking model states...", flush=True) errors = [] if model_handler.model_int is not None: errors.append("InternVL model should be None on startup") else: print("PASS: InternVL model is None") if model_handler.tokenizer_int is not None: errors.append("InternVL tokenizer should be None on startup") else: print("PASS: InternVL tokenizer is None") if model_handler.reader is not None: errors.append("EasyOCR reader should be None on startup") else: print("PASS: EasyOCR reader is None") if model_handler.model_clip is not None: errors.append("CLIP model should be None on startup") else: print("PASS: CLIP model is None") if model_handler.processor_clip is not None: errors.append("CLIP processor should be None on startup") else: print("PASS: CLIP processor is None") if errors: print("\nFAILED:", flush=True) for error in errors: print(f"- {error}", flush=True) sys.exit(1) else: print("\nSUCCESS: All models are lazily loaded.", flush=True) sys.exit(0)