From 6f83efdd940e59edabf1ad6cfb944859386b1b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=B7=E5=AE=87=E4=BD=B3?= Date: Tue, 18 Feb 2025 17:27:19 +0800 Subject: [PATCH] =?UTF-8?q?PERF=20=E6=B8=85=E7=90=86=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 87 ++++++++--------------------------------------------- 1 file changed, 13 insertions(+), 74 deletions(-) diff --git a/__init__.py b/__init__.py index dcd3b68..5ad79cf 100644 --- a/__init__.py +++ b/__init__.py @@ -23,59 +23,11 @@ video_extensions = ['webm', 'mp4', 'mkv', 'gif', 'mov'] class FaceDetect: """ - A example node - - Class methods - ------------- - INPUT_TYPES (dict): - Tell the main program input parameters of nodes. - IS_CHANGED: - optional method to control when the node is re executed. - - Attributes - ---------- - RETURN_TYPES (`tuple`): - The type of each element in the output tuple. - RETURN_NAMES (`tuple`): - Optional: The name of each output in the output tuple. - FUNCTION (`str`): - The name of the entry-point method. For example, if `FUNCTION = "execute"` then it will run Example().execute() - OUTPUT_NODE ([`bool`]): - If this node is an output node that outputs a result/image from the graph. The SaveImage node is an example. - The backend iterates on these output nodes and tries to execute all their parents if their parent graph is properly connected. - Assumed to be False if not present. - CATEGORY (`str`): - The category the node should appear in the UI. - DEPRECATED (`bool`): - Indicates whether the node is deprecated. Deprecated nodes are hidden by default in the UI, but remain - functional in existing workflows that use them. - EXPERIMENTAL (`bool`): - Indicates whether the node is experimental. Experimental nodes are marked as such in the UI and may be subject to - significant changes or removal in future versions. Use with caution in production workflows. - execute(s) -> tuple || None: - The entry point method. The name of this method must be the same as the value of property `FUNCTION`. - For example, if `FUNCTION = "execute"` then this method's name must be `execute`, if `FUNCTION = "foo"` then it must be `foo`. + 人脸遮挡检测 """ - def __init__(self): - pass - @classmethod def INPUT_TYPES(s): - """ - Return a dictionary which contains config for all input fields. - Some types (string): "MODEL", "VAE", "CLIP", "CONDITIONING", "LATENT", "IMAGE", "INT", "STRING", "FLOAT". - Input types "INT", "STRING" or "FLOAT" are special values for fields on the node. - The type can be a list for selection. - - Returns: `dict`: - - Key input_fields_group (`string`): Can be either required, hidden or optional. A node class must have property `required` - - Value input_fields (`dict`): Contains input fields config: - * Key field_name (`string`): Name of a entry-point method's argument - * Value field_config (`tuple`): - + First value is a string indicate the type of field or a list for selection. - + Second value is a config for type "INT", "STRING" or "FLOAT". - """ return { "required": { "image": ("IMAGE",), @@ -91,9 +43,7 @@ class FaceDetect: FUNCTION = "predict" - # OUTPUT_NODE = False - - CATEGORY = "自定义节点" + CATEGORY = "不忘科技-自定义节点🚩" def predict(self, image, main_seed, model, length, threshold): image, image_selected, cls, prob, nums, period = test_node(image, length=length, thres=threshold, @@ -103,26 +53,13 @@ class FaceDetect: start, end = period[main_seed % len(period)] config = {"start": start, "end": end} else: - config = {} - start = 0 - end = 0 raise RuntimeError("未找到符合要求的视频片段") return (image, image_selected, cls, prob, nums, str(period), json.dumps(config), start, end - start) - """ - The node will always be re executed if any of the inputs change but - this method can be used to force the node to execute again even when the inputs don't change. - You can make this node return a number or a string. This value will be compared to the one returned the last time the node was - executed, if it is different the node will be executed again. - This method is used in the core repo for the LoadImage node where they return the image hash as a string, if the image hash - changes between executions the LoadImage node is executed again. - """ - # @classmethod - # def IS_CHANGED(s, image, string_field, int_field, float_field, print_to_screen): - # return "" +class FaceExtract: + """人脸提取 By YOLO""" -class FaceExtract(): @classmethod def INPUT_TYPES(s): return { @@ -136,7 +73,7 @@ class FaceExtract(): FUNCTION = "crop" - CATEGORY = "自定义节点" + CATEGORY = "不忘科技-自定义节点🚩" def crop(self, image): device = model_management.get_torch_device() @@ -182,6 +119,8 @@ class FaceExtract(): class COSDownload: + """腾讯云COS下载""" + @classmethod def INPUT_TYPES(s): return { @@ -193,7 +132,7 @@ class COSDownload: RETURN_TYPES = ("STRING",) RETURN_NAMES = ("视频存储路径",) FUNCTION = "download" - CATEGORY = "自定义节点" + CATEGORY = "不忘科技-自定义节点🚩" def download(self, cos_key): if os.sep in cos_key or "/" in cos_key or "\\" in cos_key: @@ -220,6 +159,8 @@ class COSDownload: class COSUpload: + """腾讯云COS上传""" + @classmethod def INPUT_TYPES(s): return { @@ -232,7 +173,7 @@ class COSUpload: RETURN_NAMES = ("COS文件Key",) FUNCTION = "upload" - CATEGORY = "自定义节点" + CATEGORY = "不忘科技-自定义节点🚩" def upload(self, path): for i in range(0, 10): @@ -254,10 +195,8 @@ class COSUpload: return ("/".join([yaml_config["subfolder"], path.split("/")[-1] if "/" in path else path.split("\\")[-1]]),) -# 有问题 class VideoCut: - def __init__(self): - pass + """FFMPEG视频剪辑 -- !有卡顿问题 暂废弃""" @classmethod def INPUT_TYPES(s): @@ -278,7 +217,7 @@ class VideoCut: # OUTPUT_NODE = False - CATEGORY = "自定义节点" + CATEGORY = "不忘科技-自定义节点🚩" def cut(self, config, video_path, mod, fps, period_length): # 原文件名