Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Bug in getting the output back. #65

Open
landon2022 opened this issue Sep 8, 2024 · 2 comments
Open

[BUG]: Bug in getting the output back. #65

landon2022 opened this issue Sep 8, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@landon2022
Copy link

landon2022 commented Sep 8, 2024

Describe the bug
Hello!
In the source code:
`def process_output_images(outputs, job_id):
output_images = {}

for node_id, node_output in outputs.items():
    if "images" in node_output:
        for image in node_output["images"]:
               output_images = os.path.join(image["subfolder"], image["filename"])
print(f"runpod-worker-comfy - image generation is done")

# expected image output folder

local_image_path = f"{COMFY_OUTPUT_PATH}/{output_images}"

print(f"runpod-worker-comfy - {local_image_path}")

# The image is in the output folder
if os.path.exists(local_image_path):
    if os.environ.get("BUCKET_ENDPOINT_URL", False):
        # URL to image in AWS S3
        image = rp_upload.upload_image(job_id, local_image_path)
        print(
            "runpod-worker-comfy - the image was generated and uploaded to AWS S3"
        )
    else:
        # base64 image
        image = base64_encode(local_image_path)
        print(
            "runpod-worker-comfy - the image was generated and converted to base64"
        )

    return {
        "status": "success",
        "message": image,
    }
else:
    print("runpod-worker-comfy - the image does not exist in the output folder")
    return {
        "status": "error",
        "message": f"the image does not exist in the specified output folder: {local_image_path}",
    }

`
The outputs will also include the temp preview output images, the function only takes the last output as the final path, and when loop through all the outputs somtimes you might get temp image as the output, thus cause no image found error at the comfyui/output path. Since temp images are stored in comfyui/temp not comfyui/output. So a output double check may needed Or disable all the previews in the workflow.

Screenshot 2024-09-08 at 11 02 42
Screenshot 2024-09-08 at 11 07 47
Screenshot 2024-09-08 at 11 08 06

@landon2022 landon2022 added the bug Something isn't working label Sep 8, 2024
@billyberkouwer
Copy link

I came up against this issue too - it caused some real headaches for my project. I found it sometimes returned the filename with a temp substring in it (e.g. COMFY_temp_esunj_0001_.png or COMFY_temp_brqas_0008_.png).

My hacky solution for this was to edit the Python code to include a function that checks for whether the filename includes a substring that follows this pattern and to remove it from the filename, because the COMFY_0008_.png image does exist. I'm a Javascript developer not normally working in Python so it was a challenge to debug the source of the issue, but even though it isn't not a great solution it has worked for me since.

@landon2022 Your solution looks much cleaner and has found the source of the issue. Is the only addition you made to resolve this the line? -

if image['type'] == "output":

Or is there additional code needed to add the 'type' key/value to the output object?

@landon2022
Copy link
Author

landon2022 commented Oct 3, 2024

I came up against this issue too - it caused some real headaches for my project. I found it sometimes returned the filename with a temp substring in it (e.g. COMFY_temp_esunj_0001_.png or COMFY_temp_brqas_0008_.png).

My hacky solution for this was to edit the Python code to include a function that checks for whether the filename includes a substring that follows this pattern and to remove it from the filename, because the COMFY_0008_.png image does exist. I'm a Javascript developer not normally working in Python so it was a challenge to debug the source of the issue, but even though it isn't not a great solution it has worked for me since.

@landon2022 Your solution looks much cleaner and has found the source of the issue. Is the only addition you made to resolve this the line? -

if image['type'] == "output":

Or is there additional code needed to add the 'type' key/value to the output object?

Yes. If there is only one Save image node in your workflow, this line of code would suffice. But if your workflow contains more than one save image node, you need to change the source code to return all the saved images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants