REST API (v1) mode
REST API mode for Celantur Container
Use the REST API to anonymize images and videos.
- 1.
- 2.
- 3.Download segmentation masks and metadata:
- 1.
- 2.
- 3.
Currently, REST API mode only works synchronously. This means you can only process one image at a time per container instance. Async processing is coming soon.
Metadata, binary and instance segmentation masks are not yet supported for videos.
post
https://localhost/v1
/file
Upload file
Upload a file that is processed with the specified method. The container only holds data for one image at any time. A new POST request overwrites the old data.
Parameters
Query
method*
String
Enum:
blur
, pixelate
, blacken
, detect
Default:
blur
Specifies processing method.
Method
detect
only returns segmentation and binary masks, not an anonymized image.debug
Boolean
Print bounding boxes and segmentation masks of detected objects on the image.
score
Boolean
Print the detection scores of objects on the image. Works only if debug is true.
face
Boolean
Specifies whether faces should be anonymized/detected.
license-plate
Boolean
Specifies whether license plates should be anonymized/detected.
person
Boolean
Specifies whether persons should be anonymized/detected.
vehicle
Boolean
Specifies whether vehicles should be anonymized/detected.
bbox
Boolean
Anonymize bounding boxes of objects (instead of segmentation)
format
String
Default: "whole"
Example: format={"number": [2,2], "overlap": [0, 0]}
Tiling of the input image
ignores
String
Default: ""Example: ignores=[{"topLeftX": 182,"topLeftY": 154,"width":2000,"height":2000}]
Areas of the image that are not going to be anonymized
face-threshold
Number
Specifies detection threshold
0..1
for faces.
Default:
0.5
vehicle-threshold
Number
Specifies detection threshold
0..1
for vehicles.
Default:
0.4
person-threshold
Number
Specifies detection threshold
0..1
for persons.
Default:
0.4
license-plate-threshold
Number
Specifies detection threshold
0..1
for license plates.
Default:
0.5
segmentation-threshold
Number
DEPRECATED
Specifies detection threshold value for segmentation.
▶ Use
person-threshold
and vehicle-threshold
instead.Body
fileobject*
string<binary> (Fileobject)
Images:
fileobject=@/path/to/input/image;
Videos:
Specify the video type
fileobject=@/path/to/input/video;type=video/mp4
Videos need to be encoded in mpeg, h264 or h265.
Responses
200: OK
JSON
422: Unprocessable Entity
JSON
500: Internal Server Error
get
https://localhost/v1
/file/{id}/anonymised
Download anonymized image
Download anonymized image
Parameters
Path
id*
Number
The
id
of the file that will be downloaded.Query
download
String
Enum:
JPEG
or PNG
Whether the image should be downloaded as a JPEG or PNG.
quality
Number
Specifies quality level for JPEG images ranging from
1 .. 100
.
Default:
90
compress-level
Number
Specifies compression level for PNG images ranging from
0 .. 9
.
Default:
5
Responses
200: OK
JPEG or PNG
422: Unprocessable Entity
JSON
500: Internal Server Error
get
https://localhost/v1/file
/{id}/video/anonymised
Download anonymized video
get
https://localhost/v1
/file/{id}/binary-mask
Download binary mask
Parameters
Path
id*
Number
The
id
of the file whose binary segmentation mask will be downloaded.Query
mask-scale
Number
Specifies the ratio at which the mask file will be scaled down, range between
0 .. 100
.
Default:
100
Responses
200: OK
PNG
422: Unprocessable Entity
JSON
500: Internal Server Error
For conceptual information on segmentation masks, see:
get
https://localhost/v1
/file/{id}/instance-mask
Download instance mask
Parameters
Path
id
Number
The
id
of the file whose instance segmentation mask will be downloaded.Query
mask-scale
Number
Specifies the ratio at which the mask file will be scaled down, range between
0 .. 100
.
Default:
100
Responses
200: OK
PNG
422: Unprocessable Entity
JSON
500: Internal Server Error
For conceptual information on segmentation masks, see:
get
https://localhost/v1
/file/{id}/metadata
Download file metadata (JSON)
Parameters
Path
id*
Number
The
id
of the file whose metadata will be downloaded.Responses
200: OK
JSON
422: Unprocessable Entity
JSON
500: Internal Server Error
get
https://localhost/v1
/status
Check Celantur Container status
Returns health status of of Celantur Container.
200 when running, 500 when down.
Parameters
No parameters
Responses
200: OK
JSON
500: Internal Server Error
Start the server with all object types (
-a face -a license-plate -a person -a vehicle
) that you want to anonymize by using the API. You can select specific objects for individual images using API calls.bash celantur.sh --api --api-endpoint http://localhost:7000/ -a face -a license-plate -a person -a vehicle --format whole
curl -i -X GET 'http://127.0.0.1:7000/v1/file/status'
Response
{
"status": "RUNNING"
}
curl -i -X POST 'http://127.0.0.1:7000/v1/file?method=pixelate&face=True' -F 'fileobject=@/path/to/original-image.jpg'
curl -i -X POST 'http://127.0.0.1:7000/v1/file?method=blur&debug=True&person=True' -F 'fileobject=@/path/to/original-image.jpg'
Post method returns image id with GET request links:
JSON Response
{
"content-type": "image/jpeg",
"id": "{image_id}",
"metadata-url": "http://localhost:7000/v1/file/{image_id}/metadata",
"binary-mask-url": "http://localhost:7000/v1/file/{image_id}/binary-mask",
"instance-mask-url": "http://localhost:7000/v1/file/{image_id}/instance-mask",
"anonymised-url": "http://localhost:7000/v1/file/{image_id}/anonymised"
}
curl -X GET http://127.0.0.1:7000/v1/file/{image_id}/anonymised --output /path/to/anonymised-image.jpg


curl -X GET http://127.0.0.1:7000/v1/file/{image_id}/binary-mask --output /path/to/binary-mask.png
curl -X GET http://127.0.0.1:7000/v1/file/{image_id}/instance-mask --output /path/to/instance-mask.png
curl -X GET http://127.0.0.1:7000/v1/file/{image_id}/instance-mask?mask-scale=50 --output /path/to/instance-mask.png

curl -X GET http://127.0.0.1:7000/v1/file/{image_id}/metadata
{
"id": "omar-lopez-rwF_pJRWhAI-unsplash.jpg",
"detections": [
{
"id": 0,
"parent_image": "omar-lopez-rwF_pJRWhAI-unsplash.jpg",
"offset": [
1560,
744
],
"bbox": [
1957,
744,
3003,
1855
],
"type": 103,
"score": 0.9993754029273987,
"is_anonymised": true,
"type_label": "face",
"color": null
},
{
"id": 0,
"parent_image": "omar-lopez-rwF_pJRWhAI-unsplash.jpg",
"offset": [
2682,
760
],
"bbox": [
3091,
760,
4078,
1680
],
"type": 103,
"score": 0.9989292025566101,
"is_anonymised": true,
"type_label": "face",
"color": null
},
{
"id": 0,
"parent_image": "omar-lopez-rwF_pJRWhAI-unsplash.jpg",
"offset": [
3736,
712
],
"bbox": [
4015,
758,
4777,
1520
],
"type": 103,
"score": 0.9988161325454712,
"is_anonymised": true,
"type_label": "face",
"color": null
}
],
"size": [
3456,
5184
],
"duration": 1.8533296539999355,
"filename": "omar-lopez-rwF_pJRWhAI-unsplash.jpg",
"folder": null
}
Last modified 8d ago