From 149fab21051696fe7f134a5459df2378097d2b5d Mon Sep 17 00:00:00 2001 From: yolain Date: Wed, 3 Apr 2024 19:36:08 +0800 Subject: [PATCH] add:if the huggingface connection timeout, it will switch to the mirrored address to download --- README.en.md | 4 +--- README.md | 8 +++++--- __init__.py | 2 +- py/libs/utils.py | 12 +++++++++++- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/README.en.md b/README.en.md index 4f4b753..7671d26 100644 --- a/README.en.md +++ b/README.en.md @@ -31,7 +31,7 @@ ## Changelog -**v1.1.2 (2024/3/25)** +**v1.1.2 (39c5ccf)** - Optimized some of the recommended nodes for slots related to EasyUse - Added **Enable ContextMenu Auto Nest Subdirectories** The setting item is enabled by default, and it can be classified into subdirectories, checkpoints and loras previews @@ -44,8 +44,6 @@ - Added `easy preMaskDetailerFix` - Fixed `easy stylesSelector` is change the prompt when not select the style -(4c25580) - - `easy kSamplerInpainting` add *additional* widget,you can choose 'Differential Diffusion' or 'Only InpaintModelConditioning' - Fixed `easy pipeEdit` error when add lora to prompt - Fixed layerDiffuse xyplot bug diff --git a/README.md b/README.md index 61a1d72..421a9e6 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,11 @@ ## 更新日志 -**v1.1.2 (2024/3/25)** +**v1.1.3 (2024/4/3)** + +- 增加 当节点需要下载模型时,若huggingface连接超时,会切换至镜像地址下载模型 + +**v1.1.2 (39c5ccf)** - 改写 EasyUse 相关节点的部分插槽推荐节点 - 增加 **启用上下文菜单自动嵌套子目录** 设置项,默认为启用状态,可分类子目录及checkpoints、loras预览图 @@ -48,8 +52,6 @@ - 增加 `easy preMaskDetailerFix` - 修复 `easy stylesSelector` 当未选择样式时,原有提示词发生了变化 -(4c25580) - - `easy kSamplerInpainting` 增加 *additional* 属性,可设置成 Differential Diffusion 或 Only InpaintModelConditioning - 修复 `easy pipeEdit` 提示词输入lora时报错 - 修复 layerDiffuse xyplot相关bug diff --git a/__init__.py b/__init__.py index 962a5fc..dd61fe6 100644 --- a/__init__.py +++ b/__init__.py @@ -85,4 +85,4 @@ WEB_DIRECTORY = "./web" __all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS', "WEB_DIRECTORY"] -print('\033[34mComfy-Easy-Use (v1.1.2): \033[92mLoaded\033[0m') \ No newline at end of file +print('\033[34mComfy-Easy-Use (v1.1.3): \033[92mLoaded\033[0m') \ No newline at end of file diff --git a/py/libs/utils.py b/py/libs/utils.py index f0b3c19..2a8a72d 100644 --- a/py/libs/utils.py +++ b/py/libs/utils.py @@ -134,7 +134,17 @@ def get_local_filepath(url, dirname, local_file_name=None): destination = os.path.join(dirname, local_file_name) if not os.path.exists(destination): print(f'downloading {url} to {destination}') - download_url_to_file(url, destination) + try: + download_url_to_file(url, destination) + except Exception as e: + args = e.args[0] if e.args is not None and len(e.args) > 0 else None + if isinstance(args, TimeoutError): + print(f'无法从 {url} 下载,正在尝试使用镜像地址...') + url = url.replace('huggingface.co', 'hf-mirror.com') + try: + download_url_to_file(url, destination) + except Exception as err: + raise Exception(f'无法从 {url} 下载,错误信息:{str(err.args[0])}') return destination def to_lora_patch_dict(state_dict: dict) -> dict: