Create Stunning High-Resolution Images with Demofusion

25 Apr 2025
Create Stunning High-Resolution Images with Demofusion

Demofusion is a powerful framework designed to leverage open-source Generative AI models to generate high-resolution images. With the ability to create images up to 3072x3072 pixels, Demofusion employs advanced techniques like Progressive Upscaling, Skip Residual, and Dilated Sampling. This allows developers to quickly iterate on prompts while ensuring superior image quality. Whether you're looking to enhance your creative projects, produce unique artwork, or generate images for marketing materials, Demofusion simplifies the image generation process and provides stunning results.

Use Cases:

  1. Creative Projects: Artists and designers can use Demofusion to visualize concepts and create high-quality images for their portfolios.
  2. Marketing and Advertising: Businesses can generate eye-catching visuals for campaigns, social media, and promotional materials.
  3. Content Creation: Bloggers and content creators can produce unique images to accompany their articles, enhancing reader engagement.
  4. Game Development: Developers can create detailed textures and assets for their games, enriching the visual experience for players.

To get started with Demofusion, you'll need a Cognitive Actions API key and a basic understanding of making API calls.

Generate High-Resolution Images with DemoFusion

The Generate High-Resolution Images action enables users to produce stunning, high-resolution images based on descriptive prompts. This action addresses the need for high-quality visuals that can be generated rapidly and customized according to specific requirements.

Input Requirements: The action accepts a variety of parameters to tailor the image generation process, including:

  • Prompt: A descriptive text that guides the image creation.
  • Width & Height: Dimensions of the output image (default is 3072x3072).
  • Sigma: Standard deviation for the Gaussian filter (default is 1).
  • Stride: Controls local patch movement in pixel space (default is 64).
  • Batch Size for Views: Number of samples processed in each batch (default is 16).
  • Guidance Scale Factor: Strength of classifier-free guidance (default is 7.5).
  • Negative Input Prompt: Descriptive text to avoid unwanted outputs (default includes terms like "blurry" and "ugly").
  • Multi Decoder: Option to use multiple decoders (default is true).
  • Number of Inference Steps: Steps in the denoising process (default is 50).
  • Cosine Strength Parameters: Control the influence of various effects.

Expected Output: The action will return URLs of the generated images, allowing you to access and use them directly. An example output might look like this:

  • https://assets.cognitiveactions.com/invocations/9dc13227-697a-46cb-9132-7b0078c36e97/80badd62-c603-4e89-8790-4dd6ab96c7aa.png
  • https://assets.cognitiveactions.com/invocations/9dc13227-697a-46cb-9132-7b0078c36e97/a8c4de44-98da-4547-a378-693e0ee9a217.png

Use Cases for this specific action:

  • Artistic Visualization: Quickly generate detailed artwork for use in exhibitions or online galleries.
  • Product Mockups: Create realistic images of products from textual descriptions for e-commerce sites.
  • Storytelling: Generate visuals that enhance narratives in digital storytelling or game design.

```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 = "e8e72f44-6263-4946-bad6-19cbb9123fa9" # Action ID for: Generate High-Resolution Images with DemoFusion

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "sigma": 0.8,
  "width": 3072,
  "height": 3072,
  "prompt": "Envision a portrait of an elderly woman, her face a canvas of time, framed by a headscarf with muted tones of rust and cream. Her eyes, blue like faded denim. Her attire, simple yet dignified",
  "stride": 64,
  "batchSizeForViews": 16,
  "guidanceScaleFactor": 7.5,
  "negativeInputPrompt": "blurry, ugly, duplicate, poorly drawn, deformed, mosaic",
  "useMultipleDecoders": true,
  "numberOfInferenceSteps": 40,
  "cosineStrengthSkipResidual": 3,
  "cosineStrengthGaussianFilter": 1,
  "cosineStrengthDilatedSampling": 1
}

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("------------------------------------------------")


In conclusion, Demofusion offers developers a simplified and efficient way to generate high-resolution images tailored to specific needs. With its powerful capabilities and customizable parameters, you can create stunning visuals for various applications, from marketing to creative arts. To explore further, consider integrating Demofusion into your next project and unlock the potential of AI-driven image generation.