Table of Contents
- Export training data
- Train the model
- Deploy model and detect mussel farms
Mussels are aquatic animals with bivalved hard shells that are consumed by millions of people around the world. Mussels grow in fresh water rivers or lakes near their openings to saline waters of the ocean, as well as in some coastal intertidal regions. Mussel aquaculture involves floating rafts that have ropes suspended in the water on which the mussels are cultured. The farmers collect mussel seeds from nearby rocky shores during low tides and attach them to the ropes in their rafts. Later, these ropes are covered with mesh socks that collect the mussels once they are ripe.
Spain is one of the biggest producer of mussels in the world. The Galicia region in Spain accounts for almost 90 percent of the mussel aquaculture in the country. Our study area for this notebook is Ria de Arousa, which is the biggest mussel farming area in Galicia region.
Monitoring of such aquacultures is an important aspect of maintaining the aquatic ecosystems. While sustainable farming can help the ecosystem, it's exploitation can degrade the environment quality and biodiversity. Therefore, it is important to monitor the growth of mussel farms in a region and their expansion into fragile areas. While physical surveys can be arduous and time consuming, satellite imagery and deep learning can help in monitoring mussel farming with much less effort. These analysis can also be helpful in comparing changes over longer periods of time.
In this notebook, we will train a deep learning model to detect mussel farms in high-resolution imagery of the Ria De Arousa region of Spain.
# Connect to GIS from arcgis.gis import GIS gis = GIS("home")
The following imagery layer contains high resolution imagery of a part of the Ria De Arousa region. The spatial resolution of the imagery is 30 cm, and it contains 3 bands: Red, Green, and Blue. It is used as the 'Input Raster' for exporting the training data.
training_raster = gis.content.get('f2b92eed10394e5eb3c7f135861937d9') training_raster
The following feature layer contains the bounding boxes for a few mussel farms in the Ria de Arousa region. It is used as the 'Input Feature Class' for exporting the training data.
training_feature_layer = gis.content.get('ff6a48b3391c4a24b807af0eb08bb6c1') training_feature_layer
Training data can be exported by using the 'Export Training Data For Deep Learning' tool available in ArcGIS Pro and ArcGIS Enterprise. For this example, we prepared the training data in the 'PASCAL Visual Object Classes' format, using a 'chip_size' of 448px and a 'cell_size' of 0.3m, in ArcGIS Pro. The 'Input Raster' and the 'Input Feature Class' have been made available to export the required training data. We have also provided the exported training data in the next section, if you wish to skip this step.
import os import glob import zipfile from pathlib import Path from arcgis.learn import prepare_data, MMDetection
We have already exported the data that can be directly used by following the steps below:
training_data = gis.content.get('57cb821dedca4c5598e81c8d2d510c91') training_data
filepath = training_data.download(file_name=training_data.name)
import zipfile with zipfile.ZipFile(filepath, 'r') as zip_ref: zip_ref.extractall(Path(filepath).parent)
data_path = Path(os.path.join(os.path.splitext(filepath)))
We will specify the path to our training data and a few hyperparameters.
path: path of the folder/list of folders containing training data.
batch_size: Number of images your model will train on each step inside an epoch. Depends on the memory of your graphic card.
chip_size: The same as the tile size used while exporting the dataset.
data = prepare_data(path, batch_size=4, chip_size=448)
Visualize training data¶
To get a sense of what the training data looks like, the
show_batch() method will randomly pick a few training chips and visualize them.