├── requirements.txt ├── models └── PIP_ClassV1 │ ├── training_args.bin │ ├── all_results.json │ ├── preprocessor_config.json │ └── config.json ├── __init__.py ├── pyproject.toml ├── .github └── workflows │ └── publish.yml ├── README.md ├── PIP_Class.py ├── PIP_Class_Advanced.py ├── base.json └── workflow ├── 基础版.json └── 高级版json.json /requirements.txt: -------------------------------------------------------------------------------- 1 | transformers>=4.0.0 2 | torch>=1.7.0 3 | Pillow>=8.0.0 -------------------------------------------------------------------------------- /models/PIP_ClassV1/training_args.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenpipi0807/Comfyui_PIP_Class/HEAD/models/PIP_ClassV1/training_args.bin -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- 1 | from .PIP_Class import PIPClass 2 | from .PIP_Class_Advanced import PIPClassAdvanced 3 | 4 | NODE_CLASS_MAPPINGS = { 5 | "PIPClass": PIPClass, 6 | "PIPClassAdvanced": PIPClassAdvanced 7 | } 8 | 9 | NODE_DISPLAY_NAME_MAPPINGS = { 10 | "PIPClass": "PIP 图像分类", 11 | "PIPClassAdvanced": "PIP 图像分类高级版" 12 | } 13 | 14 | __all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] 15 | -------------------------------------------------------------------------------- /models/PIP_ClassV1/all_results.json: -------------------------------------------------------------------------------- 1 | { 2 | "epoch": 45.16, 3 | "eval_accuracy": 0.9354838709677419, 4 | "eval_loss": 0.13194797933101654, 5 | "eval_runtime": 0.5596, 6 | "eval_samples_per_second": 55.396, 7 | "eval_steps_per_second": 14.296, 8 | "train_loss": 0.11627865114382335, 9 | "train_runtime": 212.3619, 10 | "train_samples_per_second": 28.725, 11 | "train_steps_per_second": 1.648 12 | } -------------------------------------------------------------------------------- /models/PIP_ClassV1/preprocessor_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "do_normalize": true, 3 | "do_rescale": true, 4 | "do_resize": true, 5 | "image_mean": [ 6 | 0.5, 7 | 0.5, 8 | 0.5 9 | ], 10 | "image_processor_type": "ViTImageProcessor", 11 | "image_std": [ 12 | 0.5, 13 | 0.5, 14 | 0.5 15 | ], 16 | "resample": 2, 17 | "rescale_factor": 0.00392156862745098, 18 | "size": { 19 | "height": 224, 20 | "width": 224 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "comfyui_pip_class" 3 | description = "A ComfyUI custom node that provides advanced class-based operations for image processing workflows." 4 | version = "1.0.0" 5 | license = {text = "MIT"} 6 | dependencies = ["transformers"] 7 | 8 | [project.urls] 9 | Repository = "https://github.com/chenpipi0807/Comfyui_PIP_Class" 10 | # Used by Comfy Registry https://comfyregistry.org 11 | 12 | [tool.comfy] 13 | PublisherId = "" 14 | DisplayName = "ComfyUI PIP Class" 15 | Icon = "" 16 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish to Comfy registry 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: 6 | - main 7 | - master 8 | paths: 9 | - "pyproject.toml" 10 | 11 | permissions: 12 | issues: write 13 | 14 | jobs: 15 | publish-node: 16 | name: Publish Custom Node to registry 17 | runs-on: ubuntu-latest 18 | if: ${{ github.repository_owner == 'chenpipi0807' }} 19 | steps: 20 | - name: Check out code 21 | uses: actions/checkout@v4 22 | with: 23 | submodules: true 24 | - name: Publish Custom Node 25 | uses: Comfy-Org/publish-node-action@v1 26 | with: 27 | ## Add your own personal access token to your Github Repository secrets and reference it here. 28 | personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }} 29 | -------------------------------------------------------------------------------- /models/PIP_ClassV1/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "architectures": [ 3 | "ViTForImageClassification" 4 | ], 5 | "attention_probs_dropout_prob": 0.0, 6 | "encoder_stride": 16, 7 | "hidden_act": "gelu", 8 | "hidden_dropout_prob": 0.0, 9 | "hidden_size": 768, 10 | "id2label": { 11 | "0": "Anime", 12 | "1": "NoHuman", 13 | "2": "RealPeople" 14 | }, 15 | "image_size": 224, 16 | "initializer_range": 0.02, 17 | "intermediate_size": 3072, 18 | "label2id": { 19 | "Anime": "0", 20 | "NoHuman": "1", 21 | "RealPeople": "2" 22 | }, 23 | "layer_norm_eps": 1e-12, 24 | "model_type": "vit", 25 | "num_attention_heads": 12, 26 | "num_channels": 3, 27 | "num_hidden_layers": 12, 28 | "patch_size": 16, 29 | "problem_type": "single_label_classification", 30 | "qkv_bias": true, 31 | "torch_dtype": "float32", 32 | "transformers_version": "4.36.0" 33 | } 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | --- 2 | PIPClass 图像分类节点 3 | PIPClass是一个基于ViT(Vision Transformer)模型的Python类,专为图像分类设计。它不仅可以快速识别图像中的内容,还能提供详细的分类得分,帮助用户更好地理解模型的判断依据。 4 | PIP_ClassV1 模型是基于ViT-B/16预训练模型,在动漫、非人类(动物/场景/几何图形)、真人、三个类别上进行全量微调训练。 5 | 该模型在300张各类图片中做过批量测试,准确率大约90%。 6 | 7 | 我寻思独乐了不如众乐乐,完了我就整了个能加载大多数VIT模型的玩意出来,反正这玩意结构也差不太多,好像现在还没人这么整呢,至少我没发现。 8 | 当然如果你微调了vit模型又懒得写节点,那你直接用这玩意也行。 9 | 理论上你知道要把模型文件夹胡楞个的扔进models里就行了 10 | 11 | ### 主要功能 12 | 1. **图像分类**:利用预训练的ViT模型,PIPClass可以准确地对输入的图像进行分类,返回最可能的类别。 13 | 2. **自定义模型路径**:用户可以指定模型路径来加载自定义的训练模型,增加了模型的灵活性和适用范围。 14 | 3. **图像预处理**:自动对输入的图像进行中心裁剪和调整大小,确保图像符合模型的输入要求,从而提高分类的准确性(目前尺寸为224x224)。 15 | 16 | ![微信截图_20241129125450](https://github.com/user-attachments/assets/dcc69b73-49f0-41f1-9da8-4f820c8e40f7) 17 | 18 | ![微信截图_20241127163951](https://github.com/user-attachments/assets/448b6580-2ce2-406d-a9c8-4c5395e64ebf) 19 | ![微信截图_20241127163939](https://github.com/user-attachments/assets/fe666fa8-fa74-48d5-98fc-fb5c6dc3fbed) 20 | ![微信截图_20241127163900](https://github.com/user-attachments/assets/9fdc51fd-914d-4c41-a03e-801cf60daaba) 21 | ![微信截图_20241129111714](https://github.com/user-attachments/assets/d21e7365-bda2-42aa-8ddc-6fd9f10c8a8c) 22 | 23 | ### 重要更新 24 | 25 | 11/29. **更准确的分类模型PIP_ClassV2** 26 | 使用10000+图像微调了用于区分真实人脸/动漫人脸/其他(动物/风景/抽象元素等) 27 | 准确率95%以上。 28 | 29 | 模型地址: 30 | 通过百度网盘分享的文件:PIP_ClassV2 31 | 链接:https://pan.baidu.com/s/1uM-vtcNdETVckzOqDotAIQ?pwd=pip6 32 | 提取码:pip6 33 | --来自百度网盘超级会员V5的分享 34 | 35 | 使用方法: 36 | 下载到Comfyui_PIP_Class/models路径下 37 | 38 | 11/29. **VIT模型加载** 39 | 新增了对于三方图像分类模型的加载,你只需要在models下 git clone https://huggingface.co/Falconsai/nsfw_image_detection(示例,亲测有效) 40 | 确保你的文件结构类似这样: 41 | ![微信截图_20241129125819](https://github.com/user-attachments/assets/76cfe272-09d0-4b09-943e-e33ec1affdc3) 42 | 43 | ` 44 | 45 | 46 | ### 使用方法 47 | - **输入参数**: 48 | - `image`: 需要分类的图像,类型为IMAGE。 49 | - `model_path` (可选): 指定使用的模型路径,默认为"PIP_ClassV1"。 50 | - **输出结果**: 51 | - `分类标签`: 返回图像的预测类别标签。 52 | - `分类详情`: 显示每个类别的得分详情,帮助用户理解模型的分类决策。 53 | 54 | ### 使用方法 55 | 56 | PIP_ClassV1 模型是基于ViT-B/16预训练模型,在动漫、非人类、真人、三个类别上进行全量微调训练。 57 | 58 | 模型下载链接: 59 | 通过百度网盘分享的文件:model.safetensors 60 | 链接:https://pan.baidu.com/s/1cdMSZvlBhBccyDuYWL81gg?pwd=pip6 61 | 提取码:pip6 62 | --来自百度网盘超级会员V5的分享 63 | 64 | 模型路径: 65 | Comfyui_PIP_Class/models/PIP_ClassV1/模型 66 | 67 | 通过以上功能和简单的参数配置,PIPClass能够为用户提供强大且直观的图像分类服务。 68 | -------------------------------------------------------------------------------- /PIP_Class.py: -------------------------------------------------------------------------------- 1 | from transformers import ViTForImageClassification, ViTImageProcessor 2 | from PIL import Image 3 | import torch 4 | import os 5 | import numpy as np 6 | 7 | class PIPClass: 8 | @classmethod 9 | def INPUT_TYPES(cls): 10 | # 获取models目录下的所有子目录作为模型选项 11 | current_dir = os.path.dirname(__file__) 12 | models_dir = os.path.join(current_dir, "models") 13 | model_options = [d for d in os.listdir(models_dir) if os.path.isdir(os.path.join(models_dir, d))] 14 | 15 | return { 16 | "required": { 17 | "image": ("IMAGE", {}), 18 | }, 19 | "optional": { 20 | "model_path": (model_options, {"default": model_options[0] if model_options else ""}) 21 | } 22 | } 23 | 24 | RETURN_TYPES = ("STRING", "STRING") 25 | RETURN_NAMES = ("分类标签", "分类详情") 26 | CATEGORY = "PIP 图像分类" 27 | FUNCTION = "classify_image" 28 | 29 | def __init__(self, model_path="PIP_ClassV1"): 30 | # 获取当前脚本的目录 31 | current_dir = os.path.dirname(__file__) 32 | full_model_path = os.path.join(current_dir, "models", model_path) 33 | 34 | # 打印模型路径以调试 35 | print(f"Loading model from: {full_model_path}") 36 | 37 | # 加载模型和预处理器 38 | self.model = ViTForImageClassification.from_pretrained(full_model_path) 39 | self.processor = ViTImageProcessor.from_pretrained(full_model_path) 40 | 41 | # 手动设置id2label(如果需要) 42 | self.model.config.id2label = { 43 | "0": "动漫", 44 | "1": "非人", 45 | "2": "真人" 46 | } 47 | 48 | def preprocess_image(self, image): 49 | # 中心裁剪 50 | width, height = image.size 51 | new_size = min(width, height) 52 | left = (width - new_size) / 2 53 | top = (height - new_size) / 2 54 | right = (width + new_size) / 2 55 | bottom = (height + new_size) / 2 56 | image = image.crop((left, top, right, bottom)) 57 | 58 | # 调整大小到224x224 59 | image = image.resize((224, 224), Image.LANCZOS) 60 | 61 | # 预处理 62 | inputs = self.processor(images=image, return_tensors="pt") 63 | return inputs 64 | 65 | def classify_image(self, image, model_path=""): 66 | # 确保输入是一个三维张量 67 | if image.dim() == 4: 68 | image = image.squeeze(0) # 去除批次维度 69 | 70 | # 确保图像数据在0-1范围内 71 | image = image.float() / 255.0 if image.dtype == torch.uint8 else image.float() 72 | image = torch.clamp(image, 0, 1) 73 | 74 | # 转换为PIL图像 75 | image_np = (image.cpu().numpy() * 255).astype(np.uint8) 76 | image = Image.fromarray(image_np, mode='RGB') 77 | 78 | # 预处理图像 79 | inputs = self.preprocess_image(image) 80 | 81 | with torch.no_grad(): 82 | outputs = self.model(**inputs) 83 | logits = outputs.logits 84 | predicted_class_idx = logits.argmax(-1).item() 85 | 86 | # 获取预测标签 87 | predicted_label = self.model.config.id2label.get(str(predicted_class_idx), "未知") 88 | 89 | # 获取每个类别的分数详情 90 | scores = torch.nn.functional.softmax(logits, dim=-1).squeeze().tolist() 91 | detailed_scores = " | ".join([f"{self.model.config.id2label[str(i)]}: {score:.2f}" for i, score in enumerate(scores)]) 92 | 93 | return predicted_label, detailed_scores 94 | 95 | # 包含所有要导出的节点的字典,以及它们的名称 96 | NODE_CLASS_MAPPINGS = { 97 | "PIPClass": PIPClass 98 | } 99 | 100 | # 包含节点的友好/人类可读标题的字典 101 | NODE_DISPLAY_NAME_MAPPINGS = { 102 | "PIPClass": "PIP 图像分类" 103 | } -------------------------------------------------------------------------------- /PIP_Class_Advanced.py: -------------------------------------------------------------------------------- 1 | from transformers import ViTForImageClassification, ViTImageProcessor 2 | from PIL import Image 3 | import torch 4 | import os 5 | import json 6 | import numpy as np 7 | 8 | class PIPClassAdvanced: 9 | @classmethod 10 | def INPUT_TYPES(cls): 11 | current_dir = os.path.dirname(__file__) 12 | models_dir = os.path.join(current_dir, "models") 13 | model_options = [d for d in os.listdir(models_dir) if os.path.isdir(os.path.join(models_dir, d))] 14 | 15 | return { 16 | "required": { 17 | "image": ("IMAGE", {}), 18 | }, 19 | "optional": { 20 | "model_path": (model_options, {"default": model_options[0] if model_options else ""}) 21 | } 22 | } 23 | 24 | RETURN_TYPES = ("STRING", "STRING") 25 | RETURN_NAMES = ("分类标签", "分类详情") 26 | CATEGORY = "PIP 图像分类高级版" 27 | FUNCTION = "classify_image" 28 | 29 | def __init__(self, model_path="PIP_ClassV1"): 30 | current_dir = os.path.dirname(__file__) 31 | models_dir = os.path.join(current_dir, "models") 32 | full_model_path = os.path.join(models_dir, model_path) 33 | 34 | print(f"Loading model from: {full_model_path}") 35 | 36 | self.model = ViTForImageClassification.from_pretrained(full_model_path) 37 | self.processor = ViTImageProcessor.from_pretrained(full_model_path) 38 | 39 | # 从config.json读取id2label 40 | config_path = os.path.join(full_model_path, "config.json") 41 | with open(config_path, 'r') as f: 42 | config = json.load(f) 43 | self.model.config.id2label = config.get("id2label", {}) 44 | 45 | def preprocess_image(self, image): 46 | width, height = image.size 47 | new_size = min(width, height) 48 | left = (width - new_size) / 2 49 | top = (height - new_size) / 2 50 | right = (width + new_size) / 2 51 | bottom = (height + new_size) / 2 52 | image = image.crop((left, top, right, bottom)) 53 | image = image.resize((224, 224), Image.LANCZOS) 54 | inputs = self.processor(images=image, return_tensors="pt") 55 | return inputs 56 | 57 | def classify_image(self, image, model_path=""): 58 | if model_path: 59 | current_dir = os.path.dirname(__file__) 60 | models_dir = os.path.join(current_dir, "models") 61 | full_model_path = os.path.join(models_dir, model_path) 62 | self.model = ViTForImageClassification.from_pretrained(full_model_path) 63 | self.processor = ViTImageProcessor.from_pretrained(full_model_path) 64 | 65 | # 从config.json读取id2label 66 | config_path = os.path.join(full_model_path, "config.json") 67 | with open(config_path, 'r') as f: 68 | config = json.load(f) 69 | self.model.config.id2label = config.get("id2label", {}) 70 | 71 | if image.dim() == 4: 72 | image = image.squeeze(0) 73 | 74 | image = image.float() / 255.0 if image.dtype == torch.uint8 else image.float() 75 | image = torch.clamp(image, 0, 1) 76 | 77 | image_np = (image.cpu().numpy() * 255).astype(np.uint8) 78 | image = Image.fromarray(image_np, mode='RGB') 79 | 80 | inputs = self.preprocess_image(image) 81 | 82 | with torch.no_grad(): 83 | outputs = self.model(**inputs) 84 | logits = outputs.logits 85 | predicted_class_idx = logits.argmax(-1).item() 86 | 87 | predicted_label = self.model.config.id2label.get(str(predicted_class_idx), "未知") 88 | 89 | scores = torch.nn.functional.softmax(logits, dim=-1).squeeze().tolist() 90 | detailed_scores = " | ".join([f"{self.model.config.id2label[str(i)]}: {score:.2f}" for i, score in enumerate(scores)]) 91 | 92 | return predicted_label, detailed_scores -------------------------------------------------------------------------------- /base.json: -------------------------------------------------------------------------------- 1 | { 2 | "last_node_id": 180, 3 | "last_link_id": 382, 4 | "nodes": [ 5 | { 6 | "id": 178, 7 | "type": "ShowText|pysssss", 8 | "pos": [ 9 | 205.40158081054688, 10 | 1893.505615234375 11 | ], 12 | "size": [ 13 | 525.917724609375, 14 | 227.97877502441406 15 | ], 16 | "flags": {}, 17 | "order": 2, 18 | "mode": 0, 19 | "inputs": [ 20 | { 21 | "name": "text", 22 | "type": "STRING", 23 | "link": 381, 24 | "widget": { 25 | "name": "text" 26 | }, 27 | "label": "文本" 28 | } 29 | ], 30 | "outputs": [ 31 | { 32 | "name": "STRING", 33 | "type": "STRING", 34 | "links": null, 35 | "shape": 6, 36 | "label": "字符串" 37 | } 38 | ], 39 | "properties": { 40 | "Node name for S&R": "ShowText|pysssss" 41 | }, 42 | "widgets_values": [ 43 | "", 44 | "非人" 45 | ] 46 | }, 47 | { 48 | "id": 176, 49 | "type": "PIPClass", 50 | "pos": [ 51 | -212, 52 | 1893 53 | ], 54 | "size": [ 55 | 304.79998779296875, 56 | 78 57 | ], 58 | "flags": {}, 59 | "order": 1, 60 | "mode": 0, 61 | "inputs": [ 62 | { 63 | "name": "image", 64 | "type": "IMAGE", 65 | "link": 380, 66 | "label": "image" 67 | } 68 | ], 69 | "outputs": [ 70 | { 71 | "name": "分类标签", 72 | "type": "STRING", 73 | "links": [ 74 | 381 75 | ], 76 | "slot_index": 0, 77 | "label": "分类标签" 78 | }, 79 | { 80 | "name": "分类详情", 81 | "type": "STRING", 82 | "links": [ 83 | 382 84 | ], 85 | "slot_index": 1, 86 | "label": "分类详情" 87 | } 88 | ], 89 | "properties": { 90 | "Node name for S&R": "PIPClass" 91 | }, 92 | "widgets_values": [ 93 | "PIP_ClassV1" 94 | ] 95 | }, 96 | { 97 | "id": 179, 98 | "type": "ShowText|pysssss", 99 | "pos": [ 100 | 211, 101 | 2188 102 | ], 103 | "size": [ 104 | 517.9850463867188, 105 | 152.32717895507812 106 | ], 107 | "flags": {}, 108 | "order": 3, 109 | "mode": 0, 110 | "inputs": [ 111 | { 112 | "name": "text", 113 | "type": "STRING", 114 | "link": 382, 115 | "widget": { 116 | "name": "text" 117 | }, 118 | "label": "文本" 119 | } 120 | ], 121 | "outputs": [ 122 | { 123 | "name": "STRING", 124 | "type": "STRING", 125 | "links": null, 126 | "shape": 6, 127 | "label": "字符串" 128 | } 129 | ], 130 | "properties": { 131 | "Node name for S&R": "ShowText|pysssss" 132 | }, 133 | "widgets_values": [ 134 | "", 135 | "动漫: 0.00 | 非人: 0.98 | 真人: 0.01" 136 | ] 137 | }, 138 | { 139 | "id": 177, 140 | "type": "LoadImage", 141 | "pos": [ 142 | -618, 143 | 1888 144 | ], 145 | "size": [ 146 | 315, 147 | 314 148 | ], 149 | "flags": {}, 150 | "order": 0, 151 | "mode": 0, 152 | "inputs": [], 153 | "outputs": [ 154 | { 155 | "name": "IMAGE", 156 | "type": "IMAGE", 157 | "links": [ 158 | 380 159 | ], 160 | "label": "图像" 161 | }, 162 | { 163 | "name": "MASK", 164 | "type": "MASK", 165 | "links": null, 166 | "label": "遮罩" 167 | } 168 | ], 169 | "properties": { 170 | "Node name for S&R": "LoadImage" 171 | }, 172 | "widgets_values": [ 173 | "996666.png", 174 | "image" 175 | ] 176 | } 177 | ], 178 | "links": [ 179 | [ 180 | 380, 181 | 177, 182 | 0, 183 | 176, 184 | 0, 185 | "IMAGE" 186 | ], 187 | [ 188 | 381, 189 | 176, 190 | 0, 191 | 178, 192 | 0, 193 | "STRING" 194 | ], 195 | [ 196 | 382, 197 | 176, 198 | 1, 199 | 179, 200 | 0, 201 | "STRING" 202 | ] 203 | ], 204 | "groups": [], 205 | "config": {}, 206 | "extra": { 207 | "ds": { 208 | "scale": 1.4122927695244518, 209 | "offset": [ 210 | 779.2561696646599, 211 | -1683.6662957874403 212 | ] 213 | }, 214 | "groupNodes": {} 215 | }, 216 | "version": 0.4 217 | } -------------------------------------------------------------------------------- /workflow/基础版.json: -------------------------------------------------------------------------------- 1 | { 2 | "last_node_id": 193, 3 | "last_link_id": 397, 4 | "nodes": [ 5 | { 6 | "id": 177, 7 | "type": "LoadImage", 8 | "pos": [ 9 | -517.4732055664062, 10 | 1853.72998046875 11 | ], 12 | "size": [ 13 | 275.3946838378906, 14 | 645.2816162109375 15 | ], 16 | "flags": {}, 17 | "order": 0, 18 | "mode": 0, 19 | "inputs": [], 20 | "outputs": [ 21 | { 22 | "name": "IMAGE", 23 | "type": "IMAGE", 24 | "links": [ 25 | 395 26 | ], 27 | "slot_index": 0, 28 | "label": "图像" 29 | }, 30 | { 31 | "name": "MASK", 32 | "type": "MASK", 33 | "links": null, 34 | "label": "遮罩" 35 | } 36 | ], 37 | "properties": { 38 | "Node name for S&R": "LoadImage" 39 | }, 40 | "widgets_values": [ 41 | "sss.png", 42 | "image" 43 | ] 44 | }, 45 | { 46 | "id": 193, 47 | "type": "ShowText|pysssss", 48 | "pos": [ 49 | 253.94248962402344, 50 | 2038.8717041015625 51 | ], 52 | "size": [ 53 | 315, 54 | 75.9998779296875 55 | ], 56 | "flags": {}, 57 | "order": 3, 58 | "mode": 0, 59 | "inputs": [ 60 | { 61 | "name": "text", 62 | "type": "STRING", 63 | "link": 397, 64 | "widget": { 65 | "name": "text" 66 | }, 67 | "label": "文本" 68 | } 69 | ], 70 | "outputs": [ 71 | { 72 | "name": "STRING", 73 | "type": "STRING", 74 | "links": null, 75 | "shape": 6, 76 | "label": "字符串" 77 | } 78 | ], 79 | "properties": { 80 | "Node name for S&R": "ShowText|pysssss" 81 | }, 82 | "widgets_values": [ 83 | "", 84 | "动漫: 0.01 | 非人: 0.01 | 真人: 0.99" 85 | ] 86 | }, 87 | { 88 | "id": 192, 89 | "type": "ShowText|pysssss", 90 | "pos": [ 91 | 253.94244384765625, 92 | 1861.9443359375 93 | ], 94 | "size": [ 95 | 315, 96 | 76 97 | ], 98 | "flags": {}, 99 | "order": 2, 100 | "mode": 0, 101 | "inputs": [ 102 | { 103 | "name": "text", 104 | "type": "STRING", 105 | "link": 396, 106 | "widget": { 107 | "name": "text" 108 | }, 109 | "label": "文本" 110 | } 111 | ], 112 | "outputs": [ 113 | { 114 | "name": "STRING", 115 | "type": "STRING", 116 | "links": null, 117 | "shape": 6, 118 | "label": "字符串" 119 | } 120 | ], 121 | "properties": { 122 | "Node name for S&R": "ShowText|pysssss" 123 | }, 124 | "widgets_values": [ 125 | "", 126 | "真人" 127 | ] 128 | }, 129 | { 130 | "id": 191, 131 | "type": "PIPClass", 132 | "pos": [ 133 | -126.86579895019531, 134 | 1859.8709716796875 135 | ], 136 | "size": [ 137 | 315, 138 | 78 139 | ], 140 | "flags": {}, 141 | "order": 1, 142 | "mode": 0, 143 | "inputs": [ 144 | { 145 | "name": "image", 146 | "type": "IMAGE", 147 | "link": 395, 148 | "label": "image" 149 | } 150 | ], 151 | "outputs": [ 152 | { 153 | "name": "分类标签", 154 | "type": "STRING", 155 | "links": [ 156 | 396 157 | ], 158 | "label": "分类标签", 159 | "slot_index": 0 160 | }, 161 | { 162 | "name": "分类详情", 163 | "type": "STRING", 164 | "links": [ 165 | 397 166 | ], 167 | "label": "分类详情", 168 | "slot_index": 1 169 | } 170 | ], 171 | "properties": { 172 | "Node name for S&R": "PIPClass" 173 | }, 174 | "widgets_values": [ 175 | "PIP_ClassV1" 176 | ] 177 | } 178 | ], 179 | "links": [ 180 | [ 181 | 395, 182 | 177, 183 | 0, 184 | 191, 185 | 0, 186 | "IMAGE" 187 | ], 188 | [ 189 | 396, 190 | 191, 191 | 0, 192 | 192, 193 | 0, 194 | "STRING" 195 | ], 196 | [ 197 | 397, 198 | 191, 199 | 1, 200 | 193, 201 | 0, 202 | "STRING" 203 | ] 204 | ], 205 | "groups": [], 206 | "config": {}, 207 | "extra": { 208 | "ds": { 209 | "scale": 0.9646149645000038, 210 | "offset": [ 211 | 883.6444275122535, 212 | -1566.3817702556596 213 | ] 214 | }, 215 | "groupNodes": {} 216 | }, 217 | "version": 0.4 218 | } -------------------------------------------------------------------------------- /workflow/高级版json.json: -------------------------------------------------------------------------------- 1 | { 2 | "last_node_id": 190, 3 | "last_link_id": 394, 4 | "nodes": [ 5 | { 6 | "id": 182, 7 | "type": "ShowText|pysssss", 8 | "pos": [ 9 | 280, 10 | 1880 11 | ], 12 | "size": [ 13 | 315, 14 | 76 15 | ], 16 | "flags": {}, 17 | "order": 3, 18 | "mode": 0, 19 | "inputs": [ 20 | { 21 | "name": "text", 22 | "type": "STRING", 23 | "link": 387, 24 | "widget": { 25 | "name": "text" 26 | }, 27 | "label": "文本" 28 | } 29 | ], 30 | "outputs": [ 31 | { 32 | "name": "STRING", 33 | "type": "STRING", 34 | "links": null, 35 | "shape": 6, 36 | "label": "字符串" 37 | } 38 | ], 39 | "properties": { 40 | "Node name for S&R": "ShowText|pysssss" 41 | }, 42 | "widgets_values": [ 43 | "", 44 | "nsfw" 45 | ] 46 | }, 47 | { 48 | "id": 183, 49 | "type": "ShowText|pysssss", 50 | "pos": [ 51 | 280, 52 | 2060 53 | ], 54 | "size": [ 55 | 315, 56 | 76 57 | ], 58 | "flags": {}, 59 | "order": 4, 60 | "mode": 0, 61 | "inputs": [ 62 | { 63 | "name": "text", 64 | "type": "STRING", 65 | "link": 388, 66 | "widget": { 67 | "name": "text" 68 | }, 69 | "label": "文本" 70 | } 71 | ], 72 | "outputs": [ 73 | { 74 | "name": "STRING", 75 | "type": "STRING", 76 | "links": null, 77 | "shape": 6, 78 | "label": "字符串" 79 | } 80 | ], 81 | "properties": { 82 | "Node name for S&R": "ShowText|pysssss" 83 | }, 84 | "widgets_values": [ 85 | "", 86 | "normal: 0.00 | nsfw: 1.00" 87 | ] 88 | }, 89 | { 90 | "id": 184, 91 | "type": "PIPClassAdvanced", 92 | "pos": [ 93 | -160, 94 | 1880 95 | ], 96 | "size": [ 97 | 360.48809814453125, 98 | 110.18492889404297 99 | ], 100 | "flags": {}, 101 | "order": 1, 102 | "mode": 0, 103 | "inputs": [ 104 | { 105 | "name": "image", 106 | "type": "IMAGE", 107 | "link": 386, 108 | "label": "image" 109 | } 110 | ], 111 | "outputs": [ 112 | { 113 | "name": "分类标签", 114 | "type": "STRING", 115 | "links": [ 116 | 387 117 | ], 118 | "slot_index": 0, 119 | "label": "分类标签" 120 | }, 121 | { 122 | "name": "分类详情", 123 | "type": "STRING", 124 | "links": [ 125 | 388 126 | ], 127 | "slot_index": 1, 128 | "label": "分类详情" 129 | } 130 | ], 131 | "properties": { 132 | "Node name for S&R": "PIPClassAdvanced" 133 | }, 134 | "widgets_values": [ 135 | "nsfw_image_detection" 136 | ] 137 | }, 138 | { 139 | "id": 185, 140 | "type": "ShowText|pysssss", 141 | "pos": [ 142 | 280, 143 | 2350 144 | ], 145 | "size": [ 146 | 315, 147 | 76 148 | ], 149 | "flags": {}, 150 | "order": 5, 151 | "mode": 0, 152 | "inputs": [ 153 | { 154 | "name": "text", 155 | "type": "STRING", 156 | "link": 389, 157 | "widget": { 158 | "name": "text" 159 | }, 160 | "label": "文本" 161 | } 162 | ], 163 | "outputs": [ 164 | { 165 | "name": "STRING", 166 | "type": "STRING", 167 | "links": null, 168 | "shape": 6, 169 | "label": "字符串" 170 | } 171 | ], 172 | "properties": { 173 | "Node name for S&R": "ShowText|pysssss" 174 | }, 175 | "widgets_values": [ 176 | "", 177 | "20-29" 178 | ] 179 | }, 180 | { 181 | "id": 187, 182 | "type": "PIPClassAdvanced", 183 | "pos": [ 184 | -160, 185 | 2350 186 | ], 187 | "size": [ 188 | 360.48809814453125, 189 | 110.18492889404297 190 | ], 191 | "flags": {}, 192 | "order": 2, 193 | "mode": 0, 194 | "inputs": [ 195 | { 196 | "name": "image", 197 | "type": "IMAGE", 198 | "link": 391, 199 | "label": "image" 200 | } 201 | ], 202 | "outputs": [ 203 | { 204 | "name": "分类标签", 205 | "type": "STRING", 206 | "links": [ 207 | 389 208 | ], 209 | "slot_index": 0, 210 | "label": "分类标签" 211 | }, 212 | { 213 | "name": "分类详情", 214 | "type": "STRING", 215 | "links": [ 216 | 390 217 | ], 218 | "slot_index": 1, 219 | "label": "分类详情" 220 | } 221 | ], 222 | "properties": { 223 | "Node name for S&R": "PIPClassAdvanced" 224 | }, 225 | "widgets_values": [ 226 | "vit-age-classifier" 227 | ] 228 | }, 229 | { 230 | "id": 186, 231 | "type": "ShowText|pysssss", 232 | "pos": [ 233 | 280, 234 | 2530 235 | ], 236 | "size": [ 237 | 745.29248046875, 238 | 76 239 | ], 240 | "flags": {}, 241 | "order": 6, 242 | "mode": 0, 243 | "inputs": [ 244 | { 245 | "name": "text", 246 | "type": "STRING", 247 | "link": 390, 248 | "widget": { 249 | "name": "text" 250 | }, 251 | "label": "文本" 252 | } 253 | ], 254 | "outputs": [ 255 | { 256 | "name": "STRING", 257 | "type": "STRING", 258 | "links": null, 259 | "shape": 6, 260 | "label": "字符串" 261 | } 262 | ], 263 | "properties": { 264 | "Node name for S&R": "ShowText|pysssss" 265 | }, 266 | "widgets_values": [ 267 | "", 268 | "0-2: 0.01 | 3-9: 0.09 | 10-19: 0.28 | 20-29: 0.54 | 30-39: 0.06 | 40-49: 0.01 | 50-59: 0.01 | 60-69: 0.00 | more than 70: 0.01" 269 | ] 270 | }, 271 | { 272 | "id": 177, 273 | "type": "LoadImage", 274 | "pos": [ 275 | -517.4732055664062, 276 | 1853.72998046875 277 | ], 278 | "size": [ 279 | 275.3946838378906, 280 | 645.2816162109375 281 | ], 282 | "flags": {}, 283 | "order": 0, 284 | "mode": 0, 285 | "inputs": [], 286 | "outputs": [ 287 | { 288 | "name": "IMAGE", 289 | "type": "IMAGE", 290 | "links": [ 291 | 386, 292 | 391 293 | ], 294 | "slot_index": 0, 295 | "label": "图像" 296 | }, 297 | { 298 | "name": "MASK", 299 | "type": "MASK", 300 | "links": null, 301 | "label": "遮罩" 302 | } 303 | ], 304 | "properties": { 305 | "Node name for S&R": "LoadImage" 306 | }, 307 | "widgets_values": [ 308 | "sss.png", 309 | "image" 310 | ] 311 | } 312 | ], 313 | "links": [ 314 | [ 315 | 386, 316 | 177, 317 | 0, 318 | 184, 319 | 0, 320 | "IMAGE" 321 | ], 322 | [ 323 | 387, 324 | 184, 325 | 0, 326 | 182, 327 | 0, 328 | "STRING" 329 | ], 330 | [ 331 | 388, 332 | 184, 333 | 1, 334 | 183, 335 | 0, 336 | "STRING" 337 | ], 338 | [ 339 | 389, 340 | 187, 341 | 0, 342 | 185, 343 | 0, 344 | "STRING" 345 | ], 346 | [ 347 | 390, 348 | 187, 349 | 1, 350 | 186, 351 | 0, 352 | "STRING" 353 | ], 354 | [ 355 | 391, 356 | 177, 357 | 0, 358 | 187, 359 | 0, 360 | "IMAGE" 361 | ] 362 | ], 363 | "groups": [], 364 | "config": {}, 365 | "extra": { 366 | "ds": { 367 | "scale": 1.1671841070450049, 368 | "offset": [ 369 | 774.1244304283048, 370 | -1738.1484242956894 371 | ] 372 | }, 373 | "groupNodes": {} 374 | }, 375 | "version": 0.4 376 | } --------------------------------------------------------------------------------