Delete workflow/lib directory

This commit is contained in:
Cyber-BlackCat
2025-03-12 17:04:44 +08:00
committed by GitHub
parent 64da7155d9
commit c2af538cdf
5 changed files with 0 additions and 256 deletions
View File
-70
View File
@@ -1,70 +0,0 @@
[
{
"name": "replace_character_names",
"prompt": "If there is a person/character in the image you must refer to them as {name}."
},
{
"name": "exclude_unchangeable_attributes",
"prompt": "Do NOT include information about people/characters that cannot be changed (like ethnicity, gender, etc), but do still include changeable attributes (like hair style)."
},
{
"name": "include_lighting_details",
"prompt": "Include information about lighting."
},
{
"name": "include_camera_angle",
"prompt": "Include information about camera angle."
},
{
"name": "mention_watermark_presence",
"prompt": "Include information about whether there is a watermark or not."
},
{
"name": "note_jpeg_artifacts",
"prompt": "Include information about whether there are JPEG artifacts or not."
},
{
"name": "include_exif_data",
"prompt": "If it is a photo you MUST include information about what camera was likely used and details such as aperture, shutter speed, ISO, etc."
},
{
"name": "exclude_sexual_content",
"prompt": "Do NOT include anything sexual; keep it PG."
},
{
"name": "exclude_image_resolution",
"prompt": "Do NOT mention the image's resolution."
},
{
"name": "describe_aesthetic_quality",
"prompt": "You MUST include information about the subjective aesthetic quality of the image from low to very high."
},
{
"name": "include_composition_style",
"prompt": "Include information on the image's composition style, such as leading lines, rule of thirds, or symmetry."
},
{
"name": "exclude_text_elements",
"prompt": "Do NOT mention any text that is in the image."
},
{
"name": "specify_depth_of_field",
"prompt": "Specify the depth of field and whether the background is in focus or blurred."
},
{
"name": "specify_lighting_sources",
"prompt": "If applicable, mention the likely use of artificial or natural lighting sources."
},
{
"name": "avoid_ambiguous_language",
"prompt": "Do NOT use any ambiguous language."
},
{
"name": "classify_image_as_sfw_nsfw",
"prompt": "Include whether the image is sfw, suggestive, or nsfw."
},
{
"name": "describe_key_elements_only",
"prompt": "ONLY describe the most important elements of the image."
}
]
-34
View File
@@ -1,34 +0,0 @@
import folder_paths
import os
import base64
import numpy as np
from PIL import Image,ImageOps, ImageFilter
import io
comfy_path = os.path.dirname(folder_paths.__file__)
custom_nodes_path = os.path.join(comfy_path, "custom_nodes")
# D:\comfyui\ComfyUI_windows_portable\ComfyUI\custom_nodes\Comfyui_CXH_ALY
# current_folder = os.path.dirname(os.path.abspath(__file__))
# 节点路径
def node_path(node_name):
return os.path.join(custom_nodes_path,node_name)
# 创建文件夹
def mkdir(path):
folder = os.path.exists(path)
if not folder: #判断是否存在文件夹如果不存在则创建为文件夹
os.makedirs(path) #makedirs 创建文件时如果路径不存在会创建这个路径
# 获取所有图片文件路径
def get_all_image_paths(directory):
image_paths = []
for root, dirs, files in os.walk(directory):
for file in files:
if file.lower().endswith(('.png', '.jpg', '.jpeg')):
image_paths.append(os.path.join(root, file))
return image_paths
-129
View File
@@ -1,129 +0,0 @@
# -*- encoding: utf-8 -*-
'''
@File :ximg.py
@Description :图片转换工具
'''
import os
import torch
from PIL import Image, ImageOps, ImageSequence, ImageFile,UnidentifiedImageError
import numpy as np
import cv2 as cv
import io
import base64
import requests
from io import BytesIO
def tensor2pil(t_image: torch.Tensor) -> Image:
return Image.fromarray(
np.clip(255.0 * t_image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8))
def pil2tensor(image:Image) -> torch.Tensor:
return torch.from_numpy(np.array(image).astype(np.float32) / 255.0).unsqueeze(0)
def tensor2cv2(image:torch.Tensor) -> np.array:
if image.dim() == 4:
image = image.squeeze()
npimage = image.numpy()
cv2image = np.uint8(npimage * 255 / npimage.max())
return cv.cvtColor(cv2image, cv.COLOR_RGB2BGR)
def cv22pil(cv2_img:np.ndarray) -> Image:
cv2_img = cv.cvtColor(cv2_img, cv.COLOR_BGR2RGB)
return Image.fromarray(cv2_img)
# pil转io
def pil2iobyte(pil_image,format='PNG'):
byte_arr = io.BytesIO()
pil_image.save(byte_arr, format=format)
byte_arr = byte_arr.getvalue()
return byte_arr
# pil转64
def pilTobase64(pil_image,format='PNG'):
byte_arr = pil2iobyte(pil_image,format)
image_base64 = base64.b64encode(byte_arr).decode('utf-8')
return image_base64
def ioBytes2tensor(bytes):
image = Image.open(bytes)
return pil2tensor(image)
def getImageSize(image):
if image.shape[0] > 0:
image = torch.unsqueeze(image[0], 0)
_image = tensor2pil(image)
return (_image.width, _image.height)
# 转成mask
def imageToMask(img):
i = img
if i.mode == 'I':
i = i.point(lambda i: i * (1 / 255))
image = i.convert("RGB")
image = np.array(image).astype(np.float32) / 255.0
image = torch.from_numpy(image)[None,]
if 'A' in i.getbands():
mask = np.array(i.getchannel('A')).astype(np.float32) / 255.0
mask = 1. - torch.from_numpy(mask)
else:
mask = torch.zeros((64,64), dtype=torch.float32, device="cpu")
return tensor2pil(mask)
# ret_masks.append(image2mask(_mask))
def image2mask(image:Image) -> torch.Tensor:
_image = image.convert('RGBA')
alpha = _image.split() [0]
bg = Image.new("L", _image.size)
_image = Image.merge('RGBA', (bg, bg, bg, alpha))
ret_mask = torch.tensor([pil2tensor(_image)[0, :, :, 3].tolist()])
return ret_mask
# 图像回帖
def croppImg(original_image,cropped_avatar,left_x,top_y):
# 获取原始图像的大小
original_width, original_height = original_image.size
return croppImageBySize(cropped_avatar,left_x,top_y,original_width,original_height)
def croppImageBySize(cropped_avatar,left_x,top_y,original_w,original_h):
# 获取原始图像的大小
original_width, original_height = original_w,original_h
# 获取头像的大小
avatar_width, avatar_height = cropped_avatar.size
# 创建一个与原始图像相同大小的透明图像
extended_image = Image.new("RGBA", (original_width, original_height), (0, 0, 0, 0))
# 将裁剪后的头像粘贴到新图像
extended_image.paste(cropped_avatar, (left_x, top_y), cropped_avatar)
return extended_image
# 将图片转换为Base64编码
def image_to_base64(image_path):
with open(image_path, 'rb') as image_file:
return base64.b64encode(image_file.read()).decode('utf-8')
# 获取网络图片
def img_from_url(url):
# 发送HTTP请求获取图片
response = requests.get(url)
response.raise_for_status() # 如果请求失败,这会抛出异常
# 将响应内容作为BytesIO对象打开,以便PIL可以读取它
image = Image.open(BytesIO(response.content))
return image
def open_image(path):
prev_value = None
try:
img = Image.open(path)
except (UnidentifiedImageError, ValueError): #PIL issues #4472 and #2445
prev_value = ImageFile.LOAD_TRUNCATED_IMAGES
ImageFile.LOAD_TRUNCATED_IMAGES = True
img = Image.open(path)
finally:
if prev_value is not None:
ImageFile.LOAD_TRUNCATED_IMAGES = prev_value
return img
-23
View File
@@ -1,23 +0,0 @@
import os
import folder_paths
import json
from transformers import AutoProcessor
# 下载hg 模型到本地
def download_hg_model(model_id:str,exDir:str=''):
# 下载本地
model_checkpoint = os.path.join(folder_paths.models_dir, exDir, os.path.basename(model_id))
print(model_checkpoint)
if not os.path.exists(model_checkpoint):
from huggingface_hub import snapshot_download
snapshot_download(repo_id=model_id, local_dir=model_checkpoint, local_dir_use_symlinks=False)
return model_checkpoint
# clip_model = AutoModelForCausalLM.from_pretrained(
# CLIP_PATH,
# device_map="cuda",
# trust_remote_code=True,
# torch_dtype="auto"
# )
# clip_processor = AutoProcessor.from_pretrained(CLIP_PATH, trust_remote_code=True)