diff --git a/06_gpu_and_ml/comfyui/comfyapp.py b/06_gpu_and_ml/comfyui/comfyapp.py index 8e015e698..178e77860 100644 --- a/06_gpu_and_ml/comfyui/comfyapp.py +++ b/06_gpu_and_ml/comfyui/comfyapp.py @@ -131,9 +131,11 @@ def infer(self, workflow_path: str = "/root/workflow_api.json"): output_dir = "/root/comfy/ComfyUI/output" # looks up the name of the output image file based on the workflow workflow = json.loads(Path(workflow_path).read_text()) - file_prefix = [node.get("inputs") for node in workflow.values() if node.get("class_type") == "SaveImage"][0][ - "filename_prefix" - ] + file_prefix = [ + node.get("inputs") + for node in workflow.values() + if node.get("class_type") == "SaveImage" + ][0]["filename_prefix"] # returns the image as bytes for f in Path(output_dir).iterdir(): @@ -144,7 +146,9 @@ def infer(self, workflow_path: str = "/root/workflow_api.json"): def api(self, item: Dict): from fastapi import Response - workflow_data = json.loads((Path(__file__).parent / "workflow_api.json").read_text()) + workflow_data = json.loads( + (Path(__file__).parent / "workflow_api.json").read_text() + ) # insert the prompt workflow_data["6"]["inputs"]["text"] = item["prompt"]