﻿{"id":16040,"date":"2025-12-01T10:00:00","date_gmt":"2025-12-01T09:00:00","guid":{"rendered":"https:\/\/www.sigterritoires.fr\/?p=16040"},"modified":"2025-11-28T21:45:47","modified_gmt":"2025-11-28T20:45:47","slug":"when-deep-learning-dives-beneath-the-surface-mapping-corals-with-qgis-and-pytorch","status":"publish","type":"post","link":"https:\/\/www.sigterritoires.fr\/index.php\/en\/when-deep-learning-dives-beneath-the-surface-mapping-corals-with-qgis-and-pytorch\/","title":{"rendered":"When Deep Learning Dives Beneath the Surface: Mapping Corals with QGIS and PyTorch"},"content":{"rendered":"\n<p>Deep learning is revolutionizing satellite image analysis.<\/p>\n\n\n\n<p>Long reserved for large laboratories or proprietary software, it is now becoming available to the wider world thanks to PyTorch and QGIS.<\/p>\n\n\n\n<p>This article explores the principles of Deep Learning applied to geomatics, compares ESRI models with those that can be used in QGIS, and concludes with a concrete example: the automatic detection of coral reefs using Sentinel-2 images.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contenu <\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/when-deep-learning-dives-beneath-the-surface-mapping-corals-with-qgis-and-pytorch\/#Introduction_to_Deep_Learning_applied_to_geomatics\" >Introduction to Deep Learning applied to geomatics<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/when-deep-learning-dives-beneath-the-surface-mapping-corals-with-qgis-and-pytorch\/#Why_%E2%80%9Cdeep%E2%80%9D\" >Why \u201cdeep\u201d?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/when-deep-learning-dives-beneath-the-surface-mapping-corals-with-qgis-and-pytorch\/#Deep_learning_and_remote_sensing\" >Deep learning and remote sensing<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/when-deep-learning-dives-beneath-the-surface-mapping-corals-with-qgis-and-pytorch\/#ESRIs_DLPK_format\" >ESRI&rsquo;s DLPK format<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/when-deep-learning-dives-beneath-the-surface-mapping-corals-with-qgis-and-pytorch\/#The_open_source_counterpart_PyTorch_and_QGIS\" >The open source counterpart: PyTorch and QGIS<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/when-deep-learning-dives-beneath-the-surface-mapping-corals-with-qgis-and-pytorch\/#Summary\" >Summary<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/when-deep-learning-dives-beneath-the-surface-mapping-corals-with-qgis-and-pytorch\/#Practical_example_coral_segmentation_using_Sentinel-2_images_in_QGIS\" >Practical example: coral segmentation using Sentinel-2 images in QGIS<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/when-deep-learning-dives-beneath-the-surface-mapping-corals-with-qgis-and-pytorch\/#Data_used\" >Data used<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/when-deep-learning-dives-beneath-the-surface-mapping-corals-with-qgis-and-pytorch\/#Processing_in_QGIS\" >Processing in QGIS<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/when-deep-learning-dives-beneath-the-surface-mapping-corals-with-qgis-and-pytorch\/#Procedure\" >Procedure<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/when-deep-learning-dives-beneath-the-surface-mapping-corals-with-qgis-and-pytorch\/#Preliminary_operations\" >Preliminary operations<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/when-deep-learning-dives-beneath-the-surface-mapping-corals-with-qgis-and-pytorch\/#Setting_up_the_processing_script\" >Setting up the processing script<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/when-deep-learning-dives-beneath-the-surface-mapping-corals-with-qgis-and-pytorch\/#Usage\" >Usage<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/when-deep-learning-dives-beneath-the-surface-mapping-corals-with-qgis-and-pytorch\/#Interpreting_the_results\" >Interpreting the results<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/when-deep-learning-dives-beneath-the-surface-mapping-corals-with-qgis-and-pytorch\/#Towards_an_ecosystem_of_open_models\" >Towards an ecosystem of open models<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/when-deep-learning-dives-beneath-the-surface-mapping-corals-with-qgis-and-pytorch\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Introduction_to_Deep_Learning_applied_to_geomatics\"><\/span>Introduction to Deep Learning applied to geomatics<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Deep Learning is a branch of artificial intelligence inspired by the functioning of the human brain. It is based on artificial neural networks capable of learning from examples, without being explicitly told all the rules.<\/p>\n\n\n\n<p>Unlike traditional classification methods, where the indicators and thresholds are chosen by the user, Deep Learning automatically discovers relevant structures and patterns in the data.<\/p>\n\n\n\n<p>In the field of geomatics, this approach opens up impressive possibilities:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>recognition of urban, agricultural, or forest areas from satellite images,<\/li>\n\n\n\n<li>detection of changes or natural disasters,<\/li>\n\n\n\n<li>identification of specific elements (roads, roofs, corals, ships, etc.),<\/li>\n\n\n\n<li>detailed segmentation of landscapes from Sentinel, PlanetScope, or drone images.<\/li>\n<\/ul>\n\n\n\n<p>The principle is simple: a model is trained on a large set of annotated images until it learns to reproduce the desired task (for example, distinguishing between water, vegetation, and sand). Once trained, the model can be applied to new areas to automatically generate high-resolution thematic maps.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_%E2%80%9Cdeep%E2%80%9D\"><\/span>Why \u201cdeep\u201d?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The term \u201cdeep\u201d comes from the fact that these networks have many successive layers\u2014sometimes dozens.<\/p>\n\n\n\n<p>Each layer learns to recognize increasingly complex patterns:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>the first layers detect edges and textures,<\/li>\n\n\n\n<li>the next identify shapes or structures,<\/li>\n\n\n\n<li>and the last understand entire objects or contexts.<\/li>\n<\/ul>\n\n\n\n<p>It is this hierarchy of representations that gives deep learning its power, but also its appetite for data and computing power.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Deep_learning_and_remote_sensing\"><\/span>Deep learning and remote sensing<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>In remote sensing, the most commonly used models are image segmentation models, which are capable of assigning a class to each pixel.<\/p>\n\n\n\n<p>Architectures such as U-Net, DeepLab, and Mask R-CNN have become benchmarks for automatic mapping based on multispectral imagery.<\/p>\n\n\n\n<p>These models are generally trained with frameworks such as PyTorch or TensorFlow, then deployed in GIS environments.<\/p>\n\n\n\n<p>Both major worlds have taken an interest in this:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>ESRI<\/strong>, with its .dlpk (Deep Learning Package) model format integrated into ArcGIS Pro and ArcGIS Online;<\/li>\n\n\n\n<li><strong>QGIS<\/strong>, which allows PyTorch or TensorFlow models to be used via the Processing Toolbox or custom Python scripts.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"ESRIs_DLPK_format\"><\/span>ESRI&rsquo;s DLPK format<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>ESRI was one of the first GIS players to integrate deep learning directly into its ArcGIS ecosystem.<\/p>\n\n\n\n<p>To facilitate the exchange and deployment of models, the company created a standard format: DLPK (Deep Learning Package).<\/p>\n\n\n\n<p>A .dlpk file is not just a model: it is a complete and portable package containing all the elements necessary for its execution.<\/p>\n\n\n\n<p>It generally contains:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The trained model (often in PyTorch .pth or TensorFlow .h5 format)<\/li>\n\n\n\n<li>A JSON definition file describing the model architecture, expected parameters, and class names<\/li>\n\n\n\n<li>Metadata: input type (raster, tile, image), patch size, number of bands, normalization, etc.<\/li>\n\n\n\n<li>Training samples (optional) to document or retrain the model.<\/li>\n<\/ul>\n\n\n\n<p>Thanks to this organization, ArcGIS Pro or ArcGIS Online can automatically interpret the model without the need to write code.<\/p>\n\n\n\n<p>Tools such as \u201cClassify Pixels Using Deep Learning\u201d or \u201cDetect Objects Using Deep Learning\u201d directly read the .dlpk, load the model, and perform inference on a raster or image set.<\/p>\n\n\n\n<p>This turnkey approach has two major advantages:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Interoperability: a model trained elsewhere can be used by any ArcGIS user, without complex dependencies.<\/li>\n\n\n\n<li>Replicability: metadata ensures that the model is applied under the same conditions as when it was trained.<\/li>\n<\/ol>\n\n\n\n<p>The downside, of course, is the closed format: .dlpk remains tied to the ArcGIS ecosystem and is not always easy to use elsewhere.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"The_open_source_counterpart_PyTorch_and_QGIS\"><\/span>The open source counterpart: PyTorch and QGIS<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>On the open source side, QGIS does not impose a proprietary format.<\/p>\n\n\n\n<p>Models are simply saved in their native format (often .pth for PyTorch or .pt) and executed via Python scripts integrated into the Processing Toolbox.<\/p>\n\n\n\n<p>The idea is the same as with ESRI:<\/p>\n\n\n\n<p>a multispectral image is loaded, a trained model is applied, and a class or probability map is generated.<\/p>\n\n\n\n<p>But instead of relying on a packaged format such as .dlpk, QGIS gives developers complete freedom:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The model is read with torch.load().<\/li>\n\n\n\n<li>The input bands can be selected dynamically (for example, B4-B3-B2 for RGB, or B8-B4-B3 in false color).<\/li>\n\n\n\n<li>The Python script controls the entire processing flow: normalization, water masking (NDWI), block cutting, merging of results, etc.<\/li>\n<\/ul>\n\n\n\n<p>This approach allows for maximum flexibility, which is particularly useful for research or experimentation.<br>For example, a U-Net model trained in PyTorch can be applied directly in QGIS via a custom script\u2014without relying on ArcGIS Pro.<\/p>\n\n\n\n<p>QGIS then becomes a true AI spatial analysis laboratory, where users can:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>test several models (.pth) from the community,<\/li>\n\n\n\n<li>adapt pre-processing according to the area (coastal strip, forest, urban, etc.),<\/li>\n\n\n\n<li>automate an entire workflow using Processing algorithms,<\/li>\n\n\n\n<li>and combine the results with other GIS layers (vegetation, bathymetry, land cover, etc.).<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Summary\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Aspect<\/th><th>ESRI (DLPK)<\/th><th>QGIS (PyTorch)<\/th><\/tr><\/thead><tbody><tr><td><strong>Format<\/strong><\/td><td><code>.dlpk<\/code> (complete package)<\/td><td><code>.pth<\/code> or <code>.pt<\/code> (model only)<\/td><\/tr><tr><td><strong>Interoperability<\/strong><\/td><td>Simple, but proprietary<\/td><td>Free and modifiable<\/td><\/tr><tr><td><strong>Use<\/strong><\/td><td>Integrated ArcGIS tools (\u201cClassify Pixels,\u201d \u201cDetect Objects\u201d)<\/td><td>Custom Python Processing scripts<\/td><\/tr><tr><td><strong>Customization<\/strong><\/td><td>Limited<\/td><td>Total<\/td><\/tr><tr><td><strong>Learning curve<\/strong><\/td><td>Simpler for the end user<\/td><td>More flexible for the developer or researcher<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Practical_example_coral_segmentation_using_Sentinel-2_images_in_QGIS\"><\/span>Practical example: coral segmentation using Sentinel-2 images in QGIS<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Now that we have explored the logic behind deep models and the formats used by ESRI and QGIS, let&rsquo;s move on to a concrete example: analyzing coral reefs using Sentinel-2 satellite images.<br>The goal is to distinguish marine areas (sandy bottoms, seagrass beds, corals) from terrestrial or turbid areas using a pre-trained U-Net model in PyTorch.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Data_used\"><\/span>Data used<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The input image comes from Sentinel-2, a mission of the European Copernicus program.<br>These free multispectral images offer a resolution of 10 to 20 m and cover several bands in the visible and infrared:<\/p>\n\n\n\n<p>BandNameWavelength (nm)Main useB2Blue490Water, turbidityB3Green560Vegetation, marine environmentB4Red665Soil, vegetation, coralsB8NIR842Land\/water differentiationB11SWIR11610Humidity, sand, clouds<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Band<\/th><th>Name<\/th><th>Wavelength (nm)<\/th><th>Main use<\/th><\/tr><\/thead><tbody><tr><td>B2<\/td><td>Blue<\/td><td>490<\/td><td>Water, turbidity<\/td><\/tr><tr><td>B3<\/td><td>Green<\/td><td>560<\/td><td>Vegetation, marine environment<\/td><\/tr><tr><td>B4<\/td><td>Red<\/td><td>665<\/td><td>Soil, vegetation, corals<\/td><\/tr><tr><td>B8<\/td><td>NIR<\/td><td>842<\/td><td>Land\/water differentiation<\/td><\/tr><tr><td>B11<\/td><td>SWIR1<\/td><td>1610<\/td><td>Humidity, sand, clouds<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>The raster is derived from S2DR3 processing &#8211; Sentinel-2 super-resolution at 1 m, which improves the resolution of all Sentinel 2 image bands to approximately 1 m (see \u201cUsing S2DR3 in Google Colab to study corals in Mauritius\u201d). The image used is the one that served as an example in the article cited.<br>The user simply loads the multispectral .tif file, for example:<br>Palmar_MS.tif.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Processing_in_QGIS\"><\/span>Processing in QGIS<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The analysis is performed using a Python algorithm integrated into the Processing toolbox.<\/p>\n\n\n\n<p>This script loads a PyTorch model (unet_coraux.pth) and applies segmentation to the image in several steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Reading the raster and normalizing the bands<br>The values are scaled to a level compatible with the model training.<\/li>\n\n\n\n<li>Optional masking of land areas<br>A Normalized Difference Water Index (NDWI) is calculated to isolate the sea.<br>Pixels with high NDWI values are considered marine and processed by the model; the others are masked.<\/li>\n\n\n\n<li>Cutting into blocks (patches)<br>The image is processed in portions to avoid memory overload.<br>Each block is analyzed independently, then the results are merged.<\/li>\n\n\n\n<li>Application of the U-Net model<\/li>\n\n\n\n<li>The model performs pixel-by-pixel segmentation: it assigns each pixel a probability of belonging to the \u201ccoral\u201d or \u201cnon-coral\u201d class.<br>The result is an output raster containing probability or class values.<\/li>\n\n\n\n<li>Saving the output raster<br>The result is saved in GeoTIFF format (palmar_model_9.tif), ready to be overlaid with other GIS layers.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Procedure\"><\/span>Procedure<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Preliminary_operations\"><\/span>Preliminary operations<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>We will create a QGis processing script. As a prerequisite, you must install<\/p>\n\n\n\n<div class='stb-container stb-style-black stb-caption-box'><div class='stb-caption'><div class='stb-logo'><img class='stb-logo__image' src='data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob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e8ygit6ApIERW9j5kShYbUebIEYpSpgKoS0BtUGqjGAa05N5RMHPlPOP\/0v2jTyF\/WgR6EQpX7m85X3aV\/ekRXZh\/MsvzipVNHWYuIY5xxaCWXZqx+b2BKCweURVmKgjsR9qL4BosF1BAvFxGPfkPbKdeXcU\/uVTn9dZ4gKlGoH774quHs2rq9fneWdtxeFeU21Fsfbt2yg3S2YWchRcYwyhjS2NBqWjq+QNCxxwyN6diZ65vu3LPbt\/np7Zemg8WpZ2WQtIfErPtXtlezHrOHL2vCt9uzkSL0irxqsb7pkpdU5o56Y9VhbGxoweudIcJFeWGqtzEy6vH20ODl\/f27qDymTzKqklWFiCL\/8wa566U81L4G8BPL\/A+R\/BgAzCInEE2+\/LgAAAABJRU5ErkJggg==' alt='img'\/><\/div><div class='stb-caption-content'>OsGeo4W shell<\/div><div class='stb-tool'><\/div><\/div><div class='stb-content'><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python -m pip install torchgeo\npython -m pip install torch torchvision\npython -m pip install segmentation-models-pytorch\n<\/code><\/pre>\n\n\n\n<p><\/div><\/div>\n\n\n\n<p>Then we need to download the desired model. To do this, enter the following script in the QGIS Python console:<\/p>\n\n\n\n<div class='stb-container stb-style-black stb-caption-box'><div class='stb-caption'><div class='stb-logo'><img class='stb-logo__image' src='data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN\/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz\/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH\/w\/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTA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IfErPtXtlezHrOHL2vCt9uzkSL0irxqsb7pkpdU5o56Y9VhbGxoweudIcJFeWGqtzEy6vH20ODl\/f27qDymTzKqklWFiCL\/8wa566U81L4G8BPL\/A+R\/BgAzCInEE2+\/LgAAAABJRU5ErkJggg==' alt='img'\/><\/div><div class='stb-caption-content'>Python Console<\/div><div class='stb-tool'><\/div><\/div><div class='stb-content'><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import segmentation_models_pytorch as smp\nimport torch\n\n# U-Net RGB pr\u00e9-entra\u00een\u00e9\nmodel = smp.Unet(\n    encoder_name=\"resnet34\",\n    encoder_weights=\"imagenet\",\n    in_channels=3,\n    classes=1  # corail\/non-corail\n)\n\n# Sauvegarde pour QGIS\ntorch.save(model, \"<strong><em>c:\/models\/unet_coraux.pth<\/em><\/strong>\")\n<\/code><\/pre>\n\n\n\n<p><\/div><\/div>\n\n\n\n<p>In this example, we save the downloaded models in a directory c:\/models<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Setting_up_the_processing_script\"><\/span>Setting up the processing script<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>In QGIS \u2192 Processing Toolbox \u2192 Scripts \u2192 New Script,<\/p>\n\n\n\n<div class='stb-container stb-style-black stb-caption-box'><div class='stb-caption'><div class='stb-logo'><img class='stb-logo__image' src='data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN\/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz\/SMBAP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eU21Fsfbt2yg3S2YWchRcYwyhjS2NBqWjq+QNCxxwyN6diZ65vu3LPbt\/np7Zemg8WpZ2WQtIfErPtXtlezHrOHL2vCt9uzkSL0irxqsb7pkpdU5o56Y9VhbGxoweudIcJFeWGqtzEy6vH20ODl\/f27qDymTzKqklWFiCL\/8wa566U81L4G8BPL\/A+R\/BgAzCInEE2+\/LgAAAABJRU5ErkJggg==' alt='img'\/><\/div><div class='stb-caption-content'>traitement<\/div><div class='stb-tool'><\/div><\/div><div class='stb-content'><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># -*- coding: utf-8 -*-\n\"\"\"\nAlgorithme QGIS : Segmentation Coraux (U-Net) avec option masquage terrestre\nCompatible QGIS 3.44+\n\"\"\"\nfrom qgis.core import (\n    QgsProcessing,\n    QgsProcessingAlgorithm,\n    QgsProcessingParameterRasterLayer,\n    QgsProcessingParameterFile,\n    QgsProcessingParameterEnum,\n    QgsProcessingParameterRasterDestination,\n    QgsProcessingParameterBoolean,\n)\nfrom qgis.PyQt.QtCore import QCoreApplication\nimport torch\nimport torch.serialization\nimport numpy as np\nfrom osgeo import gdal\nfrom scipy.signal import windows\n\n\nclass SegmentationCoraux(QgsProcessingAlgorithm):\n    \"\"\"Segmentation des images Sentinel-2 \u00e0 1m avec un mod\u00e8le U-Net\"\"\"\n\n    BAND_OPTIONS = &#091;\"RGB (4-3-2)\", \"Fausse couleur (8-4-3)\"]\n\n    def initAlgorithm(self, config=None):\n        self.addParameter(\n            QgsProcessingParameterRasterLayer(\n                \"raster_input\",\n                self.tr(\"Image Sentinel-2 (GeoTIFF multibandes)\")\n            )\n        )\n\n        self.addParameter(\n            QgsProcessingParameterEnum(\n                \"band_set\",\n                self.tr(\"S\u00e9lection manuelle des bandes\"),\n                options=self.BAND_OPTIONS,\n                defaultValue=0\n            )\n        )\n\n        self.addParameter(\n            QgsProcessingParameterFile(\n                \"model_path\",\n                self.tr(\"Mod\u00e8le PyTorch (.pth)\"),\n                extension=\"pth\"\n            )\n        )\n\n        self.addParameter(\n            QgsProcessingParameterRasterDestination(\n                \"output_raster\",\n                self.tr(\"Raster de sortie (masque)\")\n            )\n        )\n\n        # --- Nouvelle option : masquage terrestre ---\n        self.addParameter(\n            QgsProcessingParameterBoolean(\n                \"mask_land\",\n                self.tr(\"Masquer les zones terrestres (NDWI)\"),\n                defaultValue=True\n            )\n        )\n\n    def processAlgorithm(self, parameters, context, feedback):\n        model_path = self.parameterAsFile(parameters, \"model_path\", context)\n        mask_land = self.parameterAsBool(parameters, \"mask_land\", context)\n        band_set = self.parameterAsEnum(parameters, \"band_set\", context)\n\n        feedback.pushInfo(\"Chargement du mod\u00e8le PyTorch...\")\n        try:\n            from segmentation_models_pytorch.decoders.unet.model import Unet\n            torch.serialization.add_safe_globals(&#091;Unet])\n        except Exception as e:\n            feedback.pushInfo(f\"Avertissement : impossible d\u2019ajouter Unet aux classes s\u00fbres : {e}\")\n\n        model = torch.load(model_path, map_location=torch.device('cpu'), weights_only=False)\n        model.eval()\n\n        raster_input = self.parameterAsRasterLayer(parameters, \"raster_input\", context)\n        ds = gdal.Open(raster_input.source())\n        feedback.pushInfo(f\"Ouverture du raster : {raster_input.source()}\")\n        nrows, ncols = ds.RasterYSize, ds.RasterXSize\n\n        # --- D\u00e9tecter automatiquement les canaux d'entr\u00e9e ---\n        conv1_weights = model.encoder.conv1.weight.data\n        n_channels = conv1_weights.shape&#091;1]\n        feedback.pushInfo(f\"Le mod\u00e8le attend {n_channels} canaux d'entr\u00e9e.\")\n\n        if n_channels == 3:\n            # Analyser l\u2019importance des canaux\n            channel_mean = conv1_weights.abs().mean(dim=(0, 2, 3)).numpy()\n            sorted_idx = list(np.argsort(-channel_mean))\n            feedback.pushInfo(f\"Classement des canaux par importance : {sorted_idx}\")\n\n            band_selection = &#091;4, 3, 2]  # RGB classique\n            feedback.pushInfo(f\"Utilisation automatique des bandes : {band_selection} (RGB)\")\n        else:\n            band_selection = &#091;4, 3, 2] if band_set == 0 else &#091;8, 4, 3]\n            feedback.pushInfo(f\"Utilisation manuelle des bandes : {band_selection}\")\n\n        # --- Lecture des bandes s\u00e9lectionn\u00e9es ---\n        img_list = &#091;]\n        for b in band_selection:\n            band = ds.GetRasterBand(b)\n            arr = band.ReadAsArray().astype(np.float32)\n            img_list.append(arr)\n        img = np.stack(img_list, axis=0)\n\n        # Normalisation\n        feedback.pushInfo(\"Normalisation des valeurs...\")\n        img = (img - img.min()) \/ (img.max() - img.min() + 1e-6)\n\n        # --- Calcul NDWI si option activ\u00e9e ---\n        if mask_land and ds.RasterCount &gt;= 8:\n            try:\n                B3 = ds.GetRasterBand(3).ReadAsArray().astype(np.float32)\n                B8 = ds.GetRasterBand(8).ReadAsArray().astype(np.float32)\n                ndwi = (B3 - B8) \/ (B3 + B8 + 1e-6)\n                water_mask = ndwi &gt; 0\n                feedback.pushInfo(\"NDWI calcul\u00e9 : les zones terrestres seront exclues.\")\n            except Exception as e:\n                water_mask = np.ones((nrows, ncols), dtype=bool)\n                feedback.pushInfo(f\"NDWI non calculable ({e}), toutes les zones seront trait\u00e9es.\")\n        else:\n            water_mask = np.ones((nrows, ncols), dtype=bool)\n            feedback.pushInfo(\"Masquage terrestre d\u00e9sactiv\u00e9.\")\n\n        # --- Traitement par blocs ---\n        block_size = 2048\n        overlap = 512\n        output_mask = np.zeros((nrows, ncols), dtype=np.float32)\n        weight = np.zeros((nrows, ncols), dtype=np.float32)\n\n        total_blocks = ((nrows \/\/ (block_size - overlap) + 1) *\n                        (ncols \/\/ (block_size - overlap) + 1))\n        done = 0\n        feedback.pushInfo(\"D\u00e9but du traitement par blocs...\")\n\n        for y in range(0, nrows, block_size - overlap):\n            for x in range(0, ncols, block_size - overlap):\n                if feedback.isCanceled():\n                    break\n\n                block = img&#091;:, y:y+block_size, x:x+block_size]\n                if block.size == 0:\n                    continue\n\n                mask_block_water = water_mask&#091;y:y+block_size, x:x+block_size]\n                if not mask_block_water.any():\n                    continue\n\n                # ======= BLOC ORIGINAL PR\u00c9SERV\u00c9 =======\n                with torch.no_grad():\n                    block_tensor = torch.from_numpy(block).unsqueeze(0)\n                    pred = model(block_tensor)\n                    mask_block = pred.squeeze().numpy()\n\n                h, w = mask_block.shape\n                mask_block *= mask_block_water&#091;:h, :w]\n\n                # Fen\u00eatre Hanning\n                win_y = windows.hann(h)&#091;:, None]\n                win_x = windows.hann(w)&#091;None, :]\n                weight_block = win_y * win_x\n\n                output_mask&#091;y:y+h, x:x+w] += mask_block * weight_block\n                weight&#091;y:y+h, x:x+w] += weight_block\n\n                done += 1\n                progress = int(100 * done \/ total_blocks)\n                feedback.setProgress(progress)\n                # ======= FIN DU BLOC ORIGINAL =======\n\n        # Fusion finale\n        output_mask \/= np.maximum(weight, 1e-6)\n        output_mask = np.clip(output_mask, 0, 1)\n\n        # --- Sauvegarde GeoTIFF ---\n        feedback.pushInfo(\"Sauvegarde du masque final...\")\n        driver = gdal.GetDriverByName(\"GTiff\")\n        out_path = self.parameterAsOutputLayer(parameters, \"output_raster\", context)\n        out_ds = driver.Create(out_path, ncols, nrows, 1, gdal.GDT_Float32)\n        out_ds.SetGeoTransform(ds.GetGeoTransform())\n        out_ds.SetProjection(ds.GetProjection())\n        out_ds.GetRasterBand(1).WriteArray(output_mask)\n        out_ds.FlushCache()\n\n        feedback.pushInfo(\"\u2705 Segmentation termin\u00e9e avec succ\u00e8s.\")\n        return {\"output_raster\": out_path}\n\n    # --- M\u00e9tadonn\u00e9es ---\n    def name(self):\n        return \"segmentation_coraux\"\n\n    def displayName(self):\n        return self.tr(\"Segmentation des images Sentinel 2 \u00e0 1m (U-Net)\")\n\n    def group(self):\n        return self.tr(\"Deep Learning\")\n\n    def groupId(self):\n        return \"deeplearning\"\n\n    def tr(self, string):\n        return QCoreApplication.translate(\"SegmentationCoraux\", string)\n\n    def createInstance(self):\n        return SegmentationCoraux()\n\n<\/code><\/pre>\n\n\n\n<p><\/div><\/div>\n\n\n\n<p>You will find explanations of the different parts of the code in a future article.<\/p>\n\n\n\n<p>The QGIS script presented here allows you to apply U\u2011Net-based image segmentation models saved in PyTorch (.pth) format. It is designed to process multispectral images, such as those from Sentinel\u20112 satellites, and automatically adapts the bands used according to the number of input channels expected by the model. For example, if the model is trained on RGB images, the script will select the Red, Green, and Blue bands; if the model expects more channels, it will offer a manual selection or use all available bands. The code also includes the ability to mask terrestrial areas using NDWI calculations, allowing segmentation to focus on water areas, for example to identify corals. In practice, any properly saved U-Net PyTorch model can be loaded and applied, provided that the architecture and weights are included in the .pth file.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Usage\"><\/span>Usage<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Run the script. The following window will open:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearning.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"506\" data-attachment-id=\"15920\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/quand-le-deep-learning-plonge-sous-la-surface-cartographier-les-coraux-avec-qgis-et-pytorch\/deeplearning\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearning.jpg?fit=1749%2C1383&amp;ssl=1\" data-orig-size=\"1749,1383\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"deeplearning\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearning.jpg?fit=640%2C506&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearning.jpg?resize=640%2C506&#038;ssl=1\" alt=\"\" class=\"wp-image-15920\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearning.jpg?resize=1024%2C810&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearning.jpg?resize=300%2C237&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearning.jpg?resize=768%2C607&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearning.jpg?resize=1536%2C1215&amp;ssl=1 1536w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearning.jpg?w=1749&amp;ssl=1 1749w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearning.jpg?w=1280&amp;ssl=1 1280w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/figure>\n\n\n\n<p>Manual band selection is only used if the script is unable to determine which bands to use based on the template.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Interpreting_the_results\"><\/span>Interpreting the results<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The raster generated from the model represents a probability map:<br>values close to 1 indicate a high presence of corals, while values close to 0 correspond to non-coral areas (sand, algae, depth, etc.).<\/p>\n\n\n\n<p>Appropriate symbology (from light blue to red) makes it easy to visualize the spatial distribution of probable coral areas.<br>By combining this map with other data (bathymetry, substrate, turbidity), it becomes possible to estimate the vulnerability or degradation of reefs over time.<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearningoutput.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"439\" data-attachment-id=\"15921\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/quand-le-deep-learning-plonge-sous-la-surface-cartographier-les-coraux-avec-qgis-et-pytorch\/deeplearningoutput\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearningoutput.jpg?fit=2257%2C1549&amp;ssl=1\" data-orig-size=\"2257,1549\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}\" data-image-title=\"deeplearningoutput\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearningoutput.jpg?fit=640%2C439&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearningoutput.jpg?resize=640%2C439&#038;ssl=1\" alt=\"\" class=\"wp-image-15921\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearningoutput.jpg?resize=1024%2C703&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearningoutput.jpg?resize=300%2C206&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearningoutput.jpg?resize=768%2C527&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearningoutput.jpg?resize=1536%2C1054&amp;ssl=1 1536w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearningoutput.jpg?resize=2048%2C1406&amp;ssl=1 2048w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearningoutput.jpg?w=1280&amp;ssl=1 1280w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearningoutput.jpg?w=1920&amp;ssl=1 1920w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Advantages of this approach<\/p>\n\n\n\n<p>The integration of PyTorch into QGIS opens up new possibilities for AI-assisted environmental mapping:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open source and reproducible: the entire process can be shared, modified, or adapted to other coastal areas.<\/li>\n\n\n\n<li>Local autonomy: no need for ArcGIS Pro or expensive licenses to test or apply deep learning models.<\/li>\n\n\n\n<li>Flexible experimentation: other architectures (SegNet, DeepLabV3, etc.) can be tested, or preprocessing can be adapted to the specific characteristics of each area.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Towards_an_ecosystem_of_open_models\"><\/span>Towards an ecosystem of open models<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Ultimately, we could imagine a shared library of open source environmental models\u2014the free equivalent of the DLPK format\u2014where each .pth file would be accompanied by its description file (bands, normalization, classes).<\/p>\n\n\n\n<p>QGIS could then offer an interface for importing, testing, and documenting these models, facilitating their reuse in tropical, coastal, or forest contexts.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The rise of deep learning marks a new stage in the evolution of geomatics.<\/p>\n\n\n\n<p>While traditional image processing relied on thresholds and spectral indices, neural models now learn to recognize complex shapes, textures, and signatures directly in pixels.<\/p>\n\n\n\n<p>Thanks to tools such as ArcGIS Pro (with its DLPK) and QGIS (via PyTorch and custom scripts), this power is now accessible to everyone: researchers, technicians, and environmental mapping enthusiasts.<\/p>\n\n\n\n<p>The example presented here\u2014the segmentation of corals from Sentinel-2 images\u2014illustrates the potential of these approaches for detailed analysis of coastal environments and the preservation of marine ecosystems.<\/p>\n\n\n\n<p>The challenge is no longer just technical, but also collective: pooling models, documenting their inputs, sharing methods, and making deep learning more transparent, reproducible, and open.<\/p>\n\n\n\n<p>The future of remote sensing will likely be built at the crossroads of these two worlds\u2014software engineering and field knowledge\u2014to transform satellite data into true indicators of ecological status.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n","protected":false},"excerpt":{"rendered":"<p>Deep learning is revolutionizing satellite image analysis. Long reserved for large laboratories or proprietary software, it is now becoming available to the wider world thanks to PyTorch and QGIS. This article explores the principles of Deep&hellip;<\/p>\n","protected":false},"author":1,"featured_media":15925,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"give_campaign_id":0,"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sfsi_plus_gutenberg_text_before_share":"","sfsi_plus_gutenberg_show_text_before_share":"","sfsi_plus_gutenberg_icon_type":"","sfsi_plus_gutenberg_icon_alignemt":"","sfsi_plus_gutenburg_max_per_row":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3857],"tags":[3873,3875,3877],"class_list":["post-16040","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-iaen","tag-deep-learning","tag-ia-en","tag-pytorch-en"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2025\/11\/deeplearningavant.jpeg?fit=272%2C198&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p6XU0A-4aI","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts\/16040","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/comments?post=16040"}],"version-history":[{"count":0,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts\/16040\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/media\/15925"}],"wp:attachment":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/media?parent=16040"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/categories?post=16040"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/tags?post=16040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}