Transform Your Images with rinongal/stylegan-nada Cognitive Actions

24 Apr 2025
Transform Your Images with rinongal/stylegan-nada Cognitive Actions

In the world of image generation, the rinongal/stylegan-nada API offers powerful Cognitive Actions that leverage advanced techniques, such as CLIP-guided domain adaptation, to convert image generators across different domains. This enables developers to create stunning visuals through text prompts, inversion, and cross-domain editing, yielding high-resolution outputs. With these pre-built actions, integrating complex image transformations into your applications becomes straightforward and efficient.

Prerequisites

Before diving into the actions, ensure you have the following:

  • An API key for the Cognitive Actions platform to authorize your requests.
  • Familiarity with JSON for crafting input payloads.
  • Basic knowledge of Python, as we will provide code snippets for conceptual implementation.

Authentication typically involves passing your API key in the request headers, ensuring secure access to the Cognitive Actions.

Cognitive Actions Overview

Convert Image Generators Between Domains

Description:
Utilize StyleGAN-NADA for converting image generators between different domains using CLIP-guided domain adaptation through textual prompts. This action supports inversion and cross-domain editing for high-resolution outputs.

Category:
Image Generation

Input Schema:
The input payload for this action requires the following fields:

  • input (required): The URI of the input image to be processed. Must be a valid URL.
  • styleList (optional): A comma-separated list of style models to apply, applicable when 'outputStyle' is set to 'list'.
  • outputStyle (optional): The style to apply to the output. Choose 'all' to generate outputs with all styles in a collage format.
  • videoFormat (optional): The format of the output video. Select 'gif' for browser display or 'mp4' for higher-quality downloadable video.
  • withEditing (optional): Enable or disable latent space editing for the generated video. Default is true.
  • generateVideo (optional): Determine whether to generate a video instead of a static output image.

Example Input:

{
  "input": "https://replicate.delivery/mgxm/e348c7fa-341d-443a-b56c-67ba6a180d0b/emma.jpg",
  "styleList": "joker,anime,modigliani",
  "outputStyle": "all",
  "videoFormat": "mp4",
  "withEditing": true,
  "generateVideo": false
}

Output:
The action typically returns a URL to the generated image or video. For example:

https://assets.cognitiveactions.com/invocations/f9ece23f-479c-43bd-8711-901b4899effd/529b6805-42fb-48d3-9f75-ea9a43b248ba.jpg

Conceptual Usage Example (Python): Here’s a conceptual Python code snippet illustrating how to call 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 = "9a1ce153-8901-4f37-82bc-34cff34a988c" # Action ID for Convert Image Generators Between Domains

# Construct the input payload based on the action's requirements
payload = {
    "input": "https://replicate.delivery/mgxm/e348c7fa-341d-443a-b56c-67ba6a180d0b/emma.jpg",
    "styleList": "joker,anime,modigliani",
    "outputStyle": "all",
    "videoFormat": "mp4",
    "withEditing": True,
    "generateVideo": 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 code snippet:

  • Replace the COGNITIVE_ACTIONS_API_KEY and endpoint with your actual credentials.
  • The action_id corresponds to the action you want to execute.
  • The payload variable is constructed based on the required input schema for the action.

Conclusion

The Cognitive Actions provided by the rinongal/stylegan-nada API open up exciting possibilities for image generation and transformation in your applications. By leveraging these pre-built actions, developers can effortlessly implement advanced image adaptations and create visually stunning outputs. Whether you're looking to create unique art, enhance media content, or explore creative applications, these Cognitive Actions are a powerful tool at your disposal.

Start integrating today and explore the endless creative opportunities that await!