Create Stunning T-Shirt Mockups with aj1357/ai-tshirt-mockup Cognitive Actions

In the realm of e-commerce and custom apparel design, visual representation is key. The aj1357/ai-tshirt-mockup Cognitive Actions offer a powerful solution for developers looking to integrate advanced image generation capabilities into their applications. With the ability to create custom T-shirt mockup images quickly and efficiently, these actions provide a streamlined approach to generating high-quality visuals that meet specific design requirements.
Prerequisites
To get started with the Cognitive Actions, you'll need to ensure you have the following:
- An API key for the Cognitive Actions platform, which will authenticate your requests.
- Basic knowledge of JSON and HTTP request handling in your preferred programming language.
Authentication typically involves passing your API key in the request headers. This allows you to access the Cognitive Actions securely and seamlessly.
Cognitive Actions Overview
Generate Custom T-Shirt Mockup
The Generate Custom T-Shirt Mockup action allows you to create detailed T-shirt mockup images using advanced image generation techniques. This action excels in producing high-quality visuals tailored to your specifications by adjusting various parameters.
Input
The input schema for this action requires the following fields:
- prompt (required): A descriptive text prompt to guide the image generation process. For example:
"BLKTEE worn by a male caucasian model, and athlete, shot on sony, sunset"
The action supports additional optional parameters:
- mask: URI of an image mask for inpainting mode.
- seed: Sets a random seed for reproducible image generation.
- image: URI of an input image for image-to-image or inpainting mode.
- width: Specifies the width of the generated image (256 to 1440).
- height: Specifies the height of the generated image (256 to 1440).
- numOutputs: Number of images to generate (1 to 4).
- imageFormat: Output format of the image (e.g., "webp", "jpg", "png").
- guidanceScale: Affects the realism of the generated images (0 to 10).
- outputQuality: Quality of the output image (0 to 100).
- imageAspectRatio: Defines the aspect ratio of the image.
- numInferenceSteps: Number of denoising steps for image generation (1 to 50).
Here’s an example input payload:
{
"prompt": "BLKTEE worn by a male caucasian model, and athlete, shot on sony, sunset",
"loraScale": 1,
"modelType": "dev",
"numOutputs": 1,
"imageFormat": "png",
"guidanceScale": 3.5,
"outputQuality": 80,
"imageAspectRatio": "4:5",
"numInferenceSteps": 28,
"additionalLoraIntensity": 0.8
}
Output
Upon execution, this action returns a URL to the generated image. For example:
[
"https://assets.cognitiveactions.com/invocations/cee44b23-148e-4fe4-ba44-913bf222f0cc/a4fb9449-9ca3-440d-a641-3e11f7b6979b.png"
]
This URL can be directly used to display the generated T-shirt mockup image in your application.
Conceptual Usage Example (Python)
Here’s a conceptual Python snippet demonstrating how to call this action:
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 = "064ba5fc-1144-4e06-bca1-91db7c3ceba4" # Action ID for Generate Custom T-Shirt Mockup
# Construct the input payload based on the action's requirements
payload = {
"prompt": "BLKTEE worn by a male caucasian model, and athlete, shot on sony, sunset",
"loraScale": 1,
"modelType": "dev",
"numOutputs": 1,
"imageFormat": "png",
"guidanceScale": 3.5,
"outputQuality": 80,
"imageAspectRatio": "4:5",
"numInferenceSteps": 28,
"additionalLoraIntensity": 0.8
}
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 snippet, replace the COGNITIVE_ACTIONS_API_KEY and the endpoint URL with your actual credentials. The action ID and the input payload are structured according to the requirements of the Generate Custom T-Shirt Mockup action.
Conclusion
The aj1357/ai-tshirt-mockup Cognitive Actions provide a robust framework for developers looking to enhance their applications with advanced image generation capabilities. By leveraging the Generate Custom T-Shirt Mockup action, you can streamline the process of creating stunning visuals tailored to your specifications.
Consider exploring additional parameters and experimenting with different prompts to generate unique and high-quality T-shirt mockups. Happy coding!