Metadata-Version: 2.4
Name: openvisioncapsule-tools
Version: 0.6.5
Summary: A tool to help users to package, test OpenVisionCapsules
License: BSD License
Author: Stephen Li
Author-email: stephen@aotu.ai
Requires-Python: >=3.9,<4.0
Classifier: License :: OSI Approved :: BSD License
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: Cython (==0.29.30)
Requires-Dist: Pillow (>=7.0.0)
Requires-Dist: PyYAML (>=6.0.2,<7.0.0)
Requires-Dist: matplotlib (==3.5.1)
Requires-Dist: numpy (>=1.19.2,<1.20.0)
Requires-Dist: opencv_contrib_python
Requires-Dist: opencv_contrib_python_headless
Requires-Dist: openvino (>=2024.1.0,<2025.0.0)
Requires-Dist: pandas (==1.1.5)
Requires-Dist: python_i18n (>=0.3.9,<0.4.0)
Requires-Dist: setuptools (==73.0.1)
Requires-Dist: tools (==0.1.9)
Requires-Dist: torch (==1.9.0)
Requires-Dist: tqdm (==4.54.1)
Requires-Dist: vcap (>=0.5.5)
Requires-Dist: vcap-utils (>=0.5.3)
Description-Content-Type: text/markdown

# Capsule Inference

This tool is used during development to quickly and easily run inference 
with a capsule. 

## Usage
Make sure you are running in an environment with `vcap` and `vcap-utils` 
installed.

Running is simple. Point the script to the capsule of choice, and list one 
or more images to run inference on. For example:

```shell
python3 capsule_infer.py --capsule my-detector-capsule/ --images img.png 
img2.png 
```

You can also point `--images` to a path that contains images.

Or download capsule-zoo to run capsule inference test on person, vehicle, bike,

```
python3 capsule_infer.py --capsule {capsule-zoo directory}/capsules/detector_person_vehicle_bike_openvino  --images {capsule-zoo directory}/tests/test_resources/two_people.jpg
```

# Capsule Classifier accuracy

This tool is used during development to quickly and easily run accuracy benchmark 
with a capsule. The output is a set of benchmark reports.

## Usage
Make sure you are running in an environment with `vcap` and `vcap-utils` 
installed.

Running is simple. Point the script to the capsule of choice, and list one 
or more images to run inference on. For example:
```shell
python3 capsule_classifier_accuracy.py --capsule <capsule directory or .cap> --images-true <true image directory> --images-false <false image directory> --data attribute=<name> true_threshold=0.0 false_threshold=0.0 detection=<class name>
```

Optional image categories are as follows,

 `--images`, `--images-true`, `--images-false`

# How to build openvisioncapsule-tools

Build in Docker, so the result does not depend on what is installed on your machine. Run this from the
repository root. It builds the wheel and sdist with Poetry, installs the wheel into a clean environment,
runs `tools/tests` against it, and only then exports the files to `tools/dist/`:

```shell
# 0.6.x line (Python 3.9, what the BrainFrame core runs)
docker build --file tools/Dockerfile.build --output type=local,dest=tools/dist .

# 0.5.x line (Python 3.8)
docker build --file tools/Dockerfile.build --output type=local,dest=tools/dist \
    --build-arg PYTHON_VERSION=3.8 --build-arg PYPROJECT=pyproject.toml.py38 .
```

If a test fails, the build fails and nothing is exported. Publishing is described in `PUBLISHING.md`.

# Test openvisioncapsule-tools module installation

Build an Ubuntu image for testing the module installation with the following command, replace 20.04 with 22.04 or 24.04 as needed,

```shell
DOCKER_BUILDKIT=1 docker build --file tools/Dockerfile.ubuntu --build-arg UBUNTU_VERSION=20.04 --tag ubuntu-2004 --no-cache .
```
Run the Ubuntu image to test the module installation
```shell
docker run -it --rm -v ./tools:/open_vision_capsules/tools -w /open_vision_capsules/ ubuntu-2004 bash
```
Test the module installation in the docker container,
```shell
pip install tools/dist/openvisioncapsule_tools-0.5-py3-none-any.whl
```

Run the module

```shell
openvisioncapsule-tools
```

# Running the tests

The tests drive the installed `openvisioncapsule-tools` command, so install the built package first
(Python 3.9; see `PUBLISHING.md` for the build steps), then run

```shell
cd tools
python -m pytest tests -v
```

