Skip to content

Contribution Guidelines

Yuantao Feng edited this page Oct 31, 2022 · 4 revisions

We always welcome your contribution to improve user expereiences in the OpenCV Zoo.

Contributing new models

We are in favor of of models that are popular and in great demands, compact and efficient. A pull request contributing new models should have the followings:

  • A model with pre-trained weights. Models of ONNX format are preferred and should be simplified using onnx-simplifier. The model should be named following the pattern <topic>_<model_name>_<submit_time>.<model_suffix>.
    • <topic> stands for research topic of the model. For example, mobilenetv1 is for image_classification.
    • <model_name> stands for the name of the model, such as mobilenetv1.
    • <submit_time> stands for the time the model is submitted, such as mobilenetv1 is submitted in April 2022, so 2022apr.
    • <model_suffix> can be .onnx for ONNX models, .weights for Darknet models, .pb for Tensorflow models, .caffemodel for Caffe models. We perfer ONNX models, which should be simplified using onnx-simplifier.
  • A compatible license for the model. MIT, Apache 2.0, BSD-3 are compatible with OpenCV Zoo.
  • A class named after the model, such as MobileNetV1 in mobilenetv1.py, with the implementation of pre-process self.preprocess(), inference self.infer() and post-process self.postprocess(). Pre-process and post-process should be called in the inference methods. Time-consuming pre-processes like resize should not be put in self.preprocess().
  • A demo on how to perform inference with the class with a single image and webcam stream (if applicable) as input.
  • A yaml config for benchmarking. You can find many of those in benchmark/config.
  • The quantized model. We use Intel's Neural Compressor and ONNXRUNTIME to perform post-training static quantization. Go to https://github.com/opencv/opencv_zoo/tree/master/tools/quantize for more details.
  • (optional) Evaluation scripts if applicable. Visit https://github.com/opencv/opencv_zoo/tree/master/tools/eval for more details.

After we review your pull request, we will benchmark your model on our hardware and results will be updated to the table in README.md.

Before merge

Contributor should squash commits into one before merge. Following is an example of squashing commits:

# suppose you have 8 commits in total in your pull request
cd $your_opencv_zoo
git rebase -i HEAD~8
# an instruction window will pop up. Leave the first commit as pick, and set others to squash. Save and exit.
# another window for commit message will pop up. You could leave as-is or reword a proper commit message. Save and exit.
git push -f
Clone this wiki locally