Skip to content

Commit

Permalink
Support Execution inversion (#329)
Browse files Browse the repository at this point in the history
Added forLoop node, ifElse, batchAnything, anythingIndexSwitch...
  • Loading branch information
yolain authored Aug 22, 2024
2 parents 9137228 + ba701d1 commit df91882
Show file tree
Hide file tree
Showing 8 changed files with 654 additions and 82 deletions.
13 changes: 0 additions & 13 deletions py/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from folder_paths import get_directory_by_type
from server import PromptServer
from .config import RESOURCES_DIR, FOOOCUS_STYLES_DIR, FOOOCUS_STYLES_SAMPLES
from .logic import ConvertAnything
from .libs.model import easyModelManager
from .libs.utils import getMetadata, cleanGPUUsedForce, get_local_filepath
from .libs.cache import remove_cache
Expand Down Expand Up @@ -123,18 +122,6 @@ async def getStylesImage(request):
return web.Response(text=FOOOCUS_STYLES_SAMPLES + name + '.jpg')
return web.Response(status=400)

# convert type
@PromptServer.instance.routes.post("/easyuse/convert")
async def convertType(request):
post = await request.post()
type = post.get('type')
if type:
ConvertAnything.RETURN_TYPES = (type.upper(),)
ConvertAnything.RETURN_NAMES = (type,)
return web.Response(status=200)
else:
return web.Response(status=400)

# get models lists
@PromptServer.instance.routes.get("/easyuse/models/list")
async def getModelsList(request):
Expand Down
82 changes: 40 additions & 42 deletions py/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -1523,46 +1523,46 @@ def listdir(path, dir_name=''):


# 姿势编辑器
class poseEditor:
@classmethod
def INPUT_TYPES(self):
temp_dir = folder_paths.get_temp_directory()

if not os.path.isdir(temp_dir):
os.makedirs(temp_dir)

temp_dir = folder_paths.get_temp_directory()

return {"required":
{"image": (sorted(os.listdir(temp_dir)),)},
}

RETURN_TYPES = ("IMAGE",)
FUNCTION = "output_pose"

CATEGORY = "EasyUse/Image"

def output_pose(self, image):
image_path = os.path.join(folder_paths.get_temp_directory(), image)
# print(f"Create: {image_path}")

i = Image.open(image_path)
image = i.convert("RGB")
image = np.array(image).astype(np.float32) / 255.0
image = torch.from_numpy(image)[None,]

return (image,)

@classmethod
def IS_CHANGED(self, image):
image_path = os.path.join(
folder_paths.get_temp_directory(), image)
# print(f'Change: {image_path}')

m = hashlib.sha256()
with open(image_path, 'rb') as f:
m.update(f.read())
return m.digest().hex()
# class poseEditor:
# @classmethod
# def INPUT_TYPES(self):
# temp_dir = folder_paths.get_temp_directory()
#
# if not os.path.isdir(temp_dir):
# os.makedirs(temp_dir)
#
# temp_dir = folder_paths.get_temp_directory()
#
# return {"required":
# {"image": (sorted(os.listdir(temp_dir)),)},
# }
#
# RETURN_TYPES = ("IMAGE",)
# FUNCTION = "output_pose"
#
# CATEGORY = "EasyUse/🚫 Deprecated"
#
# def output_pose(self, image):
# image_path = os.path.join(folder_paths.get_temp_directory(), image)
# # print(f"Create: {image_path}")
#
# i = Image.open(image_path)
# image = i.convert("RGB")
# image = np.array(image).astype(np.float32) / 255.0
# image = torch.from_numpy(image)[None,]
#
# return (image,)
#
# @classmethod
# def IS_CHANGED(self, image):
# image_path = os.path.join(
# folder_paths.get_temp_directory(), image)
# # print(f'Change: {image_path}')
#
# m = hashlib.sha256()
# with open(image_path, 'rb') as f:
# m.update(f.read())
# return m.digest().hex()

NODE_CLASS_MAPPINGS = {
"easy imageInsetCrop": imageInsetCrop,
Expand Down Expand Up @@ -1595,7 +1595,6 @@ def IS_CHANGED(self, image):
"easy joinImageBatch": JoinImageBatch,
"easy humanSegmentation": humanSegmentation,
"easy removeLocalImage": removeLocalImage,
"easy poseEditor": poseEditor
}

NODE_DISPLAY_NAME_MAPPINGS = {
Expand Down Expand Up @@ -1630,5 +1629,4 @@ def IS_CHANGED(self, image):
"easy imageToBase64": "Image To Base64",
"easy humanSegmentation": "Human Segmentation",
"easy removeLocalImage": "Remove Local Image",
"easy poseEditor": "PoseEditor",
}
Loading

0 comments on commit df91882

Please sign in to comment.