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
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/magic-eraser";
const data = {
"image": "toB64('https://segmind-sd-models.s3.amazonaws.com/display_images/ai-majic-erase-ip.jpg')",
"mask": "toB64('https://segmind-sd-models.s3.amazonaws.com/display_images/ai-majic-erase-mask.jpeg')",
"invert_mask": false,
"grow_mask": 10,
"seed": 468685,
"base64": false
};
(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);
}
})();
Upload your input image
Upload your mask image (part of the image to be removed)
Refers to the inverting the mask.
Selectively expand image regions
min : 0,
max : 100
Seed for image generation.
min : -1,
max : 999999999999999
Base64 encoding of the output image.
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.
Magic Eraser lets you erase big unwanted areas from your photos while keeping them crisp and realistic. Magic eraser is based on LaMa—which stands for Resolution-robust Large Mask Inpainting, is a powerhouse for tackling large areas in need of inpainting. This is further enhanced by a high receptive field perceptual loss and the use of expansive training masks, ensuring that every edit is seamless and natural-looking.
Here's how magic eraser helps in AI photo editing:
Erases Big Stuff: Regular Inpainting tools struggle with large areas. But Magic Eraser tackles huge unwanted parts in your picture effortlessly.
Works on High-Res Photos: Even on super clear photos, It can magically remove big things without making the rest blurry.
Generative Fill: Magic eraser can seamlessly fill in missing areas in photos with realistic details.