This is the command line tool from das-element for classification of image, sequence and movie files.
Tip |
---|
Deploy You can deploy it on your render farm to use it in a post-render process for labeling of elements. |
...
Simple usage: classifier {file}
...
The result is in JSON format | ||
Code Block | ||
---|---|---|
| ||
classifier /path/to/file.mov # result: {"/path/to/file.mov": [{"label": "fire", "description": "rapid oxidation of a material", "value": "Q3196"}]} |
...
Code Block | ||
---|---|---|
| ||
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 |
Result format
For each file path you get an list of predictions for labels.
The result is in JSON format. The default string format is Unicode.
Code Block | ||
---|---|---|
| ||
{ |
...
'/path/to/file.mov': [{ |
...
'description': |
...
'stick with a flaming end used as a source of light', |
...
'value': |
...
'Q327954', |
...
'label': |
...
'torch' }]} |
...
flag | description |
---|---|
| Shows all information the software.
|
| Get results of the top X predictions of labels |
| debugging mode |