diff --git a/routes.py b/routes.py index 8641ed5..1c0161f 100644 --- a/routes.py +++ b/routes.py @@ -299,18 +299,18 @@ async def post_prompt_block(request): api_prompt = json.loads(workflow) # skip generation part if base_image is provided - # if base_image is not None: - # for value in api_prompt.values(): - # if ( - # value["class_type"] == "LoadImageFromRequest" - # and value["inputs"]["name"] == image_path - # ): - # del value["inputs"]["image"] - # elif ( - # value["class_type"] == "PreviewImage" - # or value["class_type"] == "SaveImage" - # ): - # del value["inputs"]["images"] + if base_image is not None: + for value in api_prompt.values(): + if ( + value["class_type"] == "LoadImageFromRequest" + and value["inputs"]["name"] == image_path + ): + del value["inputs"]["image"] + elif ( + value["class_type"] == "PreviewImage" + or value["class_type"] == "SaveImage" + ): + value["inputs"] = {} res = post_prompt({"prompt": api_prompt}) prompt_id = json.loads(res.text)["prompt_id"] diff --git a/sam/sam_multilayer.py b/sam/sam_multilayer.py index 6b6bc66..3a7bfbd 100644 --- a/sam/sam_multilayer.py +++ b/sam/sam_multilayer.py @@ -280,7 +280,7 @@ class SAMMultiLayer: return imagePromptsMulti, boxesMulti def load_image(self, image, ckpt, embedding_id, image_prompts_json): - image_prompts = json.loads(image_prompts_json) + image_prompts = json.loads(image_prompts_json.replace("'", '"')) order_file = f"{self.output_dir}/segments_{embedding_id}/order.json" if os.path.exists(order_file): @@ -337,7 +337,7 @@ class SAMMultiLayer: imagePromptsMulti, boxesMulti = self.detect_face(image[0].numpy()) - image_prompts = json.loads(image_prompts_json) + image_prompts = json.loads(image_prompts_json.replace("'", '"')) result = [image_prompts] if isinstance(image_prompts, list):