垃圾回收与解决PIL新老版本不一
This commit is contained in:
+27
-1
@@ -1250,8 +1250,33 @@ class ToPixel:
|
||||
pixelated_image.putpixel((j // tile_size, i // tile_size), tuple(dominant_color.astype(int)))
|
||||
|
||||
pixelated_image = imgToTensor(pixelated_image)
|
||||
garbage_collect()
|
||||
return (pixelated_image,)
|
||||
|
||||
class StringListToOneLine:
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"StringList": ("STRING", {"forceInput": True}),
|
||||
"split":("STRING", {"default": ","})
|
||||
},
|
||||
}
|
||||
|
||||
CATEGORY = "badger"
|
||||
RETURN_TYPES = ("STRING",)
|
||||
FUNCTION = "string_line"
|
||||
OUTPUT_NODE = True
|
||||
|
||||
def string_line(self,StringList,split):
|
||||
print(len(StringList))
|
||||
if len(StringList) <= 1:
|
||||
return (StringList,)
|
||||
else :
|
||||
return (split.join(StringList),)
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"ImageOverlap-badger": ImageOverlap,
|
||||
@@ -1282,7 +1307,8 @@ NODE_CLASS_MAPPINGS = {
|
||||
"IdentifyColorToMask-badger":IdentifyColorToMask,
|
||||
"IdentifyBorderColorToMask-badger":IdentifyBorderColorToMask,
|
||||
"GarbageCollect-badger": GarbageCollect,
|
||||
"ToPixel-badger": ToPixel
|
||||
"ToPixel-badger": ToPixel,
|
||||
"StringListToOneLine-badger": StringListToOneLine
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,10 @@ def regular_image(original_image, output_size=(512, 512), fill_color=(255, 255,
|
||||
new_height = int(original_height * ratio)
|
||||
|
||||
# 等比缩放图片
|
||||
original_image = original_image.resize((new_width, new_height), Image.ANTIALIAS)
|
||||
try:
|
||||
original_image = original_image.resize((new_width, new_height), Image.Resampling.LANCZOS)
|
||||
except Exception as e:
|
||||
original_image = original_image.resize((new_width, new_height), Image.ANTIALIAS)
|
||||
|
||||
# 创建一个新的白色背景图片
|
||||
new_img = Image.new("RGB", output_size, fill_color)
|
||||
|
||||
Reference in New Issue
Block a user