Create Stunning Images with Devphoto's Inpainting Action

In the world of digital content creation, the demand for high-quality images is ever-increasing. Devphoto offers a powerful solution with its Cognitive Actions, particularly the ability to generate enhanced inpainted images. This feature allows developers to leverage advanced AI models to create visually striking images by inpainting specific areas based on detailed prompts and image masks. The benefits are clear: faster production times, enhanced creativity, and the ability to customize outputs to fit specific needs. Whether you're working on a marketing campaign, developing a game, or enhancing a digital portfolio, Devphoto's inpainting capabilities can significantly elevate your visuals.
Prerequisites
To get started, you'll need a valid Cognitive Actions API key and a basic understanding of how to make API calls.
Generate Enhanced Inpainted Image
The "Generate Enhanced Inpainted Image" action is designed to solve the challenge of creating high-quality images from existing visuals. By utilizing either the 'dev' or 'schnell' model, developers can inpaint images with precision, providing various customization options to enhance quality and style.
Input Requirements
To utilize this action, the following inputs are required:
- Prompt: A detailed description of the desired image, which guides the inpainting process.
- Image (optional): An input image for inpainting mode. If provided, the dimensions set by width and height will be ignored.
- Mask (optional): An image mask that specifies which areas of the input image to modify.
- Model: Choose between 'dev' for more detailed outputs with around 28 inference steps, or 'schnell' for faster generation with about 4 steps.
- Additional parameters such as width, height, and aspect ratio can further refine the output.
Expected Output
The expected output is a URL linking to the generated image, which will reflect the inpainting based on the provided prompt and any specified configurations.
Use Cases for this specific action
- Marketing and Advertising: Create unique visuals for campaigns by inpainting specific elements in promotional images.
- Game Development: Enhance graphics by modifying characters or environments dynamically.
- Personal Projects: Artists and designers can explore creative concepts by generating new images from existing ones, allowing for endless customization.
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 = "8c4bc3a7-7648-4fad-ab54-b170c96083b6" # Action ID for: Generate Enhanced Inpainted Image
# 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": "Photo of Dev as a photographer on the edge of a high-rise balcony, overlooking a futuristic city skyline with towering skyscrapers, including an iconic central tower. He wears a black leather jacket, dark sunglasses, and modern sneakers, exuding a confident, cinematic vibe. Holding a professional canon dslr camera,, he carefully adjusts the settings, focused on his work. The background features a hazy, golden cityscape with a mix of modern architecture, creating a high-end, cinematic feel. The atmosphere is a blend of urban adventure and creative storytelling, with natural light filtering through the skyline.\n\n",
"loraScale": 1,
"megapixels": "1",
"aspectRatio": "1:1",
"imageQuality": 80,
"outputFormat": "jpg",
"guidanceValue": 3,
"enableFastMode": false,
"numberOfOutputs": 1,
"promptIntensity": 0.8,
"numInferenceSteps": 30,
"additionalLoraScale": 1
}
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
The Devphoto inpainting action empowers developers to generate stunning and unique images tailored to their specific needs. With its flexibility and high-quality outputs, this tool can be integrated into various projects, saving time while enhancing creativity. Whether you’re looking to revamp marketing materials, create immersive game graphics, or experiment with artistic designs, Devphoto's inpainting capabilities offer a robust solution. Start exploring the possibilities today and see how you can elevate your visual content!