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/models/automatic-mask-generator"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "sample text",
12 "image": "sample text",
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": -1,
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/models/automatic-mask-generator"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "sample text",
12 "image": "sample text",
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": -1,
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/models/automatic-mask-generator
Parameters
image
requiredstring (base64)
Upload your input image
prompt
requiredstring
Prompt to render
base64
optionalboolean
Base64 encoding of the output image.
false
grow_mask
optionalinteger
Selectively expand image regions
10
Range: 0 - 100invert_mask
optionalboolean
Refers to inverting the mask.
false
return_alpha
optionalboolean
Check this to obtain alpha mask image
false
return_mask
optionalboolean
Check this to obtain the mask as the output.
true
seed
optionalinteger
Seed for image generation.
-1
Range: -1 - 999999999999999stop_on_empty_mask
optionalboolean
Refers to stop the execution on an empty mask.
false
threshold
optionalnumber
Detection threshold
0.2
Range: 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