Automatic Mask Generator
Automatic Mask Generator is a powerful tool that automates the creation of precise masks for inpainting
1import requests
2import json
3
4url = "https://api.segmind.com/v1/automatic-mask-generator"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "Sofa",
12 "image": "https://segmind-sd-models.s3.amazonaws.com/display_images/automask-ip.jpg",
13 "threshold": 0.2,
14 "stop_on_empty_mask": false,
15 "invert_mask": false,
16 "return_mask": true,
17 "return_alpha": false,
18 "grow_mask": 10,
19 "seed": 468685,
20 "base64": false
21}
22
23response = requests.post(url, headers=headers, json=data)
24
25if response.status_code == 200:
26 result = response.json()
27 print(json.dumps(result, indent=2))
28else:
29 print(f"Error: {response.status_code}")
30 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/automatic-mask-generator"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "Sofa",
12 "image": "https://segmind-sd-models.s3.amazonaws.com/display_images/automask-ip.jpg",
13 "threshold": 0.2,
14 "stop_on_empty_mask": false,
15 "invert_mask": false,
16 "return_mask": true,
17 "return_alpha": false,
18 "grow_mask": 10,
19 "seed": 468685,
20 "base64": false
21}
22
23response = requests.post(url, headers=headers, json=data)
24
25if response.status_code == 200:
26 result = response.json()
27 print(json.dumps(result, indent=2))
28else:
29 print(f"Error: {response.status_code}")
30 print(response.text)API Endpoint
https://api.segmind.com/v1/automatic-mask-generatorParameters
imagerequiredstring (uri)Upload your input image
promptrequiredstringPrompt to render
base64optionalbooleanBase64 encoding of the output image.
falsegrow_maskoptionalintegerSelectively expand image regions
10Range: 0 - 100invert_maskoptionalbooleanRefers to inverting the mask.
falsereturn_alphaoptionalbooleanCheck this to obtain alpha mask image
falsereturn_maskoptionalbooleanCheck this to obtain the mask as the output.
trueseedoptionalintegerSeed for image generation.
-1Range: -1 - 999999999999999stop_on_empty_maskoptionalbooleanRefers to stop the execution on an empty mask.
falsethresholdoptionalnumberDetection threshold
0.2Range: 0 - 1Response Type
Returns: Image
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out