Skip to content
Implementation of the Mask R-CNN model using OCaml's numerical library Owl.
OCaml Other
  1. OCaml 98.9%
  2. Other 1.1%
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Mask R-CNN

This is an implementation of the Mask R-CNN network using OCaml's numerical library Owl. This network can be used to perform object detection, segmentation and classification. The implementation is based on this paper and ported from this Keras implementation.


  • OCaml >=4.06.0
  • CamlImages (opam install camlimages). Note that you need to install it after installing the following packages libpng12-dev libjpeg-dev libtiff-dev libxpm-dev libfreetype6-dev libgif-dev to make it support the image format you are interested in.
  • Owl's master branch (make sure it is up-to-date)
  • You need pre-trained weights to run the inference mode of the network. You can directly download the Owl weights here and place them at the root of the directory (they are converted from the Keras weights that can be found here).
  • You can then make and make run!


Image The code from the examples can be used to classify all the pictures in a given folder. It can be compiled with make and run with make run. A new image with highlighted objects will be generated to the results/ folder. You can modify the location of the source directory/file in examples/, as well as the size of the image: a larger size yields a more accurate detection but needs more time and memory (default is 768, but you can try 512, 1024, 1536, 2048,...).


If you are patient enough, you can try to convert a video frame-by-frame by running make video (you need FFmpeg to run it). You can modify the location of the source video in examples/ Note that this writes all the frames of the video on the hard drive.

You can’t perform that action at this time.