Products

SIGN UPLOG IN
Nudity Detection

Models / Smoking & Tobacco Product Detection

Smoking & Tobacco Product Detection

Overview

The Smoking & Tobacco Product detection model helps you determine if an image or video contains tobacco products and smoking-related situations such as:

  • people visibly smoking (such as holding a cigarette or puffing smoke)
  • cigarettes, cigarette butts, cigarette packs and similar paper-based smoking products
  • cigars
  • pipes
  • hookahs, shishas
  • vapes and vaping products
  • loose or chewing tobacco

This model focuses on products that are legal in most jurisdictions.

To detect marijuana-related smoking such as joints, cannabis, marijuana leaves, processed marijuana or to detect devices usually related to the consumption of illegal drugs (such as bongs or glass pipes) use the Drug Detection model.

Regular tobacco

The regular_tobacco class is used to flag tobacco products and smoking scenes that do not include any references to marijuana/cannabis or other drugs.

The following situations will be flagged:

Cigarettes & cigarette butts

Typical commercial cigarettes or cigarette butts. This does *not* include joints that are visibly associated with marijuana.

regular_tobacco

People smoking or puffing smoke

Displays of people visibly smoking, such as holding a cigarette, cigar or pipe, puffing smoke, or having their face surrounded by smoke. This does *not* include cases with references to marijuana.

regular_tobacco

Cigarette packs

Typical commercial cigarette packs, as sold in stores.

regular_tobacco

Cigars

Cigars in hand or in cigar boxes.

regular_tobacco

Smoking Pipes

Tobacco pipes, either in hand or not. This does not include glasspipes.

regular_tobacco

Hookahs, shishas or waterpipes

Instruments used for smoking, especially in some European or Middle-Eastern countries. This does not include bongs.

regular_tobacco

Chewing or loose tobacco

Tobacco products that are not smoked: chewing tobacco, snuff, dip and loose tobacco.

regular_tobacco

Vapes and electronic cigarettes

Vapes, vape juice, vape cartridges, unless they have marijuana symbols.

regular_tobacco

Ambiguous tobacco

In some cases, it is not possible to determine if a hand-rolled cigarette contains only regular tobacco or if it also contains marijuana/cannabis/weed. In such cases, the API will return the ambiguous_tobacco tag:

Ambiguous cigarette or joint

Hand-rolled cigarette/joint/blunt/cigarillo where it is unclear whether the content is tobacco or marijuana due to shape, zoom or visibility.

ambiguous_tobacco

If there are additional signs that the content is marijuana-related (such as the color or shape of the joint, the image context, marijuana symbols or references, marijuana-related paraphernalia etc), then this will not be flagged here. To detect such instances, use the Drug Detection model.

Use the model

If you haven't already, create an account to get your own API keys.

Detect Tobacco

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=tobacco' \
    -d 'api_user={api_user}&api_secret={api_secret}' \
    --data-urlencode 'url=https://sightengine.com/assets/img/doc/tobacco/smoking.jpg'


# this example uses requests
import requests
import json

params = {
  'url': 'https://sightengine.com/assets/img/doc/tobacco/smoking.jpg',
  'models': 'tobacco',
  'api_user': '{api_user}',
  'api_secret': '{api_secret}'
}
r = requests.get('https://api.sightengine.com/1.0/check.json', params=params)

output = json.loads(r.text)


$params = array(
  'url' =>  'https://sightengine.com/assets/img/doc/tobacco/smoking.jpg',
  'models' => 'tobacco',
  'api_user' => '{api_user}',
  'api_secret' => '{api_secret}',
);

// this example uses cURL
$ch = curl_init('https://api.sightengine.com/1.0/check.json?'.http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

$output = json_decode($response, true);


// this example uses axios
const axios = require('axios');

axios.get('https://api.sightengine.com/1.0/check.json', {
  params: {
    'url': 'https://sightengine.com/assets/img/doc/tobacco/smoking.jpg',
    'models': 'tobacco',
    'api_user': '{api_user}',
    'api_secret': '{api_secret}',
  }
})
.then(function (response) {
  // on success: handle response
  console.log(response.data);
})
.catch(function (error) {
  // handle error
  if (error.response) console.log(error.response.data);
  else console.log(error.message);
});

The API will then return a JSON response such as this:

                    
                    
{
    "status": "success",
    "request": {
        "id": "req_1OjggusalNb2S7MxwLq2h",
        "timestamp": 1509132120.6988,
        "operations": 1
    },
    "tobacco": {
        "prob": 0.9,
        "classes": {
          "regular_tobacco": 0.9,
          "ambiguous_tobacco": 0.01
        }
    },
    "media": {
        "id": "med_1OjgEqvJtOhqP7sfNe3ga",
        "uri": "https://sightengine.com/assets/img/doc/tobacco/smoking.jpg"
    }
}
                    
                

Any other needs?

See our full list of Image/Video models for details on other filters and checks you can run on your images and videos. You might also want to check our Text models to moderate text-based content: messages, reviews, comments, usernames...

Was this page helpful?