Products

SIGN UP LOG IN

Models / Text Moderation in Images/Videos

Text Moderation in Images/Videos

Overview

The Visual Text Moderation API is useful to determine if an image or video contains unwanted text such as profanity or personally identifiable information.

The API gives you fine-grained control over the moderation decision. The API will tell you what type of content has been found (phone number, email address, discriminatory content, sexual content...) along with a text extract of the content. You can then use this response to reject, flag or review the image/video on your end.

Just like our other Image Moderation APIs, this API uses advanced AI to perform the analysis entirely automatically. There are no humans reviewing your content. This helps us achieve very fast turnaround times — typically a couple of seconds — and very high scalablity.

boxes showing natural text found on a woman's shirt and artificial text added through post-processing
Image containing flagged profanity

Principles

The Text Moderation API for Images works in several steps:

  1. Detection of text items contained in the image
  2. Recognition of the text (this is equivalent to transforming text into string objects)
  3. Analysis of the recognized text, through our text moderation engine

Use-cases

  • Prevent users from adding insults, profanity, racial slurs or sexually suggestive text in an image
  • Remove photos that contain PII such as an email address or phone number
  • Flag users who include links/URLs in their images
  • Prevent users from mentioning their social accounts in images

Profanity Detection in Images

Profanity Detection will enable you to detect insults, discriminatory content, sexual content or other inappropriate words and phrases in your images.

It is a lot stronger than word-based filters. It uses advanced language analysis to detect objectionable content, even when users specifically attempt to circumvent your filters. It covers obfuscation techniques such as repetitions, insertions, spelling mistakes, leet speak and more. Learn more on our Text Moderation Engine.

boxes showing natural text found on a woman's shirt and artificial text added through post-processing
Image containing flagged profanity

Personal Information Detection in Images

Email addresses

Email addresses will be detected and flagged as such in the image.

Image with a flagged email address

Phone numbers

Phone numbers will be detected and flagged as such in the image.

You can select the countries to be covered through the opt_countries parameter. Provide a comma-separated list of the ISO 3166 2-letter country codes. For instance us for the United-States, fr for France. See the full list of supported countries.

If you do not specify any country, the API will default to the following list of countries: United States us, France fr, United Kingdom gb

Image with a flagged US phone number

Link and URL Detection in Images

Links and URLs will be detected and flagged as such in the image.

Image with a flagged link to a twitter handle

In addition to detecting URLs in Images or Videos, you can also moderate the link to determine if the link is unsafe, deceptive or known to contain otherwise unwanted content (such as adult content, gambling, drugs...). More details are available on the URL and link moderation page.

Social Account Detection in Images

Mentions of social networks and social accounts can be detected in images. This detection works on any text-based mention. It will not flag logos of said social networks.

The most common social networks are supported by default: facebook, whatsapp, snapchat. Other social networks can be made available on a custom basis. Reach out for more.

Image with a flagged mention of a social network or account

Custom disallow or allow lists

You can use custom disallow lists (also known as blacklist or ban list) and allow lists along with with Text-in-image moderation and Text-in-video moderation.

To create a new text list, go to the dedicated page on your dashboard.

Once your text list has been created, you will have the opportunity to add entries to the text list.

View your custom list

Each entry is a text item that you want to detect, along with meta-data to help our engine determine how and when this entry should be detected. The following information will be needed:

  • Text: this is the text item you want to detect.
  • Language: this is the language to which the text item applies. If it appears in a text item with a different language, it will not be flagged. If you need a text item to be detected in all languages, select all
  • Match type: this is the way the detection engine should detect. Choose exact match if you want the engine to detect the exact string, with no modifications (apart from case modifications).
    Choose standard match if you want the engine to detect variations such as phonetic variations, repetitions, typos, leet speak etc... This will typically cover millions of variations and make sure your users cannot simply obfuscate the word to fool the engine.
  • Category: this is a suggested categorization of the text item, to help you sort and filter entries.
Add a new entry to your custom list

While most users only need to create a single text list, you can create multiple text lists to apply different moderation criteria to different types of text items.

In order to use a custom list, you will have to specify the corresponding id of the list in the opt_textlist parameter in your API calls.

Languages and Recommendations

Languages

English is the default language used for the text recognition and profanity filtering.

You can set a different language with the opt_lang parameter. To do so use the following codes:

LanguageCode
English (default)en
Chinesezh
Danishda
Dutchnl
Finnishfi
Frenchfr
Germande
Italianit
Norwegianno
Portuguesept
Spanishes
Swedishsv
Tagalog / Filipinotl
Turkishtr

Other languages are available upon request. Please get in touch.

Recommendations

  • Minimum text size: text that is too small to read may be ignored. Our recognition engine will analyze text that has a width or height of at least 4% of the image's max dimension.
  • Dense text: This Model has been designed to work with photographs that contain short text items. It is not meant to analyze images with dense text such as PDFs, scans or photos of printed documents. If you submit an image containing dense text, the API will decline the image and ignore the dense text. To know if text has been ignored just check the ignored_text flag. It is set to true when dense text has been ignored
  • Image rotation: Make sure submitted images are correctly rotated or have proper rotation EXIF data. Text that is upside-down or rotated (by more than 20 degrees) might not be properly recognized
  • Multi-frame processing: GIF images containing multiple frames will not be processed. If you need to review a multi-frame GIF image, we recommend submitting individual frames to the API

Use the model

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

Detect unwanted text in an image

Let's say you want to moderate the following image:

photo with an embedded phone number

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=text-content' \
    -d 'api_user={api_user}&api_secret={api_secret}' \
    --data-urlencode 'url=https://sightengine.com/assets/img/examples/example-text-ocr-3.jpg'


# this example uses requests
import requests
import json

params = {
  'url': 'https://sightengine.com/assets/img/examples/example-text-ocr-3.jpg',
  'models': 'text-content',
  '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/examples/example-text-ocr-3.jpg',
  'models' => 'text-content',
  '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/examples/example-text-ocr-3.jpg',
    'models': 'text-content',
    '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:

            
            
{
    "status": "success",
    "request": {
        "id": "req_22Qd0gUNmRH4GCYLvYtN6",
        "timestamp": 1512483673.1405,
        "operations": 1
    },
    "text": {
        "personal": [
          {
            "type": "phone_number_us",
            "match": "+1 800 222 2408"
          }
        ],
        "link": [],
        "social": [],
        "profanity": [],
        "ignored_text": false
    },
    "media": {
        "id": "med_22Qdfb5s97w8EDuY7Yfjp",
        "uri": "https://sightengine.com/assets/img/examples/example-text-ocr-3.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?