...
Code Block | ||
---|---|---|
| ||
# print the top 3 label predictions for a given file path import json import subprocess path = '/path/to/file.mov' command = ['./classifier', '--top', '3', path] process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) output, error = process.communicate() if process.returncode != 0: print('Something went wrong: {} - Error: {}'.format(path, error)) else: result = json.loads(output) for path, predictions in result.items(): wikidata_ids = [item['value'] for item in predictions] # list of IDs from wikidata readable_labels = [item['label'] for item in predictions] # list of human readable labels print('For path: "{}" predicted the labels: {}'.format(path, ', '.join(readable_labels))) # result: # For path: "/path/to/file.mov" predicted the labels: torch, flame, fire |
Info
Get information about the current software version and the categories that can be classified.
classifier --info
key | description |
---|---|
id | the identifier for the class from Wikidata |
human-readable | meaningful readable label |
synonym | a list of different words for this class |
Result Format
For each file path you get an list of predictions for labels.
...
flag | description | ||
---|---|---|---|
| Shows information the software. | ||
| Get the top X predictions of labels.
| ||
| debugging mode |
...