def init_comfy( comfyui_path = "/home/dmarx/projects/ComfyUI" ): # 1. add ComyUI to path import sys sys.path.append(comfyui_path) # 2. ensure cli parser doesn't cause issues from comfy.options import enable_args_parsing enable_args_parsing(False) # 3. spin up custom nodes and prompt server import asyncio import server import execution from nodes import init_custom_nodes loop = asyncio.get_event_loop() server_instance = server.PromptServer(loop) execution.PromptQueue(server_instance) init_custom_nodes() init_comfy() from nodes import NODE_CLASS_MAPPINGS import torch with torch.inference_mode(): image_load = NODE_CLASS_MAPPINGS["Image Load"]() clipseg = NODE_CLASS_MAPPINGS["CLIPSeg"]() input_image_data = image_load.load_image( image_path="/home/dmarx/projects/whats-in-a-name/images/a_photo_of_adele_portrait_photography_full_color_face_full_frame/1695441053_3.png", RGBA="false", filename_text_extension="true", )[0] hair_mask = clipseg.segment_image( image=input_image_data, text="hair", blur=7, threshold=0.4, dilation_factor=4, )[0]