Transform Your Images with the mcai/dreamshaper-v6-img2img Cognitive Actions

In the world of image generation and manipulation, the mcai/dreamshaper-v6-img2img API provides developers with powerful tools to create stunning images using customizable parameters. This API leverages the DreamShaper V6 model, allowing you to generate new images based on existing ones while fine-tuning various aspects of the output. By integrating these pre-built cognitive actions into your applications, you can automate image creation and enhance your projects with unique visual content.
Prerequisites
To get started with the Cognitive Actions, you will need to have an API key for the platform. This key is essential for authenticating your requests when calling the actions. Typically, you would pass the API key in the headers of your HTTP requests.
Cognitive Actions Overview
Generate Image with DreamShaper V6
Description: This action allows you to create a new image based on an input image using the DreamShaper V6 model. You can customize various parameters such as seed, upscaling, noise intensity, guidance scale, and scheduler type to refine the image generation process.
Category: Image Generation
Input
The input for this action requires the following fields:
- image (required): URI of the initial image.
- seed (optional): An integer seed for random number generation. Leave blank for a randomized seed.
- prompt (optional): A descriptive input prompt to guide the image generation.
- upscale (optional): The factor by which to upscale the output image (1 to 4).
- strength (optional): Intensity of the noise added to the image (0 to 1).
- guidanceScale (optional): Scale for classifier-free guidance (1 to 20).
- schedulerType (optional): Type of scheduler to use during inference.
- negativePrompt (optional): Elements to exclude from the output.
- numberOfOutputs (optional): Number of images to generate (1 to 4).
- numberOfInferenceSteps (optional): Total number of denoising steps during inference (1 to 500).
Example Input:
{
"image": "https://replicate.delivery/pbxt/IvpKFGkiQb4HPnAHzEFIgIvCgp0Kv0zp6YmzhJTxVfgkTJx0/1685721671_881.png",
"prompt": "Photo of a lone astronaut standing on a barren planet, looking up at the stars, surrounded by remnants of a destroyed spaceship. Deep blue filter, harsh shadows, intense stare, gritty texture, captured by a Sony Alpha 7S III camera.",
"upscale": 2,
"strength": 0.5,
"guidanceScale": 7.5,
"schedulerType": "EulerAncestralDiscrete",
"negativePrompt": "disfigured, kitsch, ugly, oversaturated, greain, low-res, deformed, blurry, bad anatomy, poorly drawn face, mutation, mutated, extra limb, poorly drawn hands, missing limb, floating limbs, disconnected limbs, malformed hands, blur, out of focus, long neck, long body, disgusting, poorly drawn, childish, mutilated, mangled, old, surreal, calligraphy, sign, writing, watermark, text, body out of frame, extra legs, extra arms, extra feet, out of frame, poorly drawn feet, cross-eye",
"numberOfOutputs": 1,
"numberOfInferenceSteps": 30
}
Output
The action typically returns an array of generated image URIs.
Example Output:
[
"https://assets.cognitiveactions.com/invocations/e446ccf0-60d5-4ece-8b47-d8d0326def0e/d6b4e174-8e57-404b-97db-556a6b4c4e34.png"
]
Conceptual Usage Example (Python)
Here’s a conceptual example of how you might call this action using Python:
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 = "68d3e522-28e3-494a-a513-ef921d7b61c4" # Action ID for Generate Image with DreamShaper V6
# Construct the input payload based on the action's requirements
payload = {
"image": "https://replicate.delivery/pbxt/IvpKFGkiQb4HPnAHzEFIgIvCgp0Kv0zp6YmzhJTxVfgkTJx0/1685721671_881.png",
"prompt": "Photo of a lone astronaut standing on a barren planet, looking up at the stars, surrounded by remnants of a destroyed spaceship. Deep blue filter, harsh shadows, intense stare, gritty texture, captured by a Sony Alpha 7S III camera.",
"upscale": 2,
"strength": 0.5,
"guidanceScale": 7.5,
"schedulerType": "EulerAncestralDiscrete",
"negativePrompt": "disfigured, kitsch, ugly, oversaturated, greain, low-res, deformed, blurry, bad anatomy, poorly drawn face, mutation, mutated, extra limb, poorly drawn hands, missing limb, floating limbs, disconnected limbs, malformed hands, blur, out of focus, long neck, long body, disgusting, poorly drawn, childish, mutilated, mangled, old, surreal, calligraphy, sign, writing, watermark, text, body out of frame, extra legs, extra arms, extra feet, out of frame, poorly drawn feet, cross-eye",
"numberOfOutputs": 1,
"numberOfInferenceSteps": 30
}
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 example, replace the placeholder API key and endpoint with your actual values. The action ID and input payload are structured to match the requirements of the "Generate Image with DreamShaper V6" action.
Conclusion
The Cognitive Actions provided by the mcai/dreamshaper-v6-img2img API offer developers a robust set of tools for image generation and manipulation. By utilizing these actions, you can create unique images tailored to your specific needs, enhancing the visual appeal of your applications. Explore potential use cases, integrate these actions, and unleash your creativity in image generation!