1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const axios = require('axios');
const fs = require('fs');
const path = require('path');
async function toB64(imgPath) {
const data = fs.readFileSync(path.resolve(imgPath));
return Buffer.from(data).toString('base64');
}
const api_key = "YOUR API-KEY";
const url = "https://api.segmind.com/v1/furniture-staging";
const data = {
"prompt": "photo of a white table with plant pot placed on an interior",
"main_image": "toB64('https://i.ibb.co/z8pdz41/main-image.png')",
"overlay_image": "toB64('https://i.ibb.co/bHhQFBq/overlay-image.png')",
"main_image_mask": "toB64('https://i.ibb.co/GFxb3SX/main-image-mask.png')",
"overlay_image_mask": "toB64('https://i.ibb.co/8cqzRHL/overlay-image-mask.png')",
"steps": 25,
"seed": 42424242,
"guidance": 30,
"image_format": "png",
"image_quality": 95
};
(async function() {
try {
const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } });
console.log(response.data);
} catch (error) {
console.error('Error:', error.response.data);
}
})();
The main prompt describing the scene or subject
The URL of the main image
The URL of the overlay image
The URL of the main image mask
The URL of the overlay image mask
The number of steps for image processing
min : 10,
max : 100
Random seed for reproducibility
Guidance scale for adjusting adherence to the prompt
min : 1,
max : 50
The output image format
Allowed values:
The quality of the output image
min : 10,
max : 100
To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.
Each parameter of the model controls a specific aspect of the furniture staging process. Here's a breakdown:
prompt:
This describes the scene or subject you want to stage. Write a detailed description of how the staged furniture or design should look.
main_image:
The primary image of the room or space where the furniture will be staged. Ensure the URL is accessible and points to a clear, high-quality image.
overlay_image:
The secondary image containing the furniture or staging items to overlay on the main image. Provide the URL of the furniture/staging image.
main_image_mask:
A mask for the main image. This defines areas to focus on for staging (e.g., walls, floors). If not provided, staging might be applied globally.
overlay_image_mask (optional):
steps:
This determines the number of processing steps. Higher values lead to better quality but take longer.
seed:
Sets a random seed for reproducibility. Change this if you want different variations of the same setup.
guidance:
Controls how strictly the output adheres to the prompt. Higher values ensure the output matches your prompt but can reduce creativity.
image_format:
Specifies the format of the output image. Options are usually png
, jpeg
, etc. Choose png
for lossless quality.
image_quality:
Sets the quality of the output image. Higher values produce better quality but larger file sizes.
Prepare Your Inputs
Make sure all inputs are ready:
Images:
main_image
and overlay_image
to a cloud service or use an accessible URL.Prompt: