Add files via upload
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from PIL import Image
|
||||
import numpy as np
|
||||
import torch
|
||||
|
||||
class IfImageValid:
|
||||
def __init__(self):
|
||||
@@ -25,9 +25,10 @@ class IfImageValid:
|
||||
elif else_Image is not None:
|
||||
return (else_Image,)
|
||||
else:
|
||||
return (Image.fromarray(np.zeros((512, 512, 3), dtype=np.uint8)),)
|
||||
black_image = torch.zeros((1, 32, 32, 3), dtype=torch.uint8)
|
||||
return (black_image,)
|
||||
|
||||
# Mapping de la classe
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"If Image Valid": IfImageValid,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
class IsImageValid:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"optional": {
|
||||
"image": ("IMAGE",), # Type d'entrée défini comme IMAGE
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("BOOL",)
|
||||
RETURN_NAMES = ("is_valid",)
|
||||
FUNCTION = "check_is_valid"
|
||||
CATEGORY = "Fictiverse"
|
||||
|
||||
def check_is_valid(self, image=None):
|
||||
# Retourne False si l'image est None, sinon True
|
||||
return (image is not None,)
|
||||
|
||||
# Mapping de la classe
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"Is Image Valid ?": IsImageValid,
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import torch
|
||||
import numpy as np
|
||||
|
||||
class NoneIfSameImage:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"optional": {
|
||||
"image": ("IMAGE",),
|
||||
"compare": ("IMAGE",),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE", "BOOL",)
|
||||
RETURN_NAMES = ("IMAGE", "is_same",)
|
||||
FUNCTION = "checkIfSameImage"
|
||||
CATEGORY = "Fictiverse"
|
||||
|
||||
def checkIfSameImage(self, image=None, compare=None):
|
||||
if image is None and compare is None:
|
||||
black_image = torch.zeros((1, 32, 32, 3), dtype=torch.uint8)
|
||||
return (black_image, False)
|
||||
|
||||
if image is None:
|
||||
return (compare, False)
|
||||
|
||||
if compare is None:
|
||||
return (image, False)
|
||||
|
||||
if torch.equal(image, compare):
|
||||
black_image = torch.zeros((1, 32, 32, 3), dtype=torch.uint8)
|
||||
return (black_image, True)
|
||||
|
||||
return (image, False)
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"None if same Image": NoneIfSameImage,
|
||||
}
|
||||
Reference in New Issue
Block a user