4 / app.py
Adi12345's picture
Create app.py
c43628a verified
Raw
History Blame Contribute Delete
889 Bytes
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")
def load_module(module_name: str, file_path: Path):
spec = importlib.util.spec_from_file_location(module_name, file_path)
if spec is None or spec.loader is None:
raise RuntimeError(f"Could not load module {module_name} from {file_path}")
module = importlib.util.module_from_spec(spec)
sys.modules[module_name] = module
spec.loader.exec_module(module)
return module
original_app = load_module("dvnc_original_app", ORIGINAL_APP_PATH)
patch_module = load_module("dvnc_flip_insight_patch", PATCH_PATH)
patch_module.apply_patch(original_app)
demo = getattr(original_app, "demo", None)
app = getattr(original_app, "app", None)
if __name__ == "__main__":
if demo is not None:
demo.launch()