Generate Stunning Custom Images with yuyiliang/stripetshirt01 Cognitive Actions

In the world of image generation, the yuyiliang/stripetshirt01 API offers developers a powerful toolset through its Cognitive Actions. These actions enable you to create customized images effortlessly, enhancing your applications with unique visual content. Whether you're looking to generate images through inpainting or img2img modes, this API provides the flexibility to set parameters like masks, prompts, and dimensions, all while applying styles and refinements to perfect the output.
Prerequisites
Before diving into the integration of these Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform, which will be used for authentication.
- Basic knowledge of JSON and HTTP requests.
When making requests, the API key is typically passed in the headers for authorization.
Cognitive Actions Overview
Let’s explore the available Cognitive Action in the yuyiliang/stripetshirt01 specification.
Generate Custom Images
The Generate Custom Images action allows you to create customized images using various parameters. This action supports img2img and inpainting modes, enabling you to modify or enhance existing images based on your specifications.
- Category: Image Generation
Input
The input for this action is structured as follows:
{
"mask": "http://example.com/mask.png",
"seed": 42,
"image": "http://example.com/image.png",
"width": 1024,
"height": 1024,
"prompt": "an orange stripe T-shirt, white background",
"loraScale": 0.8,
"guidanceScale": 7.5,
"schedulerType": "K_EULER",
"applyWatermark": true,
"negativePrompt": "",
"promptStrength": 0.8,
"refinementSteps": 5,
"refinementStyle": "no_refiner",
"outputImageCount": 1,
"highNoiseFraction": 0.8,
"numInferenceSteps": 50,
"disableSafetyChecker": false
}
- Required Fields:
prompt: Text guiding the image generation.image: URL of the input image.width&height: Dimensions of the output image.
- Optional Fields:
mask: URL for inpainting.seed: Random seed for variation.loraScale,guidanceScale,schedulerType,applyWatermark, etc., for advanced customization.
Output
The output of this action typically returns a URL to the generated image. Here is an example output:
[
"https://assets.cognitiveactions.com/invocations/67333894-9aa2-4a9a-96e9-b642d3697c60/c31146b4-0ea0-4199-b37a-177bc122c288.png"
]
Conceptual Usage Example (Python)
Here’s a conceptual example of how to call the Generate Custom Images 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 = "bfa4b448-0a53-49c2-bb0f-e14ff52f30e1" # Action ID for Generate Custom Images
# Construct the input payload based on the action's requirements
payload = {
"width": 1024,
"height": 1024,
"prompt": "an orange stripe T-shirt, white background",
"loraScale": 0.8,
"guidanceScale": 7.5,
"schedulerType": "K_EULER",
"applyWatermark": True,
"negativePrompt": "",
"promptStrength": 0.8,
"refinementStyle": "no_refiner",
"outputImageCount": 1,
"highNoiseFraction": 0.8,
"numInferenceSteps": 50
}
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, remember to replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id corresponds to the Generate Custom Images action. The payload is structured according to the action's input schema, ensuring your request is successfully processed.
Conclusion
The yuyiliang/stripetshirt01 Cognitive Actions provide a comprehensive and flexible toolset for developers looking to enhance their applications with custom image generation capabilities. By utilizing the Generate Custom Images action, you can create stunning visuals tailored to your needs. Explore the possibilities these actions offer and consider integrating them into your projects for a unique user experience.