This package contains different wrappers for the AI algorithms used in the labs to speed up development and improve research quality.
The package contains the following algorithm wrappers.
- Image segmentation
- Yolact++ (Instance segmentation)
- Yolact Edge (Instance segmentation for edge devices)
- Mask2Former (Panoptic segmentation)
- Yolo v8 (Instance segmentation)
- Classification
- MMT
- Pose detection
- Mediapipe (hand pose)
Each wrapper depends on its own AI module package. (e.g., YolactInference
depends on Yolact
).
We generally use a setup with CUDA 11.3 and Nvidia drivers 470. If you have this setup install the following pytorch dependences:
pip install torch==1.10.2+cu113 torchvision==0.11.3+cu113 torchaudio==0.10.2 -f https://download.pytorch.org/whl/torch_stable.html
To install ai_utils on your system clone the repo, open a terminal in the main directory and run the following command (source your virtual env if you use them):
python3 -m pip install .
Instead if you want to install the package in "editable" or "develop" mode (to prevent the uninstall/install of the package at each pkg update) you have can run the following command:
python3 -m pip install -e .
To use the ai_utils library in your environment you can refer to the following documentation.
First of all, be sure that your python build command is properly upgraded:
pip install --upgrade build
-
Algorithm installations documentation
To use the ai_utils library be sure to have installed the base algorithm as explained in Install Algorithms.
-
Algorithms setup documentation:
If you are using a standard Cmake package configuration you should save your network weights or config files
inside your package under a custom directory e.g., YOUR_PACKAGE_PATH/weights/YOUR_WEIGHT)
.
You'll probably need your package path in your code to use the AI algorithms (e.g., to load neural network weights).
If the files are saved as has been declared above you can use the following command to retrieve the package path:
import os
pkg_dir_name = '/' + os.path.join(*os.path.abspath(__file__).split('/')[:-2])
NOTE: in ROS2 packages are installed in the install directory of your workspace so the command to use to retrieve weight dir is:
import os
pkg_dir_name = '/' + os.path.join(*__file__.split('/')[:-5]) + '/share/PACKAGE_NAME/'
Anyway the path depends on how you install your package, the above command follow the standard convention of ROS2.
To run the tests in the tests
directory you have to install pytest:
sudo apt-get install pytest
Before running the tests you have to download the neural network weights from:
Put the weights and the config files in directories and change the path of weights in the tests scripts. All these passages are explained in the documentation: Mask2Former setup and Yolact++ setup. You can put directories directly in ai_utils package.
Finally, you can run tests from the terminal. Open a terimal in the ai_utils directory and type the following command:
python -m pytest .
Warnings are not meaningful in general.
Distributed under the GPLv3
License. See LICENSE for more information.
The package is provided by:
- Federico Rollo [Mantainer]
- Andrea Zunino