From 57d737facc2e04c1beb01799b623d8107067bc25 Mon Sep 17 00:00:00 2001 From: chflame163 Date: Sat, 9 Nov 2024 00:40:46 +0800 Subject: [PATCH] Florence2 nodes support PromptGen-v2.0 --- README.MD | 1 + README_CN.MD | 1 + py/florence2_ultra.py | 14 +++++++++++++- pyproject.toml | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.MD b/README.MD index 81345e8..413eaed 100644 --- a/README.MD +++ b/README.MD @@ -150,6 +150,7 @@ Please try downgrading the ```protobuf``` dependency package to 3.20.3, or set e **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.
+* Florence2 nodes support base-PromptGen-v2.0 and large-PromptGen-v2.0, Download ```base-PromptGen-v2.0``` and ```large-PromptGen-v2.0``` two folder from [huggingface](https://huggingface.co/chflame163/ComfyUI_LayerStyle/tree/main/ComfyUI/models/florence2) or [BaiduNetdisk](https://pan.baidu.com/s/1BVvXt3N7zrBnToyF-GrC_A?pwd=xm0x) and copy to ```ComfyUI/models/florence2``` folder. * [SAM2Ultra](#SAM2Ultra) and ObjectDetector nodes support image batch. * [SAM2Ultra](#SAM2Ultra) and [SAM2VideoUltra](#SAM2VideoUltra) nodes add support for SAM2.1 model, including [kijai](https://github.com/kijai)'s FP16 model. Download model files from [BaiduNetdisk](https://pan.baidu.com/s/1xaQYBA6ktxvAxm310HXweQ?pwd=auki) or [huggingface.co/Kijai/sam2-safetensors](https://huggingface.co/Kijai/sam2-safetensors/tree/main) and copy to ```ComfyUI/models/sam2``` folder. * Commit [JoyCaption2Split](#JoyCaption2Split) and [LoadJoyCaption2Model](#LoadJoyCaption2Model) nodes, Sharing the model across multiple JoyCaption2 nodes improves efficiency. diff --git a/README_CN.MD b/README_CN.MD index 48a23d8..e7e7daa 100644 --- a/README_CN.MD +++ b/README_CN.MD @@ -127,6 +127,7 @@ If this call came from a _pb2.py file, your generated code is out of date and mu ## 更新说明 **如果本插件更新后出现依赖包错误,请双击运行插件目录下的```install_requirements.bat```(官方便携包),或 ```install_requirements_aki.bat```(秋叶整合包) 重新安装依赖包。 +* Florence2 节点更新支持 base-PromptGen-v2.0 和 large-PromptGen-v2.0 模型。从 [huggingface](https://huggingface.co/chflame163/ComfyUI_LayerStyle/tree/main/ComfyUI/models/florence2) 或 [BaiduNetdisk](https://pan.baidu.com/s/1BVvXt3N7zrBnToyF-GrC_A?pwd=xm0x) 下载 ```base-PromptGen-v2.0``` 和 ```large-PromptGen-v2.0``` 两个文件夹并复制到 ```ComfyUI/models/florence2```。 * [SAM2Ultra](#SAM2Ultra) 及 ObjectDetector 节点支持图像批次。 * [SAM2Ultra](#SAM2Ultra) 及 [SAM2VideoUltra](#SAM2VideoUltra) 节点增加支持SAM2.1模型,包括[kijai](https://github.com/kijai)量化版fp16模型。请从请从[百度网盘](https://pan.baidu.com/s/1xaQYBA6ktxvAxm310HXweQ?pwd=auki) 或者 [huggingface.co/Kijai/sam2-safetensors](https://huggingface.co/Kijai/sam2-safetensors/tree/main)下载模型文件并复制到```ComfyUI/models/sam2```文件夹。 * 添加 [JoyCaption2Split](#JoyCaption2Split) 和 [LoadJoyCaption2Model](#LoadJoyCaption2Model) 节点,在多个JoyCaption2节点时共用模型提高效率。 diff --git a/py/florence2_ultra.py b/py/florence2_ultra.py index 0833e89..b2ce915 100644 --- a/py/florence2_ultra.py +++ b/py/florence2_ultra.py @@ -23,7 +23,9 @@ "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", - "large-PromptGen-v1.5":"MiaoshouAI/Florence-2-large-PromptGen-v1.5" + "large-PromptGen-v1.5":"MiaoshouAI/Florence-2-large-PromptGen-v1.5", + "base-PromptGen-v2.0":"MiaoshouAI/Florence-2-base-PromptGen-v2.0", + "large-PromptGen-v2.0":"MiaoshouAI/Florence-2-large-PromptGen-v2.0" } def fixed_get_imports(filename) -> list[str]: @@ -322,6 +324,14 @@ def process_image(model, processor, image, task_prompt, max_new_tokens, num_beam task_prompt = '' result = run_example(model, processor, task_prompt, image, max_new_tokens, num_beams, do_sample) return result[task_prompt], None + elif task_prompt == 'mixed caption plus(PromptGen 2.0)': + task_prompt = '' + result = run_example(model, processor, task_prompt, image, max_new_tokens, num_beams, do_sample) + return result[task_prompt], None + elif task_prompt == 'analyze(PromptGen 2.0)': + task_prompt = '<>' + result = run_example(model, processor, task_prompt, image, max_new_tokens, num_beams, do_sample) + return result[task_prompt], None else: return "", None # Return empty string and None for unknown task prompts @@ -533,6 +543,8 @@ def INPUT_TYPES(s): 'description', 'generate tags(PromptGen 1.5)', 'mixed caption(PromptGen 1.5)', + 'mixed caption plus(PromptGen 2.0)', + 'analyze(PromptGen 2.0)', "object detection", "dense region caption", "region proposal", diff --git a/pyproject.toml b/pyproject.toml index 6e08cd8..927f6bd 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.88" +version = "1.0.89" license = "MIT" dependencies = ["numpy", "pillow", "torch", "matplotlib", "Scipy", "scikit_image", "scikit_learn", "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", "peft", "iopath"]