4 / dvnc_patch_loader_example.py
Adi12345's picture
Create dvnc_patch_loader_example.py
73a267e verified
Raw
History Blame Contribute Delete
916 Bytes
"""
Example launcher that keeps the original code untouched.
Place this file alongside the existing app module and adjust the import path if needed.
Run this launcher instead of the original entry point.
"""
import importlib.util
import sys
from pathlib import Path
ORIGINAL_APP_PATH = Path("dvnc_ai_v2_hf/app.py")
PATCH_PATH = Path("dvnc_flip_insight_patch.py")
spec = importlib.util.spec_from_file_location("dvnc_original_app", ORIGINAL_APP_PATH)
mod = importlib.util.module_from_spec(spec)
sys.modules["dvnc_original_app"] = mod
spec.loader.exec_module(mod)
patch_spec = importlib.util.spec_from_file_location("dvnc_flip_insight_patch", PATCH_PATH)
patch = importlib.util.module_from_spec(patch_spec)
sys.modules["dvnc_flip_insight_patch"] = patch
patch_spec.loader.exec_module(patch)
patch.apply_patch(mod)
# If the original app exposes demo/launch objects, they remain on mod.
# Example: mod.demo.launch()