Create Stunning Identity Images with grandlineai/instant-id-photorealistic Actions

22 Apr 2025
Create Stunning Identity Images with grandlineai/instant-id-photorealistic Actions

In the realm of digital identity and personalization, the grandlineai/instant-id-photorealistic API offers a powerful set of Cognitive Actions designed to generate photorealistic images while preserving individual identities. Utilizing cutting-edge AI models, these actions can facilitate a variety of stylization tasks, making them invaluable for developers looking to enhance their applications with high-quality image generation capabilities.

Prerequisites

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

  • An API key for accessing the grandlineai Cognitive Actions platform.
  • Familiarity with making HTTP requests and handling JSON data.
  • Basic understanding of image formats and URIs.

Authentication generally requires passing the API key in the request headers, allowing you to securely access the action endpoints.

Cognitive Actions Overview

Generate Photorealistic Identity Images

Description: This action allows you to create photorealistic images that preserve a person's identity using the InstantID method with the Juggernaut-XL v8 model. It achieves zero-shot identity-preserving generation and supports various stylization tasks while maintaining high fidelity.

Category: Image Generation

Input

The following fields are required for the input:

  • Image: (string) URI of the input image. This image is required for processing.
  • Width: (integer) Width of the output image in pixels. Allowed range is 512 to 2048. Default is 640.
  • Height: (integer) Height of the output image in pixels. Allowed range is 512 to 2048. Default is 640.
  • Prompt: (string) The main prompt used as input to guide the image generation process.
  • Guidance Scale: (number) Scale factor for classifier-free guidance. Range is 1 to 50. Default is 5.
  • IP Adapter Scale: (number) Scale factor for the IP adapter, influencing the stylization. Range is 0 to 1. Default is 0.8.
  • Negative Prompt: (string) The negative prompt to suppress certain features in the generated image.
  • Number of Inference Steps: (integer) The number of steps used for denoising during image generation. Range is 1 to 500. Default is 30.
  • ControlNet Conditioning Scale: (number) Conditioning scale that influences how much the conditioning inputs control the output. Range is 0 to 1. Default is 0.8.

Example Input:

{
  "image": "https://replicate.delivery/pbxt/KHU47j4Ad3rbq6TVxRuwFhyyX6HYmWrCSlUuVOM3q3ORKgVt/demo.png",
  "width": 640,
  "height": 640,
  "prompt": "glowing, robe, fog, mist, smoke, girl composed of white light, girl composed of black smoke, fire, sun, 1girl, long hair, solo, photorealistic, cowboy shot, cinematic angle, fisheye, motion blur, blue fire, rain, Long hair fluttering in the wind, long, wave, cinematic film still",
  "guidanceScale": 5,
  "ipAdapterScale": 0.8,
  "numInferenceSteps": 30,
  "controlnetConditioningScale": 0.6
}

Output

Upon successful execution, this action returns a URI to the generated photorealistic image.

Example Output:

https://assets.cognitiveactions.com/invocations/07be1bb0-48bc-4d10-a16e-d5ab8898ff5c/cc9c76ca-4a75-4e0e-96d4-271903970102.jpg

Conceptual Usage Example (Python)

Here’s how a developer might call the Cognitive Actions execution endpoint for generating photorealistic identity images:

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 = "55b8609b-b84f-4002-9233-0beffbe2b839" # Action ID for Generate Photorealistic Identity Images

# Construct the input payload based on the action's requirements
payload = {
    "image": "https://replicate.delivery/pbxt/KHU47j4Ad3rbq6TVxRuwFhyyX6HYmWrCSlUuVOM3q3ORKgVt/demo.png",
    "width": 640,
    "height": 640,
    "prompt": "glowing, robe, fog, mist, smoke, girl composed of white light, girl composed of black smoke, fire, sun, 1girl, long hair, solo, photorealistic, cowboy shot, cinematic angle, fisheye, motion blur, blue fire, rain, Long hair fluttering in the wind, long, wave, cinematic film still",
    "guidanceScale": 5,
    "ipAdapterScale": 0.8,
    "numInferenceSteps": 30,
    "controlnetConditioningScale": 0.6
}

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 code snippet, replace the API key and endpoint with your actual values. The action ID and input payload are structured to match the required format for invoking the photorealistic identity image generation action.

Conclusion

The grandlineai/instant-id-photorealistic Cognitive Actions provide developers with a robust toolset for generating stunning identity images that can be tailored to specific needs and preferences. By integrating these actions into your applications, you can unlock a world of creative possibilities and enhance user experiences. Start experimenting with these actions to see how they can elevate your projects!