commit GrayValue node, support defining multiple folders in resource-dir.ini
This commit is contained in:
@@ -116,6 +116,9 @@ When this error has occurred, please check the network environment.
|
||||
## Update
|
||||
<font size="4">**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. </font><br />
|
||||
|
||||
* Commit [GrayValue](#GrayValue) node, output the grayscale values corresponding to the RGB color values.
|
||||
* [LUT Apply](#LUT), [TextImageV2](#TextImageV2), [TextImage](#TextImage), [SimpleTextImage](#SimpleTextImage) nodes to support defining multiple folders in ```resource-dir.ini```, separated by commas, semicolons, or spaces. Simultaneously supports refreshing real-time updates.
|
||||
* [LUT Apply](#LUT), [TextImageV2](#TextImageV2), [TextImage](#TextImage), [SimpleTextImage](#SimpleTextImage) nodes support defining multi directory fonts and lut folders, and support refreshing and real-time updates.
|
||||
* Commit [HumanPartsUltra](#HumanPartsUltra) node, used to generate human body parts masks. It is based on the warrper of [metal3d/ComfyUI_Human_Parts](https://github.com/metal3d/ComfyUI_Human_Parts), thank the original author.
|
||||
Download model file from [BaiduNetdisk](https://pan.baidu.com/s/1-6uwH6RB0FhIVfa3qO7hhQ?pwd=d862) or [huggingface](https://huggingface.co/Metal3d/deeplabv3p-resnet50-human/tree/main) and copy to ```ComfyUI\models\onnx\human-parts``` folder.
|
||||
* ObjectDetector nodes add sort by confidence option.
|
||||
@@ -442,7 +445,9 @@ Node options:
|
||||
* strength: Range 0~100, LUT application strength. The larger the value, the greater the difference from the original image, and the smaller the value, the closer it is to the original image.
|
||||
|
||||
<sup>*</sup><font size="3">LUT folder is defined in ```resource_dir.ini```, this file is located in the root directory of the plug-in, and the default name is ```resource_dir.ini.example```. to use this file for the first time, you need to change the file suffix to ```.ini```.
|
||||
Open the text editing software and find the line starting with "LUT_dir=", after "=", enter the custom folder path name. all .cube files in this folder will be collected and displayed in the node list during ComfyUI initialization.
|
||||
Open the text editing software and find the line starting with "LUT_dir=", after "=", enter the custom folder path name.
|
||||
support defining multiple folders in ```resource-dir.ini```, separated by commas, semicolons, or spaces.
|
||||
all .cube files in this folder will be collected and displayed in the node list during ComfyUI initialization.
|
||||
If the folder set in ini is invalid, the LUT folder that comes with the plugin will be enabled.</font>
|
||||
|
||||
### <a id="table1">AutoAdjust</a>
|
||||
@@ -956,8 +961,11 @@ Node Options:
|
||||
* font_file<sup>**</sup>: Here is a list of available font files in the font folder, and the selected font files will be used to generate images.
|
||||
* border: The border width of the reel.
|
||||
* color_theme: Theme color for the output image.
|
||||
<sup>*</sup>The font folder is defined in ```resource_dir.ini```, this file is located in the root directory of the plug-in, and the default name is ```resource_dir.ini.example```. to use this file for the first time, you need to change the file suffix to ```.ini```.
|
||||
Open the text editing software and find the line starting with "FONT_dir=", after "=", enter the custom folder path name. all font files in this folder will be collected and displayed in the node list during ComfyUI initialization.
|
||||
<sup>*</sup>The font folder is defined in ```resource_dir.ini```, this file is located in the root directory of the plug-in, and the default name is ```resource_dir.ini.example```.
|
||||
to use this file for the first time, you need to change the file suffix to ```.ini```.
|
||||
Open the text editing software and find the line starting with "FONT_dir=", after "=", enter the custom folder path name.
|
||||
support defining multiple folders in ```resource-dir.ini```, separated by commas, semicolons, or spaces.
|
||||
all font files in this folder will be collected and displayed in the node list during ComfyUI initialization.
|
||||
If the folder set in ini is invalid, the font folder that comes with the plugin will be enabled.
|
||||
|
||||
|
||||
@@ -997,6 +1005,17 @@ Output color values as individual decimal values of H, S, and V (maximum value o
|
||||
Node Options:
|
||||
* color_value: Supports hexadecimal (HEX) or decimal (DEC) color values and should be of string or tuple type. Forcing in other types will result in an error.
|
||||
|
||||
### <a id="table1">GrayValue</a>
|
||||
Output grayscale values based on color values. Supports outputting 256 level and 100 level grayscale values.
|
||||

|
||||
|
||||
Node Options:
|
||||
* color_value: Supports hexadecimal (HEX) or decimal (DEC) color values and should be of string or tuple type. Forcing in other types will result in an error.
|
||||
|
||||
Outputs:
|
||||
* gray(256_level): 256 level grayscale value. Integer type, range 0~255.
|
||||
* gray(100_level): 100 level grayscale value. Integer type, range 0~100.
|
||||
|
||||
### <a id="table1">GetColorTone</a>
|
||||
Obtain the main color or average color from the image and output RGB values.
|
||||

|
||||
@@ -1195,7 +1214,9 @@ Node options:
|
||||
<sup>*</sup>Only limited to input image and mask. forcing the integration of other types of inputs will result in node errors.
|
||||
|
||||
<sup>**</sup>The font folder is defined in ```resource_dir.ini```, this file is located in the root directory of the plug-in, and the default name is ```resource_dir.ini.example```. to use this file for the first time, you need to change the file suffix to ```.ini```.
|
||||
Open the text editing software and find the line starting with "FONT_dir=", after "=", enter the custom folder path name. all font files in this folder will be collected and displayed in the node list during ComfyUI initialization.
|
||||
Open the text editing software and find the line starting with "FONT_dir=", after "=", enter the custom folder path name.
|
||||
support defining multiple folders in ```resource-dir.ini```, separated by commas, semicolons, or spaces.
|
||||
all font files in this folder will be collected and displayed in the node list during ComfyUI initialization.
|
||||
If the folder set in ini is invalid, the font folder that comes with the plugin will be enabled.
|
||||
|
||||
|
||||
@@ -1224,7 +1245,9 @@ Node options:
|
||||
<sup>*</sup>Only limited to input image and mask. forcing the integration of other types of inputs will result in node errors.
|
||||
|
||||
<sup>**</sup>The font folder is defined in ```resource_dir.ini```, this file is located in the root directory of the plug-in, and the default name is ```resource_dir.ini.example```. to use this file for the first time, you need to change the file suffix to ```.ini```.
|
||||
Open the text editing software and find the line starting with "FONT_dir=", after "=", enter the custom folder path name. all font files in this folder will be collected and displayed in the node list during ComfyUI initialization.
|
||||
Open the text editing software and find the line starting with "FONT_dir=", after "=", enter the custom folder path name.
|
||||
support defining multiple folders in ```resource-dir.ini```, separated by commas, semicolons, or spaces.
|
||||
all font files in this folder will be collected and displayed in the node list during ComfyUI initialization.
|
||||
If the folder set in ini is invalid, the font folder that comes with the plugin will be enabled.
|
||||
|
||||
### <a id="table1">TextImageV2</a>
|
||||
|
||||
+32
-4
@@ -116,6 +116,8 @@ os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
|
||||
## 更新说明
|
||||
<font size="4">**如果本插件更新后出现依赖包错误,请双击运行插件目录下的```install_requirements.bat```(官方便携包),或 ```install_requirements_aki.bat```(秋叶整合包) 重新安装依赖包。
|
||||
|
||||
* 添加 [GrayValue](#GrayValue) 节点,输出RGB色值对应的灰度值。
|
||||
* [LUT Apply](#LUT), [TextImageV2](#TextImageV2), [TextImage](#TextImage), [SimpleTextImage](#SimpleTextImage) 等节点支持在 ```resource_dir.ini``` 中定义多个文件夹,之间用逗号,分号或者空格分隔。同时支持刷新实时更新。
|
||||
* 添加 [HumanPartsUltra](#HumanPartsUltra) 节点,用于人物肢体分割。本节点是基于[metal3d/ComfyUI_Human_Parts](https://github.com/metal3d/ComfyUI_Human_Parts) 的重新封装,感谢原作者。
|
||||
请从[百度网盘](https://pan.baidu.com/s/1-6uwH6RB0FhIVfa3qO7hhQ?pwd=d862) 或 [huggingface](https://huggingface.co/Metal3d/deeplabv3p-resnet50-human/tree/main) 下载模型文件并复制到 ```ComfyUI\models\onnx\human-parts``` 文件夹。
|
||||
* ObjectDetector 节点添加按置信度排序选项。
|
||||
@@ -437,7 +439,10 @@ os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
|
||||
* color_space: 普通图片请选择linear, log色彩空间的图片请选择log。
|
||||
* strength: 范围0~100, LUT应用强度。数值越大,与原图的差别越大, 数值越小,越接近原图。
|
||||
|
||||
<sup>*</sup><font size="3">LUT文件夹在```resource_dir.ini```中定义,这个文件位于插件根目录下, 默认名字是```resource_dir.ini.example```, 初次使用这个文件需将文件后缀改为.ini。用文本编辑软件打开,找到“LUT_dir=”开头的这一行,编辑“=”之后为自定义文件夹路径名。这个文件夹里面所有的.cube文件将在ComfyUI初始化时被收集并显示在节点的列表中。如果ini中设定的文件夹无效,将启用插件自带的LUT文件夹。</font>
|
||||
<sup>*</sup><font size="3">LUT文件夹在```resource_dir.ini```中定义,这个文件位于插件根目录下, 默认名字是```resource_dir.ini.example```, 初次使用这个文件需将文件后缀改为.ini。
|
||||
用文本编辑软件打开,找到“LUT_dir=”开头的这一行,编辑“=”之后为自定义文件夹路径名。这个文件夹里面所有的.cube文件将在ComfyUI初始化时被收集并显示在节点的列表中。
|
||||
支持定义多个文件夹,之间用逗号,分号或者空格分隔。
|
||||
如果ini中设定的文件夹无效,将启用插件自带的LUT文件夹。</font>
|
||||
|
||||
|
||||
### <a id="table1">AutoAdjust</a>
|
||||
@@ -941,7 +946,11 @@ ImageScaleByAspectRatio的V2升级版
|
||||
* font_file<sup>*</sup>: 字体文件。
|
||||
* border: 卷轴的边框宽度。
|
||||
* color_theme: 主题色。
|
||||
<sup>*</sup>font文件夹在```resource_dir.ini```中定义,这个文件位于插件根目录下, 默认名字是```resource_dir.ini.example```, 初次使用这个文件需将文件后缀改为.ini。用文本编辑软件打开,找到“FONT_dir=”开头的这一行,编辑“=”之后为自定义文件夹路径名。这个文件夹里面所有的.ttf和.otf文件将在ComfyUI初始化时被收集并显示在节点的列表中。如果ini中设定的文件夹无效,将启用插件自带的font文件夹。
|
||||
<sup>*</sup>font文件夹在```resource_dir.ini```中定义,这个文件位于插件根目录下, 默认名字是```resource_dir.ini.example```, 初次使用这个文件需将文件后缀改为.ini。
|
||||
用文本编辑软件打开,找到“FONT_dir=”开头的这一行,编辑“=”之后为自定义文件夹路径名。
|
||||
支持定义多个文件夹,之间用逗号,分号或者空格分隔。
|
||||
文件夹里面所有的.ttf和.otf文件将在ComfyUI初始化时被收集并显示在节点的列表中。
|
||||
如果ini中设定的文件夹无效,将启用插件自带的font文件夹。
|
||||
|
||||
### <a id="table1">ImageOpacity</a>
|
||||
调整图像不透明度。
|
||||
@@ -980,6 +989,17 @@ ImageScaleByAspectRatio的V2升级版
|
||||
节点选项说明:
|
||||
* color_value: 支持十六进制(HEX)或十进制(DEC)色值,应是string或tuple类型,强行接入其他类型将导致错误。
|
||||
|
||||
### <a id="table1">GrayValue</a>
|
||||
将色值输出灰度数值。支持输出256级和100级灰度值。
|
||||

|
||||
|
||||
节点选项说明:
|
||||
* color_value: 支持十六进制(HEX)或十进制(DEC)色值,应是string或tuple类型,强行接入其他类型将导致错误。
|
||||
|
||||
输出:
|
||||
* gray(256_level): 256级灰度值。整数类型,范围0~255。
|
||||
* gray(100_level): 100级灰度值。整数类型,范围0~100。
|
||||
|
||||
### <a id="table1">GetColorTone</a>
|
||||
从图片中获取主颜色或平均色。
|
||||

|
||||
@@ -1178,7 +1198,11 @@ GradientImage的V2升级版。
|
||||
* height: 画面的高度。如果有size_as输入,此设置将被忽略。
|
||||
|
||||
<sup>*</sup>仅限输入image和mask, 如果强制接入其他类型输入,将导致节点错误。
|
||||
<sup>**</sup>font文件夹在```resource_dir.ini```中定义,这个文件位于插件根目录下, 默认名字是```resource_dir.ini.example```, 初次使用这个文件需将文件后缀改为.ini。用文本编辑软件打开,找到“FONT_dir=”开头的这一行,编辑“=”之后为自定义文件夹路径名。这个文件夹里面所有的.ttf和.otf文件将在ComfyUI初始化时被收集并显示在节点的列表中。如果ini中设定的文件夹无效,将启用插件自带的font文件夹。
|
||||
<sup>**</sup>font文件夹在```resource_dir.ini```中定义,这个文件位于插件根目录下, 默认名字是```resource_dir.ini.example```, 初次使用这个文件需将文件后缀改为.ini。
|
||||
用文本编辑软件打开,找到“FONT_dir=”开头的这一行,编辑“=”之后为自定义文件夹路径名。
|
||||
支持定义多个文件夹,之间用逗号,分号或者空格分隔。
|
||||
文件夹里面所有的.ttf和.otf文件将在ComfyUI初始化时被收集并显示在节点的列表中。
|
||||
如果ini中设定的文件夹无效,将启用插件自带的font文件夹。
|
||||
|
||||
|
||||
### <a id="table1">TextImage</a>
|
||||
@@ -1203,7 +1227,11 @@ GradientImage的V2升级版。
|
||||
* background_color<sup>4</sup>: 背景颜色。
|
||||
|
||||
<sup>*</sup>仅限输入image和mask, 如果强制接入其他类型输入,将导致节点错误。
|
||||
<sup>**</sup>font文件夹在```resource_dir.ini```中定义,这个文件位于插件根目录下, 默认名字是```resource_dir.ini.example```, 初次使用这个文件需将文件后缀改为.ini。用文本编辑软件打开,找到“FONT_dir=”开头的这一行,编辑“=”之后为自定义文件夹路径名。这个文件夹里面所有的.ttf和.otf文件将在ComfyUI初始化时被收集并显示在节点的列表中。如果ini中设定的文件夹无效,将启用插件自带的font文件夹。
|
||||
<sup>**</sup>font文件夹在```resource_dir.ini```中定义,这个文件位于插件根目录下, 默认名字是```resource_dir.ini.example```, 初次使用这个文件需将文件后缀改为.ini。
|
||||
用文本编辑软件打开,找到“FONT_dir=”开头的这一行,编辑“=”之后为自定义文件夹路径名。
|
||||
支持定义多个文件夹,之间用逗号,分号或者空格分隔。
|
||||
文件夹里面所有的.ttf和.otf文件将在ComfyUI初始化时被收集并显示在节点的列表中。
|
||||
如果ini中设定的文件夹无效,将启用插件自带的font文件夹。
|
||||
|
||||
### <a id="table1">TextImageV2</a>
|
||||

|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
@@ -9,7 +9,11 @@ class ColorCorrectLUTapply:
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(self):
|
||||
(LUT_DICT, _) = get_resource_dir()
|
||||
LUT_LIST = list(LUT_DICT.keys())
|
||||
|
||||
color_space_list = ['linear', 'log']
|
||||
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE", ), #
|
||||
@@ -27,6 +31,9 @@ class ColorCorrectLUTapply:
|
||||
CATEGORY = '😺dzNodes/LayerColor'
|
||||
|
||||
def color_correct_LUTapply(self, image, LUT, color_space, strength):
|
||||
|
||||
(LUT_DICT, _) = get_resource_dir()
|
||||
log(f"LUT_DICT={LUT_DICT}")
|
||||
ret_images = []
|
||||
for i in image:
|
||||
i = torch.unsqueeze(i, 0)
|
||||
@@ -42,6 +49,9 @@ class ColorCorrectLUTapply:
|
||||
log(f"{NODE_NAME} Processed {len(ret_images)} image(s).", message_type='finish')
|
||||
return (torch.cat(ret_images, dim=0),)
|
||||
|
||||
|
||||
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"LayerColor: LUT Apply": ColorCorrectLUTapply
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
from .imagefunc import *
|
||||
|
||||
NODE_NAME = 'Gray Value'
|
||||
any = AnyType("*")
|
||||
|
||||
class ColorValuetoGrayValue:
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(self):
|
||||
|
||||
return {
|
||||
"required": {
|
||||
"color_value": (any, {}),
|
||||
},
|
||||
"optional": {
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("INT", "INT",)
|
||||
RETURN_NAMES = ("gray(256_level)", "gray(100_level)",)
|
||||
FUNCTION = 'color_value_to_gray_value'
|
||||
CATEGORY = '😺dzNodes/LayerUtility/Data'
|
||||
|
||||
def color_value_to_gray_value(self, color_value,):
|
||||
gray = rgb2gray(color_value)
|
||||
return (gray, int(gray / 2.55),)
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"LayerUtility: GrayValue": ColorValuetoGrayValue
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"LayerUtility: GrayValue": "LayerUtility: Gray Value"
|
||||
}
|
||||
+116
-28
@@ -1094,6 +1094,72 @@ def gamma_trans(image:Image, gamma:float) -> Image:
|
||||
_corrected = cv2.LUT(cv2_image,gamma_table)
|
||||
return cv22pil(_corrected)
|
||||
|
||||
|
||||
def read_LUT_IridasCube_encode_utf8(path: str):
|
||||
from colour.utilities import as_float_array, as_int_scalar
|
||||
from colour.io.luts.lut import LUT3x1D, LUT3D
|
||||
title = re.sub("_|-|\\.", " ", os.path.splitext(os.path.basename(path))[0])
|
||||
domain_min, domain_max = np.array([0, 0, 0]), np.array([1, 1, 1])
|
||||
dimensions: int = 3
|
||||
size: int = 2
|
||||
data = []
|
||||
comments = []
|
||||
|
||||
with open(path, encoding='utf-8') as cube_file:
|
||||
lines = cube_file.readlines()
|
||||
for line in lines:
|
||||
|
||||
line = line.strip() # noqa: PLW2901
|
||||
|
||||
if len(line) == 0:
|
||||
continue
|
||||
|
||||
if line.startswith("#"):
|
||||
comments.append(line[1:].strip())
|
||||
continue
|
||||
|
||||
tokens = line.split()
|
||||
if tokens[0] == "TITLE":
|
||||
title = " ".join(tokens[1:])[1:-1]
|
||||
elif tokens[0] == "DOMAIN_MIN":
|
||||
domain_min = as_float_array(tokens[1:])
|
||||
elif tokens[0] == "DOMAIN_MAX":
|
||||
domain_max = as_float_array(tokens[1:])
|
||||
elif tokens[0] == "LUT_1D_SIZE":
|
||||
dimensions = 2
|
||||
size = as_int_scalar(tokens[1])
|
||||
elif tokens[0] == "LUT_3D_SIZE":
|
||||
dimensions = 3
|
||||
size = as_int_scalar(tokens[1])
|
||||
else:
|
||||
data.append(tokens)
|
||||
|
||||
table = as_float_array(data)
|
||||
|
||||
LUT: LUT3x1D | LUT3D
|
||||
if dimensions == 2:
|
||||
LUT = LUT3x1D(
|
||||
table,
|
||||
title,
|
||||
np.vstack([domain_min, domain_max]),
|
||||
comments=comments,
|
||||
)
|
||||
elif dimensions == 3:
|
||||
# The lines of table data shall be in ascending index order,
|
||||
# with the first component index (Red) changing most rapidly,
|
||||
# and the last component index (Blue) changing least rapidly.
|
||||
table = table.reshape([size, size, size, 3], order="F")
|
||||
|
||||
LUT = LUT3D(
|
||||
table,
|
||||
title,
|
||||
np.vstack([domain_min, domain_max]),
|
||||
comments=comments,
|
||||
)
|
||||
|
||||
return LUT
|
||||
|
||||
|
||||
def apply_lut(image:Image, lut_file:str, colorspace:str, strength:int, clip_values:bool=True) -> Image:
|
||||
"""
|
||||
Apply a LUT to an image.
|
||||
@@ -1108,9 +1174,9 @@ def apply_lut(image:Image, lut_file:str, colorspace:str, strength:int, clip_valu
|
||||
if colorspace == "log":
|
||||
log_colorspace = True
|
||||
|
||||
from colour.io.luts.iridas_cube import read_LUT_IridasCube
|
||||
# from colour.io.luts.iridas_cube import read_LUT_IridasCube
|
||||
|
||||
lut = read_LUT_IridasCube(lut_file)
|
||||
lut = read_LUT_IridasCube_encode_utf8(lut_file)
|
||||
lut.name = lut_file
|
||||
|
||||
if clip_values:
|
||||
@@ -1969,6 +2035,12 @@ def extract_all_numbers_from_str(string, checkint:bool=False):
|
||||
|
||||
return number_list
|
||||
|
||||
|
||||
|
||||
# 提取字符串中用"," ";" " "分开的字符串, 返回为列表
|
||||
def extract_substr_from_str(string) -> list:
|
||||
return re.split(r'[,\s;,;]+', string)
|
||||
|
||||
def clear_memory():
|
||||
import gc
|
||||
# Cleanup
|
||||
@@ -2158,12 +2230,38 @@ def get_api_key(api_name:str) -> str:
|
||||
ret_value = ret_value.replace(i, '')
|
||||
if len(ret_value) < 4:
|
||||
log(f'Warning: Invalid API-key, Check the key in {api_key_ini_file}.', message_type='warning')
|
||||
|
||||
return ret_value
|
||||
|
||||
# 判断文件名后缀是否包括在列表中(忽略大小写)
|
||||
def file_is_extension(filename:str, ext_list:tuple) -> bool:
|
||||
# 获取文件的真实后缀(包括点)
|
||||
true_ext = os.path.splitext(filename)[1]
|
||||
if true_ext.lower() in ext_list:
|
||||
return True
|
||||
return False
|
||||
|
||||
# 遍历目录下包括子目录指定后缀文件,返回字典
|
||||
def collect_files(default_dir:str, root_dir:str, suffixes:tuple):
|
||||
result = {}
|
||||
for dirpath, _, filenames in os.walk(root_dir):
|
||||
for file in filenames:
|
||||
if file_is_extension(file, suffixes):
|
||||
# 获取文件的完整路径作为 value
|
||||
full_path = os.path.join(dirpath, file)
|
||||
# 如果是default_dir 则去掉路径,使用文件名作为 key
|
||||
if dirpath == default_dir:
|
||||
relative_path = os.path.relpath(full_path, root_dir)
|
||||
result.update({relative_path: full_path})
|
||||
else:
|
||||
result.update({full_path: full_path})
|
||||
return result
|
||||
|
||||
|
||||
def get_resource_dir() -> list:
|
||||
default_lut_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.normpath(__file__))), 'lut')
|
||||
default_font_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.normpath(__file__))), 'font')
|
||||
default_lut_dir = []
|
||||
default_lut_dir.append(os.path.join(os.path.dirname(os.path.dirname(os.path.normpath(__file__))), 'lut'))
|
||||
default_font_dir = []
|
||||
default_font_dir.append(os.path.join(os.path.dirname(os.path.dirname(os.path.normpath(__file__))), 'font'))
|
||||
resource_dir_ini_file = os.path.join(os.path.dirname(os.path.dirname(os.path.normpath(__file__))),
|
||||
"resource_dir.ini")
|
||||
try:
|
||||
@@ -2172,42 +2270,32 @@ def get_resource_dir() -> list:
|
||||
for line in ini:
|
||||
if line.startswith('LUT_dir='):
|
||||
_ldir = line[line.find('=') + 1:].rstrip().lstrip()
|
||||
if os.path.exists(_ldir):
|
||||
default_lut_dir = _ldir
|
||||
# else:
|
||||
# log(f'Invalid LUT directory, default to be used. check {resource_dir_ini_file}')
|
||||
for dir in extract_substr_from_str(_ldir) :
|
||||
if os.path.exists(dir):
|
||||
default_lut_dir.append(dir)
|
||||
elif line.startswith('FONT_dir='):
|
||||
_fdir = line[line.find('=') + 1:].rstrip().lstrip()
|
||||
if os.path.exists(_fdir):
|
||||
default_font_dir = _fdir
|
||||
# else:
|
||||
# log(f'Invalid FONT directory, default to be used. check {resource_dir_ini_file}')
|
||||
for dir in extract_substr_from_str(_fdir):
|
||||
if os.path.exists(_fdir):
|
||||
default_font_dir.append(_fdir)
|
||||
except Exception as e:
|
||||
# log(f'Warning: {resource_dir_ini_file} ' + repr(e) + f", default directory to be used. ")
|
||||
log(f'Warning: {resource_dir_ini_file} not found' + f", default directory to be used. ")
|
||||
|
||||
__lut_file_list = glob.glob(default_lut_dir + '/*.cube')
|
||||
LUT_DICT = {}
|
||||
for i in range(len(__lut_file_list)):
|
||||
_, __filename = os.path.split(__lut_file_list[i])
|
||||
LUT_DICT[__filename] = __lut_file_list[i]
|
||||
for dir in default_lut_dir:
|
||||
LUT_DICT.update(collect_files(default_lut_dir[0], dir, ('.cube'))) # 后缀要小写
|
||||
LUT_LIST = list(LUT_DICT.keys())
|
||||
log(f'Find {len(LUT_LIST)} LUTs in {default_lut_dir}')
|
||||
|
||||
__font_file_list = glob.glob(default_font_dir + '/*.ttf')
|
||||
__font_file_list.extend(glob.glob(default_font_dir + '/*.otf'))
|
||||
FONT_DICT = {}
|
||||
for i in range(len(__font_file_list)):
|
||||
_, __filename = os.path.split(__font_file_list[i])
|
||||
FONT_DICT[__filename] = __font_file_list[i]
|
||||
for dir in default_font_dir:
|
||||
FONT_DICT.update(collect_files(default_font_dir[0], dir, ('.ttf', '.otf'))) # 后缀要小写
|
||||
FONT_LIST = list(FONT_DICT.keys())
|
||||
log(f'Find {len(FONT_LIST)} Fonts in {default_font_dir}')
|
||||
|
||||
return (LUT_DICT, FONT_DICT)
|
||||
|
||||
(LUT_DICT, FONT_DICT) = get_resource_dir()
|
||||
FONT_LIST = list(FONT_DICT.keys())
|
||||
LUT_LIST = list(LUT_DICT.keys())
|
||||
# (LUT_DICT, FONT_DICT) = get_resource_dir()
|
||||
# FONT_LIST = list(FONT_DICT.keys())
|
||||
# LUT_LIST = list(LUT_DICT.keys())
|
||||
|
||||
# def get_models_dir() -> dict:
|
||||
# models_dir_ini_file = os.path.join(os.path.dirname(os.path.dirname(os.path.normpath(__file__))), "models_dir.ini")
|
||||
|
||||
+1
-1
@@ -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.60"
|
||||
version = "1.0.62"
|
||||
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"]
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
FONT_dir=C:\font
|
||||
LUT_dir=C:\lut
|
||||
FONT_dir=C:\font,C:\another\font
|
||||
LUT_dir=C:\lut,C:\another\lut
|
||||
Reference in New Issue
Block a user