Generate Stunning High-Resolution Images with ByteDance's Res-Adapter Actions

24 Apr 2025
Generate Stunning High-Resolution Images with ByteDance's Res-Adapter Actions

In today’s digital landscape, the ability to create high-quality visuals is crucial for applications across various industries. The ByteDance Res-Adapter provides developers with powerful Cognitive Actions designed to generate consistent high-resolution images using diffusion models. These pre-built actions streamline the image generation process, allowing you to produce stunning visuals without the need for extensive training or complex adjustments.

Prerequisites

To get started with the ByteDance Res-Adapter Cognitive Actions, you will need:

  • An API key for the Cognitive Actions platform.
  • Basic familiarity with JSON and making HTTP requests.

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

Cognitive Actions Overview

Generate Consistent High-Resolution Images

Description:
This action enables the generation of high-resolution images that exceed the trained resolution domain of diffusion models without requiring further training or inference adjustments. It's a versatile tool for enhancing image quality seamlessly.

Category: image-enhancement

Input

The input for this action follows the schema defined as CompositeRequest. Here are the key fields:

  • seed (integer, optional): Random seed for generating images. Leave blank to use a randomized seed.
    Example: 42
  • width (integer, optional): Width of the output image in pixels. Default is 1024.
    Example: 1024
  • height (integer, optional): Height of the output image in pixels. Default is 1024.
    Example: 1024
  • prompt (string, required): Text prompt guiding the image generation.
    Example: "Female in a fantasy world, Fluid brushwork, Bright colors..."
  • modelName (string, optional): Select a Stable Diffusion model. Default is 'dreamlike-art/dreamlike-diffusion-1.0'.
    Example: "dreamlike-art/dreamlike-diffusion-1.0"
  • showBaseline (boolean, optional): Show a comparison baseline without the Res-Adapter applied. Default is true.
    Example: false
  • guidanceScale (number, optional): Scale for classifier-free guidance. Range is 0 to 20, default is 7.5.
    Example: 7.5
  • negativePrompt (string, optional): Specify undesired elements in the output image.
    Example: "NSFW, poor bad amateur assignment cut out ugly"
  • resAdapterAlpha (number, optional): Alpha parameter for the Res-Adapter. Must be between 0 and 1. Default is 0.7.
    Example: 0.7
  • numInferenceSteps (integer, optional): Number of steps for denoising during image generation. Default is 25.
    Example: 25

Example Input

{
  "seed": 42,
  "width": 1024,
  "height": 1024,
  "prompt": "Female in a fantasy world, Fluid brushwork, Bright colors, Emphasis on light and atmosphere...",
  "modelName": "dreamlike-art/dreamlike-diffusion-1.0",
  "showBaseline": false,
  "guidanceScale": 7.5,
  "negativePrompt": "NSFW, poor bad amateur assignment cut out ugly",
  "resAdapterAlpha": 0.7,
  "numInferenceSteps": 25
}

Output

The action returns a URL to the generated image, as well as a reference to a baseline image if requested.

  • with_res_adapter: URL of the generated image using the Res-Adapter.
    Example: https://assets.cognitiveactions.com/invocations/...
  • without_res_adapter: URL of the baseline image (if applicable).
    Example: null

Example Output

{
  "with_res_adapter": "https://assets.cognitiveactions.com/invocations/2c15ba47-9ef7-4dad-9ca9-d420abda06dc/0c9dd859-3b4d-46f9-adef-48a06bc4c9e2.png",
  "without_res_adapter": null
}

Conceptual Usage Example (Python)

Here’s how you might implement this action in your application:

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 = "b88cd748-46ea-4873-9208-4db74ce9c272" # Action ID for Generate Consistent High-Resolution Images

# Construct the input payload based on the action's requirements
payload = {
    "seed": 42,
    "width": 1024,
    "height": 1024,
    "prompt": "Female in a fantasy world, Fluid brushwork, Bright colors...",
    "modelName": "dreamlike-art/dreamlike-diffusion-1.0",
    "showBaseline": False,
    "guidanceScale": 7.5,
    "negativePrompt": "NSFW, poor bad amateur assignment cut out ugly",
    "resAdapterAlpha": 0.7,
    "numInferenceSteps": 25
}

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}
    )
    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, you replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID for generating consistent high-resolution images is referenced, and the payload is constructed to match the required input schema.

Conclusion

The ByteDance Res-Adapter Cognitive Actions offer a powerful way to enhance image quality and create stunning visuals effortlessly. By leveraging these actions, developers can integrate advanced image generation capabilities into their applications, improving user engagement and visual appeal. Whether you're building a creative application or enhancing existing content, these tools provide a solid foundation for your image processing needs. Explore the possibilities and start creating high-resolution images today!