Description
Note: This API route requires the image to be registered via the /register
route.
The Objects/Mask Generator Route is used to generate all possible masks for an image, creating a full segmentation of the image.
The response contains a zip file named as the visual_id of the provided image.
There are k mask files in the zip, each named with the visual_id and mask_id.
The zip file contains an additional file whose name ends with "panoptic". It's not an image, it's a panoptic map. It can be transformed into a regular matrix.
Each point in the image (x,y) is mapped to the mask that applies to that point. In the panoptic map, each pixel's grayscale value includes the mask_id.
You can display those masks to the user, let them pick one or more masks, and use objects/remove route to remove the masked area.
In order to use the objects/remove route on the mask the user selected, you should provide the mask_id, and use the parameter mask_source=generated.
You can see below an example of the content of the zip:
92bf8ce17584de82_panoptic.png
92bf8ce17584de82_1.png
92bf8ce17584de82_2.png
92bf8ce17584de82_3.png
...
92bf8ce17584de82_86.png
You can access the SDK that demonstrates how to use this endpoint in a UI in the following link.
Successful operation.
Bad request.
Specified Image does not exist.
Method not allowed.
Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
Description
Note: This API route requires the image to be registered via the /register
route.
The Person/Info Route is used to retrieve useful information on the people in a specific visual that was previously uploaded to the database.
Additionally, it provides a description of each person within the scene along with its available changes, which are supported by the Bria API.
This route should be used instead of the main /info route when you are only interested in information and available actions for the people in the image. With this route, you will save time by only obtaining information that is relevant to your needs.
Successful operation.
File hasn’t finished onboarding. Please call /info again until you get 200.
One of the details does not meet specification. Please call person/info again.
Specified Image does not exist.
Method not allowed.
Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
[- {
- "actions": {
- "age": [
- "mid-20",
- "mid-40",
- "mid-60"
], - "Beard": [
- "shaved",
- "medium",
- "full"
], - "diversity": [
- "original",
- "africa",
- "korea",
- "india",
- "japan",
- "sweden",
- "germany",
- "russia",
- "mexico",
- "brazil",
- "england",
- "spain",
- "france",
- "unsplash"
], - "expression": [
- "happy",
- "surprised",
- "dreaming",
- "angry",
- "fear",
- "contempt",
- "disgusted",
- "sad",
- "smile"
], - "gender": [
- "femininity",
- "masculinity"
], - "glasses": [
- "light",
- "none",
- "heavy"
], - "hair_line": [
- "high",
- "low"
], - "haircolor": [
- "black",
- "brown",
- "red",
- "blond",
- "gray"
], - "makeup": [
- "light",
- "heavy",
- "none"
]
}, - "id:"c6bbe1cd719300c11e5c581889e9383245a0c1d923f210a3445e8ea5a25500e0"": null,
- "labels": [
- "age_14-26",
- "glasses",
- "Female"
], - "oracle": {
- "age": {
- "age": "low"
}, - "Beard": {
- "Beard": "low"
}, - "diversity": {
- "africa": "low",
- "brazil": "low",
- "england": "low",
- "france": "low",
- "germany": "low",
- "india": "low",
- "japan": "low",
- "korea": "low",
- "mexico": "low",
- "russia": "low",
- "spain": "low",
- "sweden": "low"
}, - "expression": {
- "angry": "high",
- "calm": "high",
- "contempt": "high",
- "disgusted": "high",
- "dreaming": "high",
- "fear": "high",
- "happy": "high",
- "surprised": "high"
}, - "gender": {
- "gender": "low"
}, - "glasses": {
- "glasses": "low"
}, - "hair_line": {
- "hair_line": "low"
}, - "haircolor": {
- "haircolor": "low"
}
}, - "rect": {
- "h": 375.98625326156616,
- "w": 280.4049072265625,
- "x": 1134.1341552734375,
- "y": 290.6307406425476
}, - "type:"person"": null
}, - {
- "actions": {
- "age": [
- "mid-20",
- "mid-40",
- "mid-60"
], - "Beard": [
- "shaved",
- "medium",
- "full"
], - "diversity": [
- "original",
- "africa",
- "korea",
- "india",
- "japan",
- "sweden",
- "germany",
- "russia",
- "mexico",
- "brazil",
- "england",
- "spain",
- "france",
- "unsplash"
], - "expression": [
- "happy",
- "surprised",
- "dreaming",
- "angry",
- "fear",
- "contempt",
- "disgusted",
- "sad",
- "smile"
], - "gender": [
- "femininity",
- "masculinity"
], - "glasses": [
- "light",
- "none",
- "heavy"
], - "hair_line": [
- "high",
- "low"
], - "haircolor": [
- "black",
- "brown",
- "red",
- "blond",
- "gray"
], - "makeup": [
- "light",
- "heavy",
- "none"
]
}, - "id:"d74da71f722b45de5f18f93e9dd7fc64a50a5a5dda001985ab9c2374807182b8"": null,
- "labels": [
- "age_26-42",
- "happy",
- "Female"
], - "oracle": {
- "age": {
- "age": "high"
}, - "Beard": {
- "Beard": "high"
}, - "diversity": {
- "africa": "high",
- "brazil": "high",
- "england": "high",
- "france": "high",
- "germany": "high",
- "india": "high",
- "japan": "high",
- "korea": "high",
- "mexico": "high",
- "russia": "high",
- "spain": "high",
- "sweden": "high"
}, - "expression": {
- "angry": "high",
- "calm": "high",
- "contempt": "high",
- "disgusted": "high",
- "dreaming": "high",
- "fear": "high",
- "happy": "high",
- "surprised": "high"
}, - "gender": {
- "gender": "high"
}, - "glasses": {
- "glasses": "high"
}, - "hair_line": {
- "hair_line": "high"
}, - "haircolor": {
- "haircolor": "high"
}
}, - "rect": {
- "h": 354.8530983924866,
- "w": 282.885498046875,
- "x": 555.80419921875,
- "y": 486.4655692577362
}, - "type:"person"": null
}
]
Description
Note: This API route requires the image to be registered via the /register
route.
The Create Route is used to create a new visual, based on the changes requested by the user for a previously uploaded visual.
You can also use this route on a modified image by providing the sid from the response of the previously used route.
This route returns both the URL and the sid associated with the updated image.
Before making any modifications, please call the /info or person/info route to obtain information on the available presenters in the image, the available modifications, and their oracle values.
You should always include all the required changes in the request if you want to use multiple changes on a single person. It is not supported to make one request on a person with one change, take the SId from the result, and then use it in another request with a different change.
When you want to make changes on multiple people, you can make one request with all the desired changes on all the relevant people or make one request with all the desired changes on one person and then use the sid from the response in the request on the other person.
Successful operation.
Bad request.
Specified Image does not exist.
Method not allowed.
Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
Description
This route is used to erase the foreground from a provided image, while generating the area behind it.
Successful operation.
Bad request. Missing or invalid parameters.
Unauthorized. Invalid API key or authentication token.
Not found. Image could not be found at the provided URL.
Payload too large. Image file size exceeds the 12MB limit.
Unsupported media type. Invalid file type. Supported file types are jpeg, jpg, png, webp.
Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.
Unavailable for legal reasons.
Failed to download image.
Internal server error. An error occurred on the server.
{- "result_url": "URL"
}
Description
The Eraser Route enables the removal of elements or specific areas from a given image.
You can define the area to be removed by providing a mask that outlines the region to be erased. There are two main ways recommended to generate these masks:
/objects/mask_generator
route, which will generate all the possible masks for an image.This capability is powered by our fast ControlNet inpainting model. HF model card is available here, and the HF demo space can be found here
Additionally, ComfyUI nodes that enable running this API route can be found here
Successful operation.
Bad request. Missing or invalid parameters.
Unauthorized. Invalid API key or authentication token.
Not found. Image could not be found at the provided URL.
Unsupported media type. Invalid file type. Supported file types are jpeg, jpg, png, webp.
Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.
Failed to download image.
Internal server error. An error occurred on the server.
{- "result_url": "URL"
}
Description
The Remove BG Route can be used to remove the background of an image. This route leverages Bria's newest model, RMBG 2.0. For more details and to explore the model, check out the Hugging Face demo.
The main difference between the regular and this isolated background removal endpoint is that you can use this endpoint without uploading or registering the image to Bria.
Constraints
The Bria API currently supports only JPEG and PNG files in RGB, RGBA, or CMYK color modes. When the file is of a different type or color mode, the status code 415 will be returned.
Remove the background from an image using the image file
In our documentation request example, we demonstrate how to remove the background from an image using the image URL.
If you want to use an image from a file, follow the example below:
import requests
url = "https://engine.prod.bria-api.com/v1/background/remove"
payload = {}
files=[
('file',('image_name.jpeg',open('/path_to_local_file/image_name.jpeg','rb'),'image/jpeg'))
]
headers = {
'api_token': 'xxxx'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
Successful operation.
File value was not provided.
Request doesn't contain file part.
Method not allowed.
Unsupported media type.
Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.
Failed to download image.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
{- "result_url": "string"
}
Description
The background/blur Route is used to create a blur effect on the background of an image.
Successful operation.
Bad request. Missing or invalid parameters.
Unauthorized. Invalid API key or authentication token.
Not found. Image could not be found at the provided URL.
Payload too large. Image file size exceeds the 12MB limit.
Unsupported media type. Invalid file type. Supported file types are jpeg, jpg, png, webp.
Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.
Unavailable for legal reasons.
Failed to download image.
Internal server error. An error occurred on the server.
{- "result_url": "URL"
}
Description
The Replace BG Route is used to replace the background of any image with a generated background using the state-of-the-art BRIA 2.3 ControlNet BG-Gen model (available on Hugging Face).
We offer a fast version of this feature, powered by Bria 2.3 Fast LoRA (model card on Hugging Face), which provides an optimal balance between speed and quality.
This endpoint also supports solid colors - you can take a color code and use it in the prompt.
Here are some examples:
original image:
bg_prompt: in a parking lot
num_results: 3
results:
Successful operation.
Bad request. Missing or invalid parameters.
Unauthorized. Invalid API key or authentication token.
Not found. Image could not be found at the provided URL.
Payload too large. Image file size exceeds the 12MB limit.
Unsupported media type. Invalid file type. Supported file types are jpeg, jpg, png, webp.
Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.
Unavailable for legal reasons.
Failed to download image.
Internal server error. An error occurred on the server.
{- "result": [
- [
- "result_url",
- 244184855,
- "ef3d9a20-4d5d-11ee-8741-8e22fc45bbfc.JPEG"
]
]
}
Description
The Image Expension Route can be used to expand an image, by utilizing generative AI.
You can decide on the image size of the final result as well as the position and size of the original image compared to the final result.
In this way, you can create unique variations of your original image instead of cropping it into different aspect ratios and losing important details.
Optimal input range
Input Image Area: Ensure that the ratio of the input image foreground or main subject to the canvas area is greater than 15% to achieve optimal results.
Canvas Size: The canvas size should be up to an area of 5000x5000 pixels. Here are some examples:
original image (Generated by Bria):
results:
original image (Stock Image):
results:
Successful operation.
Bad request. Missing or invalid parameters.
Unauthorized. Invalid API key or authentication token.
Not found. Image could not be found at the provided URL.
Payload too large. Image file size exceeds the 12MB limit.
Unsupported media type. Invalid file type. Supported file types are jpeg, jpg, png, webp.
Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.
Unavailable for legal reasons.
Failed to download image.
Internal server error. An error occurred on the server.
{- "code": 200,
- "description": "SUCCESS",
- "message": "Finished sucessfully",
- "prompt": "a man in a shirt sitting down in front of a brick wall looking off to the side",
- "result_url": "URL",
- "seed": 1525972691,
- "status": "SUCCESS"
}
Description
The Isolated Increase Resolution Route is used to upscale the resolution of any image.
The main difference between the regular and this isolated Increase Resolution endpoint is that you can use this endpoint without uploading or registering the image to Bria.
Constraints
The Bria API currently supports only JPEG and PNG files in RGB, RGBA, or CMYK color modes. When the file is of a different type or color mode, the status code 415 will be returned.
It's possible to increase the resolution of an image up to a total area of 8192x8192 pixels.
Increase the Resolution of an image using the image file
In our documentation request example, we demonstrate how to Increase the Resolution of an image using the image URL.
If you want to use an image from a file, follow the example below:
import requests
url = "https://engine.prod.bria-api.com/v1/image/increase_resolution?desired_increase=2"
payload = {}
files=[
('file',('image_name.jpeg',open('/path_to_local_file/image_name.jpeg','rb'),'image/jpeg'))
]
headers = {
'api_token': 'xxxx'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
Successful operation.
Bad request
Method not allowed.
The input image's resolution is too low.
Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.
Failed to download image.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
Description
Note: This API route requires the image to be registered via the /register
route.
It will be replaced soon with isolated version, that doesn't require image registration.
The Image to PSD Route is used to create a layered PSD file from any image.
The image is divided into different layers (depending on the image): a background layer with all identified objects removed, a foreground layer without the background, and a layer for each object.
You can also use this route on a modified image by providing the sid from the response of the previously used route.
Successful operation.
Bad request.
Specified Image does not exist.
Method not allowed.
Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
Description
The Crop Route is used to crop an image without a background tightly around the remaining region of interest.
You can utilize Bria's /background/remove endpoint and then use the result of that route in the/crop route.
Successful operation.
Bad request. Missing or invalid parameters.
Unauthorized. Invalid API key or authentication token.
Not found. Image could not be found at the provided URL.
Payload too large. Image file size exceeds the 12MB limit.
Unsupported media type. Invalid file type. Supported file types are jpeg, jpg, png, webp.
Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.
Unavailable for legal reasons.
Failed to download image.
Internal server error. An error occurred on the server.
{- "result_url": "URL"
}