Content classification

When classifying your videos, you can use the threshold parameter to filter the results based on the level of confidence that the results match the prompts you've specified in the request. The minimum value is 0 and the maximum value is 100. If the parameter is not set, it takes the default value of 75. This allows you to narrow down a response obtained from the platform by retrieving only the most relevant results

Note that the example on this page is specific to classifying a single video. However, the principles demonstrated are similar when classifying multiple videos.

Example

For a description of each field in the request and response, see the API Reference> Classify a video page.

Prerequisites

  • You’re familiar with the concepts that are described on the Platform overview page.
  • You’ve uploaded at least one video to your index, and the platform has finished indexing it. For details, see the Upload videos page.

Filter based on the level of confidence

The following example code specifies that the minimum value of the threshold parameter should be 80:

CLASSIFY_URL = f"{API_URL}/classify"
data =  {
  "conversation_option": "semantic",
  "options": ["visual"],
  "video_id": VIDEO_ID,
  "threshold": 80,
  "classes": [
      {
      "name": "DanceTok",
      "prompts": [
        "Dance tutorial",
        "Dance group",
        "Dance competition"
      ]
    }
  ]
}
response = requests.post(CLASSIFY_URL, headers=headers, json=data)
print (f'Status code: {response.status_code}')
pprint(response.json())
const CLASSIFY_URL = `${API_URL}/classify`

const data =  {
  'conversation_option': 'semantic',
  'options': ['visual'],
  'video_id': VIDEO_ID,
  'threshold': 80,
  'classes': [
      {
      'name': 'Car shapes',
      'prompts': [
        'SUV',
        'Hatchback',
        'Crossover',
        'Sedan',
        'Coupe',
        'Minivan',
        'Station Wagon',
        'Pickup Truck',
        'Truck',
        'Convertible'
      ]
    }
  ]
}
const resp = await axios.post(
  CLASSIFY_URL,
  data,
  {
    'headers': {
      'x-api-key': API_KEY
    }
  }
)
const { data: response } = resp;
console.log(`Status code: ${resp.status}`)
console.log(JSON.stringify(response,null,4))

The output should look similar to the following one:

Status code: 200
{
  "video_id": "6435651a9ab33c7198615a80",
  "classes": [
    {
      "name": "DanceTok",
      "score": 96.77333333333335,
      "duration_ratio": 1,
      "detailed_scores": {
        "max_score": 86.37,
        "avg_score": 71.61778350515468,
        "duration_weighted_score": 96.77333333333335,
        "normalized_score": 100
      }
    }
  ]
}