stac-extensions / classification

Describes categorical values and bitfields to give values in a file a certain meaning (classification).
Apache License 2.0
11 stars 3 forks source link

Proposal: Extend the Classification schema for integration with Machine Learning Model extension #48

Closed fmigneault closed 6 months ago

fmigneault commented 7 months ago

For the MLM (Machine Learning Model) extension, we are planing to reuse the definition of https://github.com/stac-extensions/classification?tab=readme-ov-file#class-object within Model Output definitions, since they are extremely related. For example, the following mlm:ouput can directly take advantage of classification:classes to indicate which class pixel values are expected to be produced by the model. Using this definition, creating a derived STAC Item product from the model prediction is simplified, since one only needs to copy the nested classification:classes directly into the derived STAC Item.

{
  "properties": {
    "mlm:output": [
      {
        "tasks": [ "segmentation", "semantic-segmentation" ],
        "result": {
          "shape": [ -1, 10980, 10980 ],
          "dim_names": [ "CLASSIFICATION" ],
          "data_type": "float32"
        },
        "post_processing_function": null,
        "classification:classes": [
          {
            "name": "WATER",
            "value": 1,
            "color_hint": [ 0, 0, 255 ],
            "nodata": false
          },
          {
            "name": "NON-WATER",
            "value": 0,
            "color_hint": [ 0, 0, 0 ],
            "nodata": false
          }
        ]
      }
    ]
  }
}

For the moment, the MLM JSON schema can point directly at the classification:classes definition to fulfil the validation, but the stac_extensions of the MLM STAC Item cannot really include the classification schema, since no field is technically respecting it at the moment. Would it be possible to do something similar to the strategy employed for raster:bands/classification:classes below?

https://github.com/stac-extensions/classification/blob/a1e713978b8cd9ac3c8b4778d140179d5e8c9022/json-schema/schema.json#L225-L236

https://github.com/stac-extensions/classification/blob/a1e713978b8cd9ac3c8b4778d140179d5e8c9022/examples/item-classes-maxar.json#L146-L148

m-mohr commented 7 months ago

Once MLM is released, feel free to create a PR.