Optimize Image Processing with the ComfyUI Workflow on NVIDIA A100

Integrating advanced image processing capabilities into your applications has never been easier, thanks to the fofr/any-comfyui-workflow-a100 Cognitive Actions. Designed for developers looking to leverage the power of NVIDIA A100 GPUs, these pre-built actions allow you to execute ComfyUI workflows efficiently. With support for various model weights and customizable inputs, you can streamline your workflows and enhance performance without extensive setup.
Prerequisites
Before diving into the integration of Cognitive Actions, ensure you have the following:
- API Key: Obtain your Cognitive Actions API key to authenticate your requests.
- Basic JSON Knowledge: Familiarity with JSON structure is helpful for crafting your input payloads.
Authentication typically involves passing your API key in the headers of your requests.
Cognitive Actions Overview
Execute ComfyUI Workflow on A100
Description: This action allows you to run any ComfyUI workflow on an NVIDIA A100 GPU, optimizing performance for various image processing tasks. It supports customizable JSON inputs and allows file inputs through URLs or uploads.
Category: Image Processing
Input
The input for this action is structured as follows:
- inputFile (string, optional): The input file can be an image, tar, or zip file. You can also provide URLs for the model to download the files. More guidance here.
- outputFormat (string, optional): Specifies the format for output images. Options include
webp,jpg, andpng, withwebpas the default. - workflowJson (string, required): Defines your ComfyUI workflow as a JSON string. Obtain this from ComfyUI by selecting ‘Save (API format)’. Instructions available here.
- outputQuality (integer, optional): Determines the quality of the output images (0 to 100), with a default value of 95.
- randomiseSeeds (boolean, optional): When true, seeds are randomized. Default is true.
- forceResetCache (boolean, optional): Resets the ComfyUI cache before executing the workflow. Useful for debugging, defaults to false.
- returnTempFiles (boolean, optional): Returns temporary files useful for debugging. Defaults to false.
Example Input:
{
"outputFormat": "webp",
"workflowJson": "{\n \"3\": {\n \"inputs\": {\n \"seed\": 156680208700286,\n \"steps\": 10,\n \"cfg\": 2.5,\n \"sampler_name\": \"dpmpp_2m_sde\",\n \"scheduler\": \"karras\",\n \"denoise\": 1,\n \"model\": [\n \"4\",\n 0\n ],\n \"positive\": [\n \"6\",\n 0\n ],\n \"negative\": [\n \"7\",\n 0\n ],\n \"latent_image\": [\n \"5\",\n 0\n ]\n },\n \"class_type\": \"KSampler\",\n \"_meta\": {\n \"title\": \"KSampler\"\n }\n },\n \"4\": {\n \"inputs\": {\n \"ckpt_name\": \"SDXL-Flash.safetensors\"\n },\n \"class_type\": \"CheckpointLoaderSimple\",\n \"_meta\": {\n \"title\": \"Load Checkpoint\"\n }\n },\n \"5\": {\n \"inputs\": {\n \"width\": 1024,\n \"height\": 1024,\n \"batch_size\": 1\n },\n \"class_type\": \"EmptyLatentImage\",\n \"_meta\": {\n \"title\": \"Empty Latent Image\"\n }\n },\n \"6\": {\n \"inputs\": {\n \"text\": \"beautiful scenery nature glass bottle landscape, purple galaxy bottle,\",\n \"clip\": [\n \"4\",\n 1\n ]\n },\n \"class_type\": \"CLIPTextEncode\",\n \"_meta\": {\n \"title\": \"CLIP Text Encode (Prompt)\"\n }\n },\n \"7\": {\n \"inputs\": {\n \"text\": \"text, watermark\",\n \"clip\": [\n \"4\",\n 1\n ]\n },\n \"class_type\": \"CLIPTextEncode\",\n \"_meta\": {\n \"title\": \"CLIP Text Encode (Prompt)\"\n }\n },\n \"8\": {\n \"inputs\": {\n \"samples\": [\n \"3\",\n 0\n ],\n \"vae\": [\n \"4\",\n 2\n ]\n },\n \"class_type\": \"VAEDecode\",\n \"_meta\": {\n \"title\": \"VAE Decode\"\n }\n },\n \"9\": {\n \"inputs\": {\n \"filename_prefix\": \"ComfyUI\",\n \"images\": [\n \"8\",\n 0\n ]\n },\n \"class_type\": \"SaveImage\",\n \"_meta\": {\n \"title\": \"Save Image\"\n }\n }\n}\n",
"outputQuality": 95,
"randomiseSeeds": true,
"forceResetCache": false,
"returnTempFiles": false
}
Output
The action typically returns a list of URLs pointing to the processed images.
Example Output:
[
"https://assets.cognitiveactions.com/invocations/27df6871-a6cd-4110-8973-e93cd33867d8/f655e02b-5b51-4a0d-91f1-d7691cc64717.webp"
]
Conceptual Usage Example (Python)
Here’s a conceptual example of how you might structure your Python code to execute this action:
import requests
import json
# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute" # Hypothetical endpoint
action_id = "8f984d05-629c-4d16-b168-dde7f972d197" # Action ID for Execute ComfyUI Workflow on A100
# Construct the input payload based on the action's requirements
payload = {
"outputFormat": "webp",
"workflowJson": "{\n \"3\": {\n \"inputs\": {\n \"seed\": 156680208700286,\n \"steps\": 10,\n \"cfg\": 2.5,\n \"sampler_name\": \"dpmpp_2m_sde\",\n \"scheduler\": \"karras\",\n \"denoise\": 1,\n \"model\": [\n \"4\",\n 0\n ],\n \"positive\": [\n \"6\",\n 0\n ],\n \"negative\": [\n \"7\",\n 0\n ],\n \"latent_image\": [\n \"5\",\n 0\n ]\n },\n \"class_type\": \"KSampler\",\n \"_meta\": {\n \"title\": \"KSampler\"\n }\n }}",
"outputQuality": 95,
"randomiseSeeds": True,
"forceResetCache": False,
"returnTempFiles": False
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json"
}
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json={"action_id": action_id, "inputs": payload} # Hypothetical structure
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))
except requests.exceptions.RequestException as e:
print(f"Error executing action {action_id}: {e}")
if e.response is not None:
print(f"Response status: {e.response.status_code}")
try:
print(f"Response body: {e.response.json()}")
except json.JSONDecodeError:
print(f"Response body: {e.response.text}")
In this example, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID and input payload are set according to the requirements of the Execute ComfyUI Workflow on A100 action. The endpoint URL and request structure shown are illustrative.
Conclusion
The ComfyUI Workflow on NVIDIA A100 action provides a powerful and flexible way to enhance your image processing capabilities. By utilizing the provided JSON inputs and the optimized performance of the A100 GPU, you can streamline your workflows and achieve impressive results. Explore the potential of these Cognitive Actions in your applications, and consider experimenting with different input parameters to see how they can best serve your project needs. Happy coding!