Elevate Your App's Aesthetics: Integrating Interior Design Cognitive Actions

In the ever-evolving landscape of app development, visual appeal plays a crucial role in user engagement. The adirik/interior-design API offers a powerful Cognitive Action that allows developers to generate stunning and realistic interior design images. By leveraging this action, developers can transform simple input images of empty rooms into beautifully designed spaces based on customizable text prompts. This not only enhances the user experience but also opens up new avenues for creativity in application design.
Prerequisites
Before diving into the integration of the Cognitive Actions, ensure you have the following:
- API Key: You will need a valid API key to authenticate your requests to the Cognitive Actions platform.
- Basic Setup: Familiarity with making HTTP requests and handling JSON data will be beneficial.
In conceptual terms, authentication typically involves passing your API key in the headers of your requests, ensuring secure access to the Cognitive Actions.
Cognitive Actions Overview
Generate Interior Design with Realistic Vision
Purpose: This action generates realistic interior design images based on an input image of an empty room and a descriptive text prompt. It utilizes advanced techniques including Realistic Vision V3.0 inpainting, segmentation, and MLSD ControlNets to produce tailored designs while preserving the layout of the room.
Category: Image Generation
Input
The following fields are required and optional for the action:
- Required Fields:
image: URI of the input image (e.g., an image of an empty room).prompt: A text description of the desired design.
- Optional Fields:
seed: Random seed for generating variations (integer).guidanceScale: Scale for the classifier-free guidance (number; default is 15, range 1-50).negativePrompt: Text to avoid undesired elements (string).promptStrength: Strength of the prompt in inpainting (number; default is 0.8, range 0-1).numInferenceSteps: Number of denoising steps (integer; default is 50, range 1-500).
Example Input:
{
"image": "https://replicate.delivery/pbxt/KhTNuTIKK1F1tvVl8e7mqOlhR3z3D0SAojAMN8BNftCvAubM/bedroom_3.jpg",
"prompt": "A bedroom with a bohemian spirit centered around a relaxed canopy bed complemented by a large macrame wall hanging. An eclectic dresser serves as a unique storage solution while an array of potted plants brings life and color to the room",
"guidanceScale": 15,
"negativePrompt": "lowres, watermark, banner, logo, watermark, contactinfo, text, deformed, blurry, blur, out of focus, out of frame, surreal, extra, ugly, upholstered walls, fabric walls, plush walls, mirror, mirrored, functional, realistic",
"promptStrength": 0.8,
"numInferenceSteps": 50
}
Output
The action typically returns a URI of the generated image. For example:
https://assets.cognitiveactions.com/invocations/d342883f-4ac7-43f1-92fb-94a7a70389b2/d461a0f9-1c81-44e0-8f14-fb735211fbf5.png
This output can be used directly in your application to showcase the newly created interior design.
Conceptual Usage Example (Python)
Here’s how you might call this action using Python, illustrating how to structure the input JSON payload:
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 = "2696f9f8-d96a-4758-a118-00257e038573" # Action ID for Generate Interior Design with Realistic Vision
# Construct the input payload based on the action's requirements
payload = {
"image": "https://replicate.delivery/pbxt/KhTNuTIKK1F1tvVl8e7mqOlhR3z3D0SAojAMN8BNftCvAubM/bedroom_3.jpg",
"prompt": "A bedroom with a bohemian spirit centered around a relaxed canopy bed complemented by a large macrame wall hanging. An eclectic dresser serves as a unique storage solution while an array of potted plants brings life and color to the room",
"guidanceScale": 15,
"negativePrompt": "lowres, watermark, banner, logo, watermark, contactinfo, text, deformed, blurry, blur, out of focus, out of frame, surreal, extra, ugly, upholstered walls, fabric walls, plush walls, mirror, mirrored, functional, realistic",
"promptStrength": 0.8,
"numInferenceSteps": 50
}
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 YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID and input payload are structured according to the Cognitive Action's requirements, and the endpoint URL is illustrative.
Conclusion
The Generate Interior Design with Realistic Vision action is a powerful tool for developers looking to enhance their applications with beautiful and personalized interior designs. By integrating this Cognitive Action, you can provide users with visually engaging experiences that are tailored to their preferences. Explore the possibilities of transforming your app's aesthetic and take your design capabilities to the next level! Consider experimenting with various prompts and images to see the diverse outputs you can achieve.