The Weapon Alcohol Drug detection model helps you determine if an image or video contains displays of weapons, alcoholic beverages, recreational drugs or medical drugs.
The API will return a weapon value between 0 and 1. This value reflects the API's confidence. Media with a weapon value closer to 1 have a higher probability of containing a weapon while media with a value closer to 0 have a lower probability.
The API has been designed to detect all displays wearable or personal weapons/arms typically found in user-submitted photos. Those include:
The detection will work even if for images with modified color schemes (black-and-white, changed saturation, icolor filter...)
The detection is also robust to varying levels of zooms, blurs, rotations.
The API has not been designed to detect the following concepts:
This model is usually used to moderate user-submitted images or videos and prevent users from posting or displaying unwanted content. Specific use-cases include:
When processing the weapon value returned by the API, users generally set a threshold. Images or videos with a value above this threshold will be flagged as potentially containing a weapon while images or videos with a value below will be considered to be safe.
Thresholds need to be fine-tuned for each individual use-case. Depending on your tolerance to false positives or false negatives, the threshold should be adapted.
The value returned is between 0 and 1, images with an alcohol value closer to 1 will have alcohol on the image, while images with an alcohol value closer to 0 will not have alcohol.
The API detects the following concepts:
The detection will work even if for images with modified color schemes (black-and-white, changed saturation, icolor filter...)
The detection is also robust to varying levels of zooms, blurs, rotations.
The API has *not* been designed to detect drunk people or other effects of alcohol consumption.
This model is usually used to moderate user-submitted images or videos and prevent users from posting or displaying unwanted content. Specific use-cases include:
When processing the alcohol value returned by the API, users generally set a threshold. Images or videos with a value above this threshold will be flagged as potentially containing alcoholic beverages while images or videos with a value below will be considered to be safe.
Thresholds need to be fine-tuned for each individual use-case. Depending on your tolerance to false positives or false negatives, the threshold should be adapted.
The value returned is between 0 and 1, images with a value close to 1 will contain displays of drugs, while images with a value closer to 0 are considered to be safe.
The API detects the following concepts:
Symbol used to represent marijuana / cannabis or more generally drugs.
drugs
Dried buds, cannabis crystals, kief.
drugs
Cannabis cigarette, also known as spliff or dooble. The model is designed to differentiate regular tobacco cigarettes from cannabis joints.
drugs
Devices used to smoke cannabis and other herbal substances.
drugs
Medical syringes, usually made of plastic, that might be used for recreational purposes such as drug injection.
drugs
Pills, tablets, and other small doses of medicine.
drugs
Self administration of some recreational drugs such as ketamine, cocaine.
drugs
The detection will work even if for images with modified color schemes (black-and-white, changed saturation, icolor filter...)
The detection is also robust to varying levels of zooms, blurs, rotations.
When processing the drugs value returned by the API, users generally set a threshold. Images or videos with a value above this threshold will be flagged as potentially containing drugs while images or videos with a value below will be considered to be safe.
Thresholds need to be fine-tuned for each individual use-case. Depending on your tolerance to false positives or false negatives, the threshold should be adapted.
If you haven't already, create an account to get your own API keys. You should then install the SDK that corresponds to your programming language. You can also implement your own logic to interact with our API if you prefer. Have a look at our API reference for more details.
# install cURL: https://curl.haxx.se/download.html
pip install sightengine
composer require sightengine/client-php
npm install sightengine --save
Let's say you want to moderate the following image:
You can either upload a public URL to the image, or upload the raw binary image. Here's how to proceed if you choose to share the image's public URL:
curl -X GET -G 'https://api.sightengine.com/1.0/check.json' \
-d 'models=wad' \
-d 'api_user={api_user}&api_secret={api_secret}' \
--data-urlencode 'url=https://sightengine.com/assets/img/examples/example-tt-1000.jpg'
# if you haven't already, install the SDK with 'pip install sightengine'
from sightengine.client import SightengineClient
client = SightengineClient('{api_user}','{api_secret}')
output = client.check('wad').set_url('https://sightengine.com/assets/img/examples/example-tt-1000.jpg')
// if you haven't already, install the SDK with 'composer require sightengine/client-php'
use \Sightengine\SightengineClient;
$client = new SightengineClient('{api_user}','{api_secret}');
$output = $client->check(['wad'])->set_url('https://sightengine.com/assets/img/examples/example-tt-1000.jpg');
// if you haven't already, install the SDK with 'npm install sightengine --save'
var sightengine = require('sightengine')('{api_user}','{api_secret}');
sightengine.check(['wad']).set_url('https://sightengine.com/assets/img/examples/example-tt-1000.jpg').then(function(result) {
// The API response (result)
}).catch(function(err) {
// Handle error
});
The API will then return a JSON response:
{
"status": "success",
"request": {
"id": "req_1OjggusalNb2S7MxwLq2h",
"timestamp": 1509132120.6988,
"operations": 1
},
"weapon": 0.773,
"alcohol": 0.001,
"drugs": 0,
"media": {
"id": "med_1OjgEqvJtOhqP7sfNe3ga",
"uri": "https:\/\/sightengine.com\/assets\/img\/examples\/example-tt-1000.jpg"
}
}
We're always looking for advice to help improve our documentation!