Generate Stunning Images with pagebrain/epicphotogasm-v1 Cognitive Actions

In the realm of digital creativity, the pagebrain/epicphotogasm-v1 API opens up a world of possibilities for developers looking to harness the power of advanced image generation. With its Cognitive Actions, you can generate high-quality images using techniques like negative embeddings, img2img transformations, and inpainting. These pre-built actions not only save development time but also empower you to create visually appealing content tailored to your specifications.
Prerequisites
Before diving into the integration of Cognitive Actions, ensure you have the following:
- An API key for accessing the pagebrain/epicphotogasm-v1 service.
- Familiarity with JSON payload structures.
- Basic understanding of HTTP requests and responses.
To authenticate, you will typically pass your API key in the request headers, allowing you to securely access the Cognitive Actions.
Cognitive Actions Overview
Generate Image with EpicPhotogasm
The Generate Image with EpicPhotogasm action is designed to create stunning images based on descriptive prompts while allowing for customization through various parameters. This action supports safety filtering and provides options for output dimensions, making it versatile for different use cases.
Input
The input for this action is structured as a JSON object with several properties:
- mask: (string, optional) URI of the input mask for inpaint mode. Black areas will be preserved, while white areas will be inpainted.
- seed: (integer, optional) Random seed for image generation. If omitted, a random seed will be used.
- image: (string, optional) URI of the input image for img2img or inpaint mode.
- width: (integer, required) Width of the output image. Must be one of the predefined sizes (128, 256, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024). Default is 512.
- height: (integer, required) Height of the output image. Must be one of the predefined sizes. Default is 512.
- prompt: (string, required) Descriptive prompt guiding the content of the output image.
- scheduler: (string, optional) The scheduling algorithm used for image generation. Default is K_EULER.
- safetyCheck: (boolean, optional) Enable the safety checker to filter out potentially unsafe content. Default is true.
- guidanceScale: (number, optional) Scale factor used for classifier-free guidance. Must be between 1 and 20. Default is 7.5.
- negativePrompt: (string, optional) Elements to exclude in the output.
- promptStrength: (number, optional) Controls the influence of the initial image on the output. Default is 0.8.
- numberOfOutputs: (integer, optional) Specifies how many images to generate (1-4). Default is 1.
- numberOfInferenceSteps: (integer, optional) Number of denoising steps to balance speed and quality (1-500). Default is 50.
Example Input:
{
"seed": 332884020,
"width": 576,
"height": 1024,
"prompt": "wide-shot, a woman, (freckles:0.9), depth of field, business woman",
"scheduler": "K_EULER_ANCESTRAL",
"safetyCheck": true,
"guidanceScale": 5,
"negativePrompt": "UnrealisticDream, BadDream, EasyNegative",
"promptStrength": 0.8,
"numberOfOutputs": 1,
"numberOfInferenceSteps": 20
}
Output
The output from this action is typically a URL pointing to the generated image. If the request is successful, you might receive a response like the following:
Example Output:
[
"https://assets.cognitiveactions.com/invocations/9639506b-b8f5-470f-b026-83be8eb26a1a/137826fd-34f7-49fe-8530-f7269cafac68.png"
]
Conceptual Usage Example (Python)
Here’s how you might call this action using Python. The endpoint URL and request structure are illustrative and should be replaced with actual values when integrating.
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 = "7988980f-0dd4-4ea3-9ff7-0d0989c4ce42" # Action ID for Generate Image with EpicPhotogasm
# Construct the input payload based on the action's requirements
payload = {
"seed": 332884020,
"width": 576,
"height": 1024,
"prompt": "wide-shot, a woman, (freckles:0.9), depth of field, business woman",
"scheduler": "K_EULER_ANCESTRAL",
"safetyCheck": True,
"guidanceScale": 5,
"negativePrompt": "UnrealisticDream, BadDream, EasyNegative",
"promptStrength": 0.8,
"numberOfOutputs": 1,
"numberOfInferenceSteps": 20
}
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, the developer replaces their API key and endpoint URL, constructs the input payload as per the action's requirements, and sends a POST request to execute the action. The response is then processed to retrieve the generated image URL.
Conclusion
The pagebrain/epicphotogasm-v1 Cognitive Actions provide a powerful tool for developers aiming to integrate advanced image generation capabilities into their applications. By leveraging the Generate Image with EpicPhotogasm action, you can create high-quality images with a variety of customizable features. As you explore these actions, consider how they can enhance your projects and open new avenues for creativity in your applications. Happy coding!