Create Stunning Identity-Preserving Images with Instant ID Basic

25 Apr 2025
Create Stunning Identity-Preserving Images with Instant ID Basic

Instant ID Basic is an innovative service designed to generate identity-preserving images quickly and efficiently. Utilizing Cubiq's ComfyUI InstantID node, this service leverages state-of-the-art zero-shot generation capabilities, allowing developers to create images that maintain the essence of the original subject while transforming their appearance. The ability to produce high-quality images in just seconds makes it an invaluable tool for a variety of applications.

Whether you're developing video games, creating animated content, or simply need unique character designs, Instant ID Basic streamlines the image generation process. By allowing for customization through prompts and various parameters, developers can achieve specific artistic visions while ensuring the generated images retain identifiable features.

Prerequisites

To get started with Instant ID Basic, you'll need a Cognitive Actions API key and a basic understanding of API calls. This will enable you to seamlessly integrate image generation into your projects.

Generate ID-Preserving Image

The Generate ID-Preserving Image action allows you to create images that preserve the identity of the input subject while being transformed according to your specifications. This action is particularly useful for projects requiring unique character designs or transformations while keeping recognizable features intact.

Input Requirements

The action requires a structured input that includes:

  • Image: A URL of the reference image for face generation.
  • Steps: Defines the number of sampling steps (1 to 50).
  • Width and Height: Specifies the output image dimensions (default is 1600x1600).
  • Prompt: A text description guiding the image generation.
  • Denoise: Strength of the denoising process (recommended at 1.0).
  • Batch Size: Number of images generated per request (1 to 8).
  • Scheduler and Sampler Name: Algorithms for the generation process.
  • Output Format and Quality: Defines the image format and quality level.
  • InstantID Effect Parameters: Including start and end points, weight, and classifier-free guidance scale to control the identity preservation effect.

Example Input

{
  "image": "https://replicate.delivery/pbxt/LGizs2Ko3P4PJ1hbeQRnWG52t27QuBLq3826VcJJURhxNoYS/IMG_4467.jpeg",
  "steps": 30,
  "width": 1600,
  "height": 1600,
  "prompt": "Pirate Captain: Young man in tricorne and longcoat, standing on the deck of his ship, tropical island looming on the horizon",
  "denoise": 1,
  "batchSize": 1,
  "scheduler": "karras",
  "samplerName": "ddpm",
  "outputFormat": "webp",
  "outputQuality": 90,
  "instantIdEndAt": 1,
  "negativePrompt": "NSFW, nudity, painting, drawing, illustration, glitch, deformed, mutated, cross-eyed, ugly, disfigured",
  "instantIdWeight": 1,
  "instantIdStartAt": 0,
  "classifierFreeGuidanceScale": 4.5
}

Expected Output

The action will return a URL pointing to the generated image, maintaining identity while applying the specified transformations.

Example Output

[
  "https://assets.cognitiveactions.com/invocations/4d906dd7-bd01-4964-b694-6c2765924ce2/dab8ed9d-8a05-4853-8ff1-749d575a711a.webp"
]

Use Cases for this Specific Action

  • Game Development: Create unique character avatars that retain identifiable traits for players to connect with.
  • Character Design: Generate diverse versions of existing characters for storytelling or marketing purposes.
  • Content Creation: Produce images for social media campaigns that require a blend of identity and creativity.
  • Fashion and Advertising: Develop promotional materials featuring models that maintain recognizable features while showcasing different styles.

```python
import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "2964a036-83fa-4a8f-91af-739b1c852c3f" # Action ID for: Generate ID-Preserving Image

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "image": "https://replicate.delivery/pbxt/LGizs2Ko3P4PJ1hbeQRnWG52t27QuBLq3826VcJJURhxNoYS/IMG_4467.jpeg",
  "steps": 30,
  "width": 1600,
  "height": 1600,
  "prompt": "Pirate Captain: Young man in tricorne and longcoat, standing on the deck of his ship, tropical island looming on the horizon",
  "denoise": 1,
  "batchSize": 1,
  "scheduler": "karras",
  "samplerName": "ddpm",
  "outputFormat": "webp",
  "outputQuality": 90,
  "instantIdEndAt": 1,
  "negativePrompt": "NSFW, nudity, painting, drawing, illustration, glitch, deformed, mutated, cross-eyed, ugly, disfigured",
  "instantIdWeight": 1,
  "instantIdStartAt": 0,
  "classifierFreeGuidanceScale": 4.5
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    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 (non-JSON): {e.response.text}")
    print("------------------------------------------------")


## Conclusion
Instant ID Basic provides a powerful tool for developers looking to integrate advanced image generation capabilities into their applications. With its ability to produce identity-preserving images quickly and effectively, it opens up a world of creative possibilities. Whether for gaming, design, or marketing, the use cases are vast and varied. Start exploring the potential of Instant ID Basic and enhance your projects with stunning, customized images.