DirectAI
computer vision without training data
Startup Instructions
- This was tested with
Python3.11.2. - Make sure to add your credentials after running
cp .env.template .env. See API docs for instructions on credential generation. This is not necessary if you're making calls to a self-hosted container. - Install requirements via
pip install -r requirements.txt. We specify package versions and can't guarantee performance with different versions.
Running Classification
- Quickstart: From the root directory, execute
python scripts/classification_on_collection.py. - Add image data that you're interested in running a classification model on to the
datafolder. - You can specify classes of interest via the command line (e.g.
-c dog -c cat) or with a filepath that points to a json (e.g.configs/classifier.json). - Arguments:
-hor--hostspecifies "DirectAI Host". It defaults to "https://api.alpha.directai.io". This may be useful if you're self-hosting a DirectAI container.-dor--data_dirspecifies the "Directory for Input Data". It defaults to "data". We accept.pngand.jpgimage formats. We've added a few samples from Pexels to the folder already!-ror--results_dirspecifies the "Directory for Results". It defaults to "results". We writeclassification_results.jsonto this directory. It specifies classification scores and ultimate class prediction for each input image.-for--config_file_pathspecifies the "File Path for Classifier Configuration". It defaults to "configs/classifier.json".-cor--classesspecifies the "List of Classes to Predict". If this is defined, it will replace theconfig_file_pathargument. We expect each class to be of the form-c {CLASS_NAME}.- Repeat as necessary (e.g.
python scripts/classification_on_collection.py -c dog -c parrot -c cat -c bear)
- Repeat as necessary (e.g.
Running Multi-Classification
- Quickstart: From the root directory, execute
python scripts/multi_classify_on_collection.py. - Add image data that you're interested in running multiple parallel classification models on to the
datafolder. - You can specify multiple classifiers of interest with several filepaths that point to a json (e.g.
configs/classifier.json&configs/alt_classifier.json). - Arguments:
-hor--hostspecifies "DirectAI Host". It defaults to "https://api.alpha.directai.io". This may be useful if you're self-hosting a DirectAI container.-dor--data_dirspecifies the "Directory for Input Data". It defaults to "data". We accept.pngand.jpgimage formats. We've added a few samples from Pexels to the folder already!-ror--results_dirspecifies the "Directory for Results". It defaults to "results". We writemulti_classification_results.jsonto this directory. It specifies classification scores and ultimate class prediction for each input image.-for--config_file_pathsspecifies the "File Path(s) for Classifier Configuration". It defaults to [configs/classifier.json,configs/alt_classifier.json].- Repeat as necessary (e.g.
python scripts/multi_classify_on_collection.py -f configs/classifier.json -f configs/alt_classifier.json -f configs/my_third_classifier.json)
- Repeat as necessary (e.g.
Running Detection
- Quickstart: From the root directory, execute
python scripts/detection_on_collection.py -b. - Add image data that you're interested in running a detection model on to the
datafolder. - You can specify objects of interest via the command line (e.g.
-c dog -c cat) or with a filepath that points to a json (e.g.configs/detector.json). - Arguments:
-hor--hostspecifies "DirectAI Host". It defaults to "https://api.alpha.directai.io". This may be useful if you're self-hosting a DirectAI container.-dor--data_dirspecifies the "Directory for Input Data". It defaults to "data". We accept.pngand.jpgimage formats. We've added a few samples from Pexels to the folder already!-ror--results_dirspecifies the "Directory for Results". It defaults to "results". We writedetection_results.jsonto this directory. It specifies classification scores and ultimate class prediction for each input image.-for--config_file_pathspecifies the "File Path for Classifier Configuration". It defaults to "configs/classifier.json".-cor--classesspecifies the "List of Classes to Predict". If this is defined, it will replace theconfig_file_pathargument. We expect each class to be of the form-c {CLASS_NAME}.- Repeat as necessary (e.g.
python scripts/detection_on_collection.py -c dog -c parrot -c cat -c bear)
- Repeat as necessary (e.g.
-bor--bounding_box_drawingis a "Flag to draw bounding boxes on images". If used, it will save annotated images to theresults_dirfolder.
Failure Modes
DirectAI's models work well for objects and categories that can be succintly described in natural language. If you notice a failure mode that isn't resolved by adding descriptions to examples_to_include and/or examples_to_exclude, please create an Issue or reach out directly!