Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kning committed Sep 18, 2024
1 parent 15374b6 commit d246638
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 @@ -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():
Expand All @@ -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"]
Expand Down

0 comments on commit d246638

Please sign in to comment.