def get_controlnet_version() -> str:
    """Borrowed from sd-webui-controlnet/patch_version.py."""
    version_file = "scripts/controlnet_version.py"
    version_file_path = os.path.join(controlnet_extensions_path, version_file)
    if not os.path.exists(version_file_path):
        builtin_version_file_path = os.path.join(controlnet_extensions_builtin_path, version_file)
        if not os.path.exists(builtin_version_file_path):
            return "0.0.0"
        else:
            with open(builtin_version_file_path, "r") as f:
                content = f.read()
    else:
        with open(version_file_path, "r") as f:
            content = f.read()
    version_pattern = r"version_flag\s*=\s*'v(\d+\.\d+\.\d+)'"
    controlnet_version = re.search(version_pattern, content).group(1)

    return controlnet_version
Borrowed from sd-webui-controlnet/patch_version.py.
scripts/easyphoto_utils/common_utils.py