This directory contains a simple example of inference for DOPE.
If you haven't already, install the dependencies listed in requirements.txt
in the root of the repo:
pip install -r ../requirements.txt
The inference.py
script will take a trained model to run inference. In order to run, the following 3 arguments are needed:
--weights
: path to the trained model weights. Can either point to a single.pth
file or a folder containing multiple.pth
files. If this path points to a folder with multiple.pth
files, the script will individually load and run inference for all of the weights.- ``--data
: path to the data that will be used as input to run inference on. The script **recursively** loads all data that end with extensions specified in the
--exts` flag. --object
: name of the class to run detections on. This name must be defined underdimensions
in the config file passed to--config
.
Below is an example of running inference:
python inference.py --weights ../weights --data ../sample_data --object cracker
Depending on the images you want to run inference on, you may need to redefine the configuration values in camera_info.yaml
and config_pose.yaml
.
You can either define a new configuration file and specify it with --config
and --camera
or update camera_info.yaml
and config_pose.yaml
.
Before running inference, it is important to make sure that:
- The
projection_matrix
field is set properly incamera_info.yaml
(or the file you specified for--camera
). Theprojection_matrix
field should be a3x4
matrix of the form:
[fx, 0, cx, 0,
0, fy, cy, 0,
0, 0, 1, 0]
- The
dimensions
andclass_ids
fields have been specified for the object you wish to detect inconfig_pose.yaml
(or the file you specified for--config
).
The inference script can run inference on multiple weights if the path specified in --weights
points to a folder containing multiple .pth
files.
This feature is useful for fast evaluation of multiple weights to find the epoch that performs the best.
While, generally, later epochs tend to perform better than earlier ones, this is not always the case.
For more information on how to quantitatively evaluate the performance of a trained model, refer to the /evaluate
subdirectory.