Create Stunning Artistic Images with Identity Preservation

25 Apr 2025
Create Stunning Artistic Images with Identity Preservation

The "Instant Id Artistic" service is designed to empower developers to generate high-quality artistic images that preserve the identity of the subjects featured in the input images. Utilizing the advanced capabilities of the Dreamshaper-XL model, this API enables users to create visually striking images with remarkable fidelity and editability—all without the need for extensive tuning.

With its zero-shot identity-preserving image generation approach, developers can easily integrate this functionality into various applications, such as digital art creation, marketing materials, social media content, and more. The ability to produce customized images based on specific prompts opens up a world of creative opportunities, allowing businesses and artists to stand out in a crowded marketplace.

Prerequisites

To get started with the Instant Id Artistic service, you will need a Cognitive Actions API key and some familiarity with making API calls.

Generate Identity-Preserving Artistic Image

The "Generate Identity-Preserving Artistic Image" action is the cornerstone of the Instant Id Artistic service. This action allows developers to create artistic renditions of images while maintaining the essence of the original identity.

Purpose

This action solves the problem of producing high-quality artistic images that retain recognizable features of the subject, making it invaluable for applications where identity preservation is crucial.

Input Requirements

The action requires the following inputs:

  • image: A URI pointing to the input image file (required).
  • width: Desired width of the output image (default is 640 pixels, can range from 512 to 2048).
  • height: Desired height of the output image (default is 640 pixels, can range from 512 to 2048).
  • prompt: A text prompt to guide the generation (default is a detailed description of an analog film photo).
  • guidanceScale: Numeric value to adjust classifier-free guidance (default is 5, can range from 1 to 50).
  • ipAdapterScale: Scale for IP adapter effects (default is 0.8, can range from 0 to 1).
  • negativePrompt: Text specifying elements to avoid in the image.
  • numInferenceSteps: Number of denoising steps (default is 30, can range from 1 to 500).
  • controlnetConditioningScale: Scale for ControlNet conditioning effects (default is 0.8, can range from 0 to 1).

Expected Output

The output will be a URI to the generated artistic image that reflects the specified attributes and maintains the identity of the original subject.

Use Cases

This action is perfect for:

  • Digital Artists: Who want to create unique interpretations of their work while keeping the subject recognizable.
  • Marketing Teams: Looking to generate engaging promotional images that feature real people or products.
  • Social Media Managers: Who need eye-catching visuals that maintain the essence of the individuals or brands being represented.
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 = "9e3e82bc-8c34-46e5-9cb5-fae82b96b9b0" # Action ID for: Generate Identity-Preserving Artistic 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/KHRI4GBd3FevVULAtdu7JySdF17BAXDk1bzIZeZoZ78NXXzY/chipu.jpeg",
  "width": 640,
  "height": 640,
  "prompt": "80's anime screencap, girl wearing a cropped top and short shorts, artistic rendition with wide brush strokes, anime comic",
  "guidanceScale": 5,
  "ipAdapterScale": 0.8,
  "negativePrompt": "cgi, render, bad quality, worst quality, text, signature, watermark, extra limbs, unaestheticXL_hk1, negativeXL_D",
  "numInferenceSteps": 30,
  "controlnetConditioningScale": 0.8
}

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

The Instant Id Artistic service, particularly through its Generate Identity-Preserving Artistic Image action, offers developers a powerful tool to create stunning images that retain the identity of their subjects. With flexibility in input parameters and the ability to cater to various creative needs, this API is a valuable addition to any developer's toolkit.

Consider integrating this functionality into your applications to enhance user engagement and elevate your visual storytelling. The potential for unique and high-quality artistic images is at your fingertips!