Customize Face Generation with jichengdu/flux-pulid Cognitive Actions

24 Apr 2025
Customize Face Generation with jichengdu/flux-pulid Cognitive Actions

In the ever-evolving landscape of image generation, the jichengdu/flux-pulid API offers powerful Cognitive Actions tailored for developers looking to create customized images, particularly focusing on faces. The Customize Face with PuLID for FLUX action leverages advanced algorithms to allow developers to manipulate image attributes, styles, and backgrounds while maintaining important identity features. This results in high-quality, visually appealing images that can be seamlessly integrated into various applications.

Prerequisites

Before diving into the integration of Cognitive Actions, ensure you have the following:

  • An API key for accessing the jichengdu/flux-pulid Cognitive Actions platform.
  • Basic knowledge of JSON and RESTful API concepts.
  • Familiarity with making HTTP requests, particularly POST requests.

Authentication typically involves passing your API key in the headers of your requests.

Cognitive Actions Overview

Customize Face with PuLID for FLUX

This action enables developers to create customized images centered on faces, optimizing for identity retention and visual consistency.

Category: Image Generation

Input:

The input for this action is structured as follows:

  • mainFaceImage (required): URI to the ID image for face generation.
  • prompt (optional): Text to guide the image generation (default: "portrait, color, cinematic").
  • negativePrompt (optional): Elements to avoid during generation (default: list of undesirable traits).
  • width (optional): Image width in pixels (default: 896, range: 256-1536).
  • height (optional): Image height in pixels (default: 1152, range: 256-1536).
  • seed (optional): Random seed for generation (leave blank or -1 for random).
  • startStep (optional): Timestep for ID insertion (default: 0).
  • numberOfSteps (optional): Steps in the denoising process (default: 20, range: 1-20).
  • outputFormat (optional): Desired output image format (default: webp).
  • guidanceScale (optional): Influence of the prompt on generation (default: 4, range: 1-10).
  • outputQuality (optional): Quality of the output image (default: 80, range: 1-100).
  • numberOfOutputs (optional): Number of images to generate (default: 1, range: 1-4).
  • identifierWeight (optional): Influence level of the ID image (default: 1, range: 0-3).
  • maxSequenceLength (optional): Maximum sequence length for prompt (default: 128, range: 128-512).
  • trueConfiguration (optional): CFG scale for adherence to prompts (default: 1).

Example Input:

{
  "width": 896,
  "height": 1152,
  "prompt": "portrait, color, cinematic",
  "startStep": 0,
  "outputFormat": "webp",
  "guidanceScale": 4,
  "mainFaceImage": "https://replicate.delivery/pbxt/Me8PvHwdoSXGlm8jtoxY2yHT254b6dV9EzWMLp29RjlGqT5E/43.jpg",
  "numberOfSteps": 20,
  "outputQuality": 80,
  "negativePrompt": "bad quality, worst quality, text, signature, watermark, extra limbs, low resolution, partially rendered objects, deformed or partially rendered eyes, deformed, deformed eyeballs, cross-eyed, blurry",
  "numberOfOutputs": 1,
  "identifierWeight": 1,
  "maxSequenceLength": 128,
  "trueConfiguration": 1
}

Output:

Upon successful execution, the action typically returns a list of generated image URLs.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/0d9fec66-6c68-431f-a0f1-4685844cae12/1f9b7762-0e70-4a30-b9de-2688d356dfad.webp"
]

Conceptual Usage Example (Python):

Below is a conceptual Python snippet illustrating how to use the Customize Face with PuLID for FLUX 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 = "79c057ba-d9b0-4579-86a2-f140c20e4f47"  # Action ID for Customize Face with PuLID for FLUX

# Construct the input payload based on the action's requirements
payload = {
    "width": 896,
    "height": 1152,
    "prompt": "portrait, color, cinematic",
    "startStep": 0,
    "outputFormat": "webp",
    "guidanceScale": 4,
    "mainFaceImage": "https://replicate.delivery/pbxt/Me8PvHwdoSXGlm8jtoxY2yHT254b6dV9EzWMLp29RjlGqT5E/43.jpg",
    "numberOfSteps": 20,
    "outputQuality": 80,
    "negativePrompt": "bad quality, worst quality, text, signature, watermark, extra limbs, low resolution, partially rendered objects, deformed or partially rendered eyes, deformed, deformed eyeballs, cross-eyed, blurry",
    "numberOfOutputs": 1,
    "identifierWeight": 1,
    "maxSequenceLength": 128,
    "trueConfiguration": 1
}

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 the COGNITIVE_ACTIONS_API_KEY and endpoint with your actual values. The payload is structured to meet the input requirements of the action, and the example demonstrates basic error handling.

Conclusion

The jichengdu/flux-pulid Cognitive Actions, particularly the Customize Face with PuLID for FLUX, enable developers to generate high-quality, customized images with remarkable fidelity to identity features. By integrating this action into your applications, you can unlock creative possibilities in image generation tailored to your specific needs. Consider experimenting with different prompts, styles, and output formats to fully leverage the capabilities of this powerful tool!