Effortlessly Generate Images with Inpainting Using Stevegl

In the ever-evolving landscape of digital content creation, the demand for high-quality imagery has never been greater. Enter Stevegl, a powerful tool that utilizes advanced models to generate and inpaint images based on user-defined prompts and parameters. By leveraging the capabilities of the 'schnell' model for rapid generation or the 'dev' model for superior quality, developers can create stunning visuals with minimal effort. This service not only simplifies the process of image generation but also allows for extensive customization, making it a valuable asset for various applications.
Imagine a scenario where you need to create unique images for a marketing campaign, enhance existing graphics, or even generate artwork for a game. Stevegl's image generation and inpainting capabilities cater to these needs, providing developers with the tools to create visually appealing content efficiently. By utilizing customizable parameters such as aspect ratio, output format, and quality, you can tailor the generated images to meet specific requirements.
Prerequisites
To get started with Stevegl, you'll need a Cognitive Actions API key and a basic understanding of making API calls.
Generate Image with Inpainting
This action allows you to generate images and perform inpainting using specified prompts. The primary purpose is to create or modify images based on textual descriptions while offering flexibility in output quality and speed.
Input Requirements
The input is structured as a composite request requiring at least the following:
- prompt: A string that guides the image generation process (e.g., "overweight STEVEGL").
- Optional inputs include:
- mask: A URI for an image mask used in inpainting.
- model: Select between 'dev' for high-quality images or 'schnell' for faster outputs.
- width and height: Define custom dimensions if the aspect ratio is set to custom.
- fastMode: Enable faster predictions with optimized models.
- numberOfOutputs: Specify how many images to generate.
Expected Output
The output will be a URI pointing to the generated image(s), which can be in formats like webp, jpg, or png. For example, you might receive a link like:
https://assets.cognitiveactions.com/invocations/c1b9f2f2-01ec-426f-9eb2-cec759e529f0/ecbb9e19-5476-4ba5-a76a-4cf68f701e99.webp
Use Cases for this Specific Action
- Marketing & Advertising: Quickly generate unique visuals for campaigns that align with specific themes or messages.
- Game Development: Create custom artwork or modify existing images to fit the narrative or style of your game.
- Content Creation: Enhance blog posts or articles with tailored images that resonate with the text, improving engagement.
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 = "13b46393-e5f3-45f3-9512-14634741fb7f" # Action ID for: Generate Image with Inpainting
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"model": "dev",
"prompt": "overweight STEVEGL ",
"fastMode": false,
"loraScale": 1,
"numberOfOutputs": 1,
"imageAspectRatio": "1:1",
"imageOutputFormat": "webp",
"imageOutputQuality": 80,
"numberOfMegapixels": "1",
"additionalLoraScale": 1,
"imagePromptStrength": 0.8,
"inferenceStepsCount": 28,
"diffusionGuidanceScale": 3
}
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
Stevegl's image generation and inpainting capabilities provide developers with a streamlined approach to creating high-quality visuals quickly and efficiently. Whether you're in marketing, game development, or any field that requires compelling imagery, this tool can significantly enhance your workflow. By customizing parameters and utilizing different models, you can achieve the exact results you need for your projects. Explore the possibilities with Stevegl and elevate your content creation game today!