Elevate Your E-commerce Applications with Image Generation using Wolverine/ecommerce-model Actions

In the world of e-commerce, visual appeal is crucial for attracting and retaining customers. The wolverinn/ecommerce-model provides a powerful set of Cognitive Actions specifically designed for generating high-quality images to enhance your online store's offerings. Among these actions, the ability to create stunning images of clothing and human poses stands out, allowing developers to integrate sophisticated image generation capabilities into their applications seamlessly.
Prerequisites
Before diving into the integrations, ensure you have the following:
- An API key for the Cognitive Actions platform to authenticate your requests.
- Basic knowledge of JSON and RESTful API interactions.
- Familiarity with Python for implementing the conceptual code examples.
Authentication typically involves passing your API key as a bearer token in the request headers, ensuring secure access to the action functionalities.
Cognitive Actions Overview
Generate Commercial Image
The Generate Commercial Image action is designed to produce high-quality, realistic images that feature clothing and human poses. This action leverages advanced parameters such as detailed prompts and various algorithms to enhance image quality and detail, making it ideal for e-commerce applications.
Input
The input for this action requires several fields that guide the image generation process:
{
"commercialImage": "https://replicate.delivery/pbxt/LVVhMkdhhD5JzSM3PWM7gNqcx2nx5UhhxUYYD95sDNrrGjTV/cloth1.png",
"seed": -1,
"steps": 35,
"prompt": "realistic, photorealistic, best quality, masterpiece, highres, 8k, RAW photo, ultra-detailed, 1 girl, looking at viewer, black hair, <lora:detailed_eye_10:0.5>, <lora:MengX_girl_Mix_V40:0.5>, luxurious decoration, detailed background, perfect lighting, Cinematic Lighting",
"scheduler": "Karras",
"maximumWidth": 1024,
"batchQuantity": 1,
"maximumHeight": 1024,
"activateAdetailer": false,
"cannyEdgeDetection": 2,
"configurationScale": 7,
"denoisingIntensity": 0.75,
"dinosaurCategories": "clothes,arms",
"negativePromptText": "easynegative, (deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime, mutated hands and fingers:1.4), (deformed, distorted, disfigured:1.3), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, disconnected limbs, mutation, mutated, ugly, disgusting, amputation",
"samplingMethodName": "DPM++ 2M SDE",
"maskedPaddingPixelsOnly": 32
}
- commercialImage: A URI pointing to an image containing clothing and poses (required).
- seed: A random seed for predictable outcomes, default is -1 (optional).
- steps: Number of inference steps, default is 20 (optional).
- prompt: Descriptive text to guide the image generation (default provided).
- scheduler: The scheduling method for the diffusion process (default is "Karras").
- maximumWidth and maximumHeight: Specify the dimensions of the output image (default 1024).
- batchQuantity: Number of images to generate in one call (default is 1).
- activateAdetailer: Enable or disable additional detail enhancement (default is true).
- cannyEdgeDetection: Level of edge detection for processing (default is 0).
- configurationScale: Influences algorithm behavior (default is 7).
- denoisingIntensity: Controls the smoothness of the output (default is 0.75).
- dinosaurCategories: For internal testing (optional).
- negativePromptText: Keywords to avoid in the image generation (default provided).
- samplingMethodName: The method for drawing samples during generation.
- maskedPaddingPixelsOnly: Specifies padding around masked areas.
Output
Upon successful execution, the action returns a response containing the generated images and relevant information:
{
"images": [
"https://assets.cognitiveactions.com/invocations/d7adf778-d774-445b-b485-770f22f08c8d/295050f2-999b-4afe-82da-0e879e72781a.png"
],
"payload": {
"info": {
"seed": 2808450488,
"steps": 35,
"width": 1024,
"height": 1024,
"prompt": "realistic, photorealistic, best quality, masterpiece, highres, 8k, RAW photo, ultra-detailed, 1 girl, looking at viewer, black hair, <lora:detailed_eye_10:0.5>, <lora:MengX_girl_Mix_V40:0.5>, luxurious decoration, detailed background, perfect lighting, Cinematic Lighting",
"sampler_name": "DPM++ 2M SDE"
}
}
}
The output includes:
- An array of URLs pointing to the generated images.
- Metadata about the generation process, such as the seed used, steps taken, and prompts.
Conceptual Usage Example (Python)
Here’s a conceptual example of how to call the Generate Commercial Image 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 = "a7473bf5-a6ce-4173-ad15-ca3b2760ac4e" # Action ID for Generate Commercial Image
# Construct the input payload based on the action's requirements
payload = {
"commercialImage": "https://replicate.delivery/pbxt/LVVhMkdhhD5JzSM3PWM7gNqcx2nx5UhhxUYYD95sDNrrGjTV/cloth1.png",
"seed": -1,
"steps": 35,
"prompt": "realistic, photorealistic, best quality, masterpiece, highres, 8k, RAW photo, ultra-detailed, 1 girl, looking at viewer, black hair, <lora:detailed_eye_10:0.5>, <lora:MengX_girl_Mix_V40:0.5>, luxurious decoration, detailed background, perfect lighting, Cinematic Lighting",
"scheduler": "Karras",
"maximumWidth": 1024,
"batchQuantity": 1,
"maximumHeight": 1024,
"activateAdetailer": false,
"cannyEdgeDetection": 2,
"configurationScale": 7,
"denoisingIntensity": 0.75,
"dinosaurCategories": "clothes,arms",
"negativePromptText": "easynegative, (deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime, mutated hands and fingers:1.4), (deformed, distorted, disfigured:1.3), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, disconnected limbs, mutation, mutated, ugly, disgusting, amputation",
"samplingMethodName": "DPM++ 2M SDE",
"maskedPaddingPixelsOnly": 32
}
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_KEYwith your actual API key. - The
action_idcorresponds to the Generate Commercial Image action. - The
payloadis constructed using the required and optional fields based on the input schema. - The response is printed in a readable format, showing the generated images.
Conclusion
The wolverinn/ecommerce-model Cognitive Actions empower developers to create visually stunning images that can significantly enhance the user experience in e-commerce applications. By leveraging the Generate Commercial Image action, you can automate the image creation process, ensuring high-quality visuals that engage customers effectively.
Explore additional use cases such as batch image generation or dynamic image updates to keep your offerings fresh and appealing. Happy coding!