Create Stunning Images with Clovis' Inpainting and LoRA Scaling

Clovis offers a powerful suite of Cognitive Actions designed to enhance image generation through advanced techniques like inpainting and adjustable LoRA scaling. This service allows developers to easily create and manipulate images with precision, making it ideal for a variety of applications—from artistic endeavors to professional projects.
With Clovis, you can generate high-quality images that meet specific requirements, such as custom aspect ratios, image masking, and optimized inference speed. The flexibility of output formats and quality settings also ensures that the generated images fit perfectly within your use case. Whether you're looking to create digital art, enhance product images, or generate unique content for marketing, Clovis streamlines the process and boosts productivity.
Prerequisites
To get started with Clovis, you'll need a Cognitive Actions API key and a basic understanding of making API calls.
Generate Image with Inpainting and LoRA Scaling
This action allows you to generate images using inpainting techniques and adjustable LoRA scaling, providing a robust solution for enhanced image manipulation. By supporting custom aspect ratios and image masking, Clovis enables you to create tailored visuals that meet your specific needs.
Input Requirements
The input for this action is structured as follows:
- Prompt: A textual description of the image you wish to generate (e.g., "professional portrait of Júlio in a studio with a dark Blue suit, 35mm").
- Mask: A URI pointing to an image mask for inpainting mode. If provided, this will override specified dimensions.
- Image: A URI of the input image used for image-to-image or inpainting modes.
- Width/Height: Specify the dimensions of the generated image, rounded to the nearest multiple of 16.
- Go Fast: A boolean option for faster predictions using an optimized model.
- Lora Scale: Adjusts the intensity of the main LoRA application.
- Output Format: Choose between webp, jpg, or png for the output images.
- Num Outputs: Define how many images you want to generate.
- Guidance Scale: Sets the guidance scale for the diffusion process.
- Output Quality: Determines the quality of the saved output images.
- Inference Model: Choose between different models for performing inference.
- Additional parameters: Such as prompt strength, image megapixels, and safety checker options.
Expected Output
The output will consist of a URI linking to the generated image in the specified format. For example:
https://assets.cognitiveactions.com/invocations/a0b46b5d-be0d-4e13-8d91-289f05ce8b6e/cf2f47ac-786b-4cf4-9a6d-0a0dfc071abf.webp
Use Cases for this Action
- Digital Art Creation: Artists can leverage this action to create unique pieces by providing descriptive prompts and specific styles.
- Marketing Content: Generate tailored images for promotional materials, social media posts, or advertisements that capture attention.
- Product Visualization: Enhance product images for e-commerce, allowing for detailed representations that can include custom backgrounds or features.
- Creative Projects: Use inpainting capabilities to modify existing images, integrating new elements seamlessly.
import requests
import json
# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"
action_id = "e4312aa3-7618-4f1b-9e59-4750f2dfe3f8" # Action ID for: Generate Image with Inpainting and LoRA Scaling
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"goFast": false,
"prompt": "professional portrait of Júlio in a studio with a dark Blue suit, 35mm",
"loraScale": 1,
"numOutputs": 1,
"outputFormat": "webp",
"guidanceScale": 3,
"outputQuality": 80,
"extraLoraScale": 1,
"inferenceModel": "dev",
"promptStrength": 0.8,
"imageMegapixels": "1",
"imageAspectRatio": "1:1",
"numInferenceSteps": 28
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json",
# Add any other required headers for the Cognitive Actions API
}
# Prepare the request body for the hypothetical execution endpoint
request_body = {
"action_id": action_id,
"inputs": payload
}
print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json=request_body
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully. Result:")
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 (non-JSON): {e.response.text}")
print("------------------------------------------------")
Conclusion
Clovis' image generation capabilities, particularly through inpainting and LoRA scaling, open up a world of possibilities for developers looking to create customized visuals quickly and efficiently. With its flexible input options, high-quality output, and a range of use cases, integrating Clovis into your workflow can significantly enhance your creative and professional projects. Start exploring the potential of Clovis today and transform your approach to image generation.