From 366cd886197037baf399ca6d7baa05f32008f4f3 Mon Sep 17 00:00:00 2001 From: chflame163 Date: Wed, 11 Sep 2024 18:50:58 +0800 Subject: [PATCH] florence2 nodes support MiaoshouAI/Florence-2-large-PromptGen-v1.5 and MiaoshouAI/Florence-2-base-PromptGen-v1.5 --- README.MD | 3 ++- README_CN.MD | 4 +++- py/birefnet_ultra_v2.py | 2 +- py/florence2_ultra.py | 3 ++- py/imagefunc.py | 2 +- pyproject.toml | 2 +- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.MD b/README.MD index aa9a249..2484af8 100644 --- a/README.MD +++ b/README.MD @@ -107,7 +107,8 @@ When this error has occurred, please check the network environment. ## Update **If the dependency package error after updating, please double clicking ```repair_dependency.bat``` (for Official ComfyUI Protable) or ```repair_dependency_aki.bat``` (for ComfyUI-aki-v1.x) in the plugin folder to reinstall the dependency packages.
- +* [Florence2Ultra](#Florence2Ultra), [Florence2Image2Prompt](#Florence2Image2Prompt) 和 [LoadFlorence2Model](#LoadFlorence2Model) nodes support the MiaoshouAI/Florence-2-large-PromptGen-v1.5 and MiaoshouAI/Florence-2-base-PromptGen-v1.5 model. +Download model files from [BaiduNetdisk](https://pan.baidu.com/s/1xOL6x6LijIMSh_3woErjJg?pwd=t3xa) or [huggingface.co/MiaoshouAI/Florence-2-large-PromptGen-v1.5](https://huggingface.co/MiaoshouAI/Florence-2-large-PromptGen-v1.5/tree/main) and [huggingface.co/MiaoshouAI/Florence-2-base-PromptGen-v1.5](https://huggingface.co/MiaoshouAI/Florence-2-base-PromptGen-v1.5/tree/main) , copy to ```ComfyUI\models\florence2``` folder. * Commit [BiRefNetUltraV2](#BiRefNetUltraV2) and [LoadBiRefNetModel](#LoadBiRefNetModel) nodes, that support the use of the latest BiRefNet model. Download model file from [BaiduNetdisk](https://pan.baidu.com/s/12z3qUuqag3nqpN2NJ5pSzg?pwd=ek65) or [GoogleDrive](https://drive.google.com/drive/folders/1s2Xe0cjq-2ctnJBR24563yMSCOu4CcxM) named ```BiRefNet-general-epoch_244.pth``` to ```ComfyUI/Models/BiRefNet/pth``` folder. You can also download more BiRefNet models and put them here. * [ExtendCanvasV2](#ExtendCanvasV2) node support negative value input, it means image will be cropped. diff --git a/README_CN.MD b/README_CN.MD index 5085194..608771f 100644 --- a/README_CN.MD +++ b/README_CN.MD @@ -102,13 +102,15 @@ git clone https://github.com/chflame163/ComfyUI_LayerStyle.git * 在ComfyUI画布点击右键 - Add Node, 找到 "😺dzNodes"。 ![image](image/node-menu.jpg) -* 或者在ComfyUI画布双击, 在搜索框输入"layer"。 +* 或者在ComfyUI画布双击, 在搜索框输入"layer"。Florence2Image2Prompt ![image](image/node-search.jpg) ## 更新说明 **如果本插件更新后出现依赖包错误,请双击运行插件目录下的```install_requirements.bat```(官方便携包),或 ```install_requirements_aki.bat```(秋叶整合包) 重新安装依赖包。 +* [Florence2Ultra](#Florence2Ultra), [Florence2Image2Prompt](#Florence2Image2Prompt) 和 [LoadFlorence2Model](#LoadFlorence2Model) 节点支持MiaoshouAI/Florence-2-large-PromptGen-v1.5 和 MiaoshouAI/Florence-2-base-PromptGen-v1.5 模型。 +请从[百度网盘](https://pan.baidu.com/s/1xOL6x6LijIMSh_3woErjJg?pwd=t3xa) 或者 [huggingface.co/MiaoshouAI/Florence-2-large-PromptGen-v1.5](https://huggingface.co/MiaoshouAI/Florence-2-large-PromptGen-v1.5/tree/main) 以及[huggingface.co/MiaoshouAI/Florence-2-base-PromptGen-v1.5](https://huggingface.co/MiaoshouAI/Florence-2-base-PromptGen-v1.5/tree/main) 下载全部模型文件并放到 ```ComfyUI\models\florence2```文件夹。 * 添加 [BiRefNetUltraV2](#BiRefNetUltraV2) 和 [LoadBiRefNetModel](#LoadBiRefNetModel) 节点,支持使用最新的BiRefNet模型。 从[百度网盘](https://pan.baidu.com/s/12z3qUuqag3nqpN2NJ5pSzg?pwd=ek65) 或 [GoogleDrive](https://drive.google.com/drive/folders/1s2Xe0cjq-2ctnJBR24563yMSCOu4CcxM) 下载 ```BiRefNet-general-epoch_244.pth``` 到 ComfyUI/Models/BiRefNet/pth 文件夹。也可以下载更多的BiRefNet模型放到这里。 * [ExtendCanvasV2](#ExtendCanvasV2) 节点支持负值输入,负值将被裁剪。 diff --git a/py/birefnet_ultra_v2.py b/py/birefnet_ultra_v2.py index 76ccf4f..883b7e3 100644 --- a/py/birefnet_ultra_v2.py +++ b/py/birefnet_ultra_v2.py @@ -45,7 +45,7 @@ class LS_LoadBiRefNetModel: from .BiRefNet.utils import check_state_dict model_dict = get_models() self.birefnet = BiRefNet(bb_pretrained=False) - self.state_dict = torch.load(model_dict[model], map_location='cpu') + self.state_dict = torch.load(model_dict[model], map_location='cpu', weights_only=True) self.state_dict = check_state_dict(self.state_dict) self.birefnet.load_state_dict(self.state_dict) return (self.birefnet,) diff --git a/py/florence2_ultra.py b/py/florence2_ultra.py index fe0fc47..4a8b339 100644 --- a/py/florence2_ultra.py +++ b/py/florence2_ultra.py @@ -22,7 +22,8 @@ fl2_model_repos = { "base-PromptGen": "MiaoshouAI/Florence-2-base-PromptGen", "CogFlorence-2-Large-Freeze": "thwri/CogFlorence-2-Large-Freeze", "CogFlorence-2.1-Large": "thwri/CogFlorence-2.1-Large", - "base-PromptGen-v1.5":"MiaoshouAI/Florence-2-base-PromptGen-v1.5" + "base-PromptGen-v1.5":"MiaoshouAI/Florence-2-base-PromptGen-v1.5", + "large-PromptGen-v1.5":"MiaoshouAI/Florence-2-large-PromptGen-v1.5" } diff --git a/py/imagefunc.py b/py/imagefunc.py index 8782d88..cdb6fd1 100644 --- a/py/imagefunc.py +++ b/py/imagefunc.py @@ -1405,7 +1405,7 @@ def load_RMBG_model(): model_path = os.path.join(folder_paths.models_dir, "rmbg", "RMBG-1.4", "model.pth") if not os.path.exists(model_path): model_path = os.path.join(os.path.dirname(current_directory), "RMBG-1.4", "model.pth") - net.load_state_dict(torch.load(model_path, map_location=device)) + net.load_state_dict(torch.load(model_path, map_location=device, weights_only=True)) net.to(device) net.eval() return net diff --git a/pyproject.toml b/pyproject.toml index e85c3b7..bc84b63 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui_layerstyle" description = "A set of nodes for ComfyUI it generate image like Adobe Photoshop's Layer Style. the Drop Shadow is first completed node, and follow-up work is in progress." -version = "1.0.52" +version = "1.0.53" license = "MIT" dependencies = ["numpy", "pillow", "torch", "matplotlib", "Scipy", "scikit_image", "opencv-contrib-python", "pymatting", "segment_anything", "timm", "addict", "yapf", "colour-science", "wget", "mediapipe", "loguru", "typer_config", "fastapi", "rich", "google-generativeai", "diffusers", "omegaconf", "tqdm", "transformers", "kornia", "image-reward", "ultralytics", "blend_modes", "blind-watermark", "qrcode", "pyzbar", "transparent-background", "huggingface_hub", "accelerate", "bitsandbytes", "torchscale", "wandb", "hydra-core", "psd-tools", "inference-cli[yolo-world]", "inference-gpu[yolo-world]", "onnxruntime"]