GRASS logo


i.ann.maskrcnn.detect - Detect features in images using a Mask R-CNN model


ann, vector, raster


i.ann.maskrcnn.detect --help
i.ann.maskrcnn.detect [-e] [band1=string] [band2=string] [band3=string] [images_directory=name] [images_format=string] model=string classes=string[,string,...] [output_type=string] [--help] [--verbose] [--quiet] [--ui]


External georeferencing in the images folder (when using images_directory)
Print usage summary
Verbose module output
Quiet module output
Force launching GUI dialog


Name of raster maps to use for detection as the first band (divided by ",")
Name of raster maps to use for detection as the second band (divided by ",")
Name of raster maps to use for detection as the third band (divided by ",")
Path to a directory with external images to detect
Name of input directory
Format suffix of images
.jpg, .tiff, .png, etc.
model=string [required]
Path to the .h5 file containing the model
classes=string[,string,...] [required]
Names of classes separated with ","
Type of output
Options: area, point
Default: area

Table of contents


i.ann.maskrcnn.detect allows the user to use a Mask R-CNN model to detect features in GRASS GIS raster maps or georeferenced files and extract them either as areas or points. The module creates a separate map for each class.


The detection may be used for raster maps imported in GRASS GIS or for external files (or using both). To use raster maps in GRASS GIS, you need to pass them in three bands following the order used during the training, e.g. if the training has been made on RGB images, use band1=*.red, band1=*.green and band3=*.blue. To pass multiple images, put more maps into band* parameters, divided by ",".

The detection may be used also for multiple external files. However, all files for the detection must be in one directory specified in the images_directory parameter. Even when using only one image, the module finds it through this parameter.

When detecting, you can use new names of classes. Classes in the model are not referenced by their name, but by their order. It means that if the model was trained with classes corn,rice and you use i.ann.maskrcnn.detect with classes zea,oryza, zea areas will present areas detected as corn and oryza areas will present areas detected as rice.

If the external file is georeferenced externally (by a worldfile or an .aux.xml file), please use -e flag.


Detect buildings and lakes and import them as areas

One map imported in GRASS GIS:

i.ann.maskrcnn.detect classes=buildings,lakes model=/home/user/Documents/logs/mask_rcnn_buildings_lakes_0100.h5

Two maps (map1, map2) imported in GRASS GIS:

i.ann.maskrcnn.detect,,, classes=buildings,lakes model=/home/user/Documents/logs/mask_rcnn_buildings_lakes_0100.h5

External files, the georeferencing is internal (GeoTIFF):

i.ann.maskrcnn.detect images_directory=/home/user/Documents/georeferenced_images classes=buildings,lakes model=/home/user/Documents/logs/mask_rcnn_buildings_lakes_0100.h5 images_format=tif

External files, the georeferencing is external:

i.ann.maskrcnn.detect images_directory=/home/user/Documents/georeferenced_images classes=buildings,lakes model=/home/user/Documents/logs/mask_rcnn_buildings_lakes_0100.h5 images_format=png -e

Detect cottages and plattenbaus and import them as points

i.ann.maskrcnn.detect classes=buildings,lakes model=/home/user/Documents/logs/mask_rcnn_buildings_lakes_0100.h5 output_type=point


Mask R-CNN in GRASS GIS, i.ann.maskrcnn.train


Ondrej Pesek


Available at: i.ann.maskrcnn.detect source code (history)

Main index | Imagery index | Topics index | Keywords index | Graphical index | Full index

© 2003-2020 GRASS Development Team, GRASS GIS 7.8.3dev Reference Manual