openvisioncapsule-tools¶
openvisioncapsule-tools helps VisionCapsule developers package and test capsules, and check which inference
hardware is available on a machine. For how to write a capsule, see the
VisionCapsule documentation.
Installation¶
pip install openvisioncapsule-tools
This tool is tested on Python 3.9.
Usage¶
openvisioncapsule-tools <command> [options]
To list the options of a command, run openvisioncapsule-tools <command> --help.
Note
Unlike the other BrainFrame command line tools, the command names of openvisioncapsule-tools are written with
underscores, for example capsule_packaging.
Commands¶
| Command | Purpose |
|---|---|
capsule_packaging |
Package capsule directories into .cap files, or unpackage a .cap file. |
capsule_inference |
Run a capsule on local images to test it. |
devices |
List the inference hardware and software frameworks on this machine. |
capsule_packaging¶
Packages capsules for distribution, or unpackages a capsule file to see its contents.
Package capsules
--capsule-dir is a directory that contains one subdirectory for each capsule. Every subdirectory is packaged into a
.cap file in the same location. For example, packaging a directory my_capsules/ that contains
detector_example/ creates my_capsules/detector_example.cap.
openvisioncapsule-tools capsule_packaging --capsule-dir my_capsules/
To encrypt the packaged capsules, add a key. You need the same key to unpackage or load them.
openvisioncapsule-tools capsule_packaging --capsule-dir my_capsules/ --capsule-key YOUR_KEY
Unpackage a capsule
openvisioncapsule-tools capsule_packaging --capsule-file my_capsules/detector_example.cap --capsule-key YOUR_KEY
The capsule is extracted to a directory with the same name as the file, without the .cap extension. Leave out
--capsule-key for a capsule that was packaged without a key.
| Option | Description |
|---|---|
--capsule-dir CAPSULE_DIR |
The directory that contains the capsule directories to package. |
--capsule-file CAPSULE_FILE |
The .cap file to unpackage. |
--capsule-key CAPSULE_KEY |
The encryption key used to package or unpackage. |
Give either --capsule-dir or --capsule-file. If you give neither, the command prints its help.
capsule_inference¶
Runs a capsule on images on your computer, without a BrainFrame server. Use it to check a capsule while you develop it.
openvisioncapsule-tools capsule_inference --capsule my_capsules/detector_example --images photo.jpg
--capsule can be either an unpackaged capsule directory or a packaged .cap file. If you give a directory, the
tool packages it to a .cap file next to it before it runs.
--images takes one or more image files, or directories. For a directory, the .png, .jpg, and .jpeg files in
it are used.
openvisioncapsule-tools capsule_inference --capsule my_capsules/detector_example --images photo1.jpg photo2.jpg
openvisioncapsule-tools capsule_inference --capsule my_capsules/detector_example --images test_images/
Testing classifiers
A classifier, or other capsule that works on detections found by another capsule, needs an input detection. Use
--detection to give the class name. The whole image is passed to the capsule as a detection of that class.
openvisioncapsule-tools capsule_inference --capsule my_capsules/classifier_example --images face.jpg --detection face
Capsule options
The tool saves the capsule options it used to options.json in the current directory, with the default value for
each option. To test other values, edit the values in this file and run the command again. The file is read on each
run.
Output
For each image, the tool prints the capsule's load time, the available detection class names, the options in use, the processing time, and the results. If a display is available, it also shows the image with the detections drawn on it. Press a key to move to the next image.
| Option | Description |
|---|---|
--capsule CAPSULE |
The capsule directory or .cap file. Required. |
--images IMAGES [IMAGES ...] |
The images, or directories of images, to run. |
--detection DETECTION |
The class name of the input detection, for capsules that need one. |
--options OPTIONS |
The file that holds the capsule options. Default: options.json. |
--capsule-key CAPSULE_KEY |
The key of an encrypted capsule. Use brainframe for capsules signed for BrainFrame. |
devices¶
Lists the inference hardware and software frameworks that are available on the machine. Use it to find out which accelerators your capsules can use, and to include in support requests.
openvisioncapsule-tools devices
The output includes:
- The CPU model and count, the Python version, the Linux distribution, and the kernel version
- The NVIDIA GPU model, driver, and CUDA version
- The Intel OpenVINO version, the Intel OpenCL driver version, and the OpenVINO devices that were found
- The PyTorch (
torch) version and its GPU devices - The TensorFlow version, and its CPU and GPU devices
- The VisionCapsule (
vcap) version, and the devices and priority order that VisionCapsules use