Skip to content

Unable to execute comfyscript when called via function #65

@dhiraj-salian

Description

@dhiraj-salian

I am trying to write a script using comfyscript to generate images.
When the comfyscript is called using function it throws the following error:

Failed to validate prompt for output SaveImage.0:
* CheckpointLoaderSimple CheckpointLoaderSimple.0:
  - Value not in list: ckpt_name: 'artium_v20Turboboosted.safetensors' not in (list of length 35)
Output will be ignored
invalid prompt: {'type': 'prompt_outputs_failed_validation', 'message': 'Prompt outputs failed validation', 'details': '', 'extra_info': {}}
ComfyScript: Failed to queue prompt: <ClientResponse(http://127.0.0.1:8188/prompt) [400 Bad Request]>
<CIMultiDictProxy('Content-Type': 'application/json; charset=utf-8', 'Content-Length': '545', 'Date': 'Fri, 16 Aug 2024 14:07:58 GMT', 'Server': 'Python/3.11 aiohttp/3.10.3')>
<ClientResponse(http://127.0.0.1:8188/prompt) [400 Bad Request]>
<CIMultiDictProxy('Content-Type': 'application/json; charset=utf-8', 'Content-Length': '545', 'Date': 'Fri, 16 Aug 2024 14:07:58 GMT', 'Server': 'Python/3.11 aiohttp/3.10.3')>
{
  "error": {
    "type": "prompt_outputs_failed_validation",
    "message": "Prompt outputs failed validation",
    "details": "",
    "extra_info": {}
  },
  "node_errors": {
    "CheckpointLoaderSimple.0": {
      "errors": [
        {
          "type": "value_not_in_list",
          "message": "Value not in list",
          "details": "ckpt_name: 'artium_v20Turboboosted.safetensors' not in (list of length 35)",
          "extra_info": {
            "input_name": "ckpt_name",
            "input_config": null,
            "received_value": "artium_v20Turboboosted.safetensors"
          }
        }
      ],
      "dependent_outputs": [
        "SaveImage.0"
      ],
      "class_type": "CheckpointLoaderSimple"
    }
  }
}

Steps to reproduce:

  • main.py : Executing main.py fails with the above error
import image

def main(name: str):
    prompt = "Dark, misty forest with twisted tree branches like skeletal fingers reaching towards a full moon hanging low in the sky, casting an eerie glow on a worn dirt path that winds through the trees. The air is heavy with the scent of damp earth and decaying leaves. In the distance, a faint light flickers from a lantern hung outside a small, weathered cottage, its windows like empty eyes staring back at you."
    image.generate_image(prompt, name)


if __name__ == "__main__":
    main("story1")
  • image.py: Executing image.py succeeds
from comfy_script.runtime import load, Workflow

load("comfyui")

from comfy_script.runtime.nodes import (
    CheckpointLoaderSimple,
    CLIPTextEncode,
    EmptyLatentImage,
    KSampler,
    VAEDecode,
    SaveImage,
)

negative_prompt = "ugly, deformed, noisy, blurry, noisy, low contrast (((bad anatomy))) watermark,  bad hands, (((incomplete limbs))) ((((looking at viewer))))(((bad anatomy))) ((exaggerated anatomy))"


def generate_image(positive_prompt: str, output: str):
    global negative_prompt

    with Workflow():
        model, clip, vae = CheckpointLoaderSimple("artium_v20Turboboosted.safetensors")
        positive_conditioning = CLIPTextEncode(positive_prompt, clip)
        negative_conditioning = CLIPTextEncode(negative_prompt, clip)
        latent = EmptyLatentImage(1024, 576, 1)
        latent = KSampler(
            model,
            156680208700286,
            20,
            7,
            "dpmpp_2m",
            "karras",
            positive_conditioning,
            negative_conditioning,
            latent,
            1,
        )
        image = VAEDecode(latent, vae)
        SaveImage(image, output)

if __name__ == "__main__":
    prompt = "Dark, misty forest with twisted tree branches like skeletal fingers reaching towards a full moon hanging low in the sky, casting an eerie glow on a worn dirt path that winds through the trees. The air is heavy with the scent of damp earth and decaying leaves. In the distance, a faint light flickers from a lantern hung outside a small, weathered cottage, its windows like empty eyes staring back at you."
    generate_image(prompt, "story1")

I have tried to play around by moving load() and Workflow() to main.py but was facing the same issue.
Please help check if I am missing something.

Thanks for the help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpendingPending ComfyUI or custom node changesruntime

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions