Effortlessly Remove Furniture from Images with jschoormans/unstaging Actions

In the realm of image processing, customization and editing capabilities play a crucial role in enhancing user experiences and creative outputs. The jschoormans/unstaging Cognitive Actions provide a powerful solution for developers looking to manipulate images by removing unwanted furniture. This operation allows users to specify elements to exclude using both textual prompts and conditioning images, ensuring greater flexibility and precision in image editing.
Prerequisites
To leverage the capabilities of the jschoormans/unstaging Cognitive Actions, you will need an API key for the Cognitive Actions platform. Authentication typically involves passing your API key in the request headers, allowing you to securely access the service and utilize its actions.
Cognitive Actions Overview
Remove Furniture From Image
This action facilitates the removal of furniture from an image, enabling a higher level of customization and editing. By specifying elements within an image to exclude, users can achieve their desired results through both textual prompts and conditioning images.
Input
The input for this action requires the following fields:
- image (string, required): A URI pointing to the input image used for conditioning the generation process. It must be a valid URL.
- prompt (string, required): A textual prompt that guides the generation process. For example,
"empty room, nothing". - seed (integer, optional): A seed value for generating deterministic results. Defaults to 0, with a valid range from 0 to 4294967295.
- scale (number, optional): The scaling factor applied to the conditioning image, ranging from 0 to 2. Defaults to 1.
- numRuns (integer, optional): Specifies the number of runs to execute, with a default of 1 and allowable values between 1 and 10.
- resolution (integer, optional): Sets the desired output resolution in pixels, with a minimum of 256, maximum of 2048, and defaulting to 768.
- negativePrompt (string, optional): An optional text prompt that specifies undesired aspects in the generation. Defaults to an empty string.
- numInferenceSteps (integer, optional): Indicates the number of denoising steps in the inference process, ranging from 1 to 50, defaulting to 8.
- resolutionConditioning (integer, optional): Defines the resolution of the conditioning image, measured in pixels, with a default of 768, ranging from 256 to 2048.
Example Input:
{
"image": "https://replicate.delivery/pbxt/MYuiIS1geUNr8VVdDvRcnn0igNwrlADa2qKRMMUKOxgkj1QM/ap_21021110795446_custom-fd9247fb6ba93d0716007fe065d4959310b3e6a8.webp",
"prompt": "empty room, nothing",
"resolution": 1024,
"numInferenceSteps": 8,
"resolutionConditioning": 1024
}
Output
The action typically returns a URL to the edited image, demonstrating the successful removal of furniture.
Example Output:
https://assets.cognitiveactions.com/invocations/f8c2887d-c329-4954-97fb-b9415f7fd4dd/1813945c-af92-4f6a-ac6b-43c63d9f4a77.png
Conceptual Usage Example (Python)
Here’s how you might invoke the "Remove Furniture From Image" action using a hypothetical Cognitive Actions endpoint:
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 = "5c71ba03-cf74-4cff-97b4-54982cac340d" # Action ID for Remove Furniture From Image
# Construct the input payload based on the action's requirements
payload = {
"image": "https://replicate.delivery/pbxt/MYuiIS1geUNr8VVdDvRcnn0igNwrlADa2qKRMMUKOxgkj1QM/ap_21021110795446_custom-fd9247fb6ba93d0716007fe065d4959310b3e6a8.webp",
"prompt": "empty room, nothing",
"resolution": 1024,
"numInferenceSteps": 8,
"resolutionConditioning": 1024
}
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 the code snippet above, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID for "Remove Furniture From Image" is included, and the input payload is structured according to the action's requirements. This example highlights how to send requests to the Cognitive Actions service and handle responses effectively.
Conclusion
The jschoormans/unstaging Cognitive Actions provide developers with powerful tools for image manipulation, specifically allowing for the removal of furniture from images. By integrating these actions into your applications, you can offer users enhanced customization features, improving their overall experience. Consider exploring additional use cases where image editing can elevate your application's functionality.