Skip to content

Commit

Permalink
ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
kning committed Sep 16, 2024
1 parent 4bc3b11 commit 5a560c5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions 06_gpu_and_ml/comfyui/comfyapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,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():
Expand All @@ -145,7 +147,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"]
Expand Down

0 comments on commit 5a560c5

Please sign in to comment.