Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[POC] classif step 5: high-level classification management #696

Open
adebardo opened this issue Mar 3, 2025 · 0 comments
Open

[POC] classif step 5: high-level classification management #696

adebardo opened this issue Mar 3, 2025 · 0 comments
Labels
[POC] Conception To review Tickets needs approval about it conception

Comments

@adebardo
Copy link
Contributor

adebardo commented Mar 3, 2025

Context

The Classification class is a high-level interface that manages the process of applying different classification layers to a DEM. This class is responsible for parsing the configuration file, instantiating the appropriate classification layers, applying them, and saving the results. The provided configuration defines different layers, each with its own parameters (segmentation, slope, fusion).

Code

In a new file (classification_manager.py), implement the Classification class, which will provide the following functionality:

  1. __init__() method:
    • Initialize the class with a classification_config object, which could be a dict or a JSON file.

      Example of classification_config object:

      dem_path: "dem.tif"
      output_dir: "./output"
      classification_layers:
        segmentation:
          layer_name: "dem_segmentation"
          segmentation_mask_path: "./segmentation_mask.tif"
          segmentation_names:
            valid: [0]
            KO: [1]
            Land: [2]
            NoData: [3]
            Outside_detector: [4]
          stats: ["mean", "nmad"]
          stats_classes: ["Land", "valid"]
        slope:
          layer_name: "dem_slope"
          ranges: [0, 5, 10, 25, 45]
        fusion:
          name: "dem_fusion"
          layers_to_fuse: ["dem_segmentation", "dem_slope"]
          stats: "median"
          stats_classes: "valid_&_slope5_10"
      
    • Attributes:

      • dem: Initialize the DEM object (dem.tif in this example).
      • output_dir: Directory where the classification results will be saved (./output).
      • list_classifications: A list to store the instantiated classification layer objects.
  2. create_classification_layers() method:
    • Parse the classification_config dictionary and instantiate each classification layer based on its type.
    • A classification layer could be:
      • Segmentation Layer: Create a SegmentationClassificationLayer using the parameters (segmentation_mask_path, segmentation_names, etc.).
      • Slope Layer: Create a SlopeClassificationLayer using the specified slope ranges.
      • Fusion Layer: Create a FusionClassificationLayer by fusing the outputs of the specified layers.
    • Add each instantiated classification layer to list_classifications.
  3. apply_classifications() method:
    • Loop through each classification layer in list_classifications and call its apply_classification() method.
  4. save() method:
    • Implement the save() method to save the classification results for each layer.
    • Each classification layer will be responsible for saving its own results (classification mask, statistics, etc.).

Tests

  • Write unit tests for the Classification class
@adebardo adebardo added the [POC] Conception To review Tickets needs approval about it conception label Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[POC] Conception To review Tickets needs approval about it conception
Projects
None yet
Development

No branches or pull requests

1 participant