Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
update examples working against JSON schema (except check for cross-b…
Browse files Browse the repository at this point in the history
…ands [AnyBandsRef])
  • Loading branch information
fmigneault committed Apr 5, 2024
1 parent 03e7e06 commit 2d6c70b
Show file tree
Hide file tree
Showing 9 changed files with 428 additions and 78 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The fields in the table below can be used in these parts of STAC documents:
| mlm:name | string | **REQUIRED** A unique name for the model. This can include, but must be distinct, from simply naming the model architecture. If there is a publication or other published work related to the model, use the official name of the model. |
| mlm:architecture | [Model Architecture](#model-architecture) string | **REQUIRED** A generic and well established architecture name of the model. |
| mlm:tasks | \[[Task Enum](#task-enum)] | **REQUIRED** Specifies the Machine Learning tasks for which the model can be used for. If multi-tasks outputs are provided by distinct model heads, specify all available tasks under the main properties and specify respective tasks in each [Model Output Object](#model-output-object). |
| mlm:framework | string | **REQUIRED** Framework used to train the model (ex: PyTorch, TensorFlow). |
| mlm:framework | string | Framework used to train the model (ex: PyTorch, TensorFlow). |
| mlm:framework_version | string | The `framework` library version. Some models require a specific version of the machine learning `framework` to run. |
| mlm:memory_size | integer | The in-memory size of the model on the accelerator during inference (bytes). |
| mlm:total_parameters | integer | Total number of model parameters, including trainable and non-trainable parameters. |
Expand Down
116 changes: 116 additions & 0 deletions examples/item_basic.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"stac_version": "1.0.0",
"stac_extensions": [
"https://stac-extensions.github.io/mlm/v1.0.0/schema.json"
],
"type": "Feature",
"id": "example-model",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-7.882190080512502,
37.13739173208318
],
[
-7.882190080512502,
58.21798141355221
],
[
27.911651652899925,
58.21798141355221
],
[
27.911651652899925,
37.13739173208318
],
[
-7.882190080512502,
37.13739173208318
]
]
]
},
"bbox": [
-7.882190080512502,
37.13739173208318,
27.911651652899923,
58.21798141355221
],
"properties": {
"datetime": null,
"start_datetime": "1900-01-01T00:00:00Z",
"end_datetime": "9999-12-31T23:59:59Z",
"mlm:name": "example-model",
"mlm:tasks": [
"classification"
],
"mlm:architecture": "ResNet",
"mlm:input": [
{
"name": "Model with RGB input that does not refer to any band.",
"bands": [],
"input": {
"shape": [
-1,
3,
64,
64
],
"dim_order": [
"batch",
"channel",
"height",
"width"
],
"data_type": "float32"
}
}
],
"mlm:output": [
{
"name": "classification",
"tasks": [
"classification"
],
"result": {
"shape": [
-1,
1
],
"dim_order": [
"batch",
"class"
],
"data_type": "uint8"
},
"classification_classes": [
{
"value": 0,
"name": "BACKGROUND",
"description": "Background non-city.",
"color_hint": [0, 0, 0]
},
{
"value": 1,
"name": "CITY",
"description": "A city is detected.",
"color_hint": [0, 0, 255]
}
]
}
]
},
"assets": {
"model": {
"href": "https://huggingface.co/example/model-card",
"title": "Pytorch weights checkpoint",
"description": "Example model.",
"type": "text/html",
"roles": [
"mlm:model"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"mlm:tasks": [
"classification"
],
"mlm:architecture": "ResNet",
"mlm:framework": "pytorch",
"mlm:framework_version": "2.1.2+cu121",
"file:size": 43000000,
Expand All @@ -60,7 +61,7 @@
"mlm:accelerator": "cuda",
"mlm:accelerator_constrained": false,
"mlm:accelerator_summary": "Unknown",
"mlm:batch_size_suggestion": null,
"mlm:batch_size_suggestion": 256,
"mlm:input": [
{
"name": "13 Band Sentinel-2 Batch",
Expand Down
242 changes: 242 additions & 0 deletions examples/item_multi_io.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
{
"stac_version": "1.0.0",
"stac_extensions": [
"https://stac-extensions.github.io/mlm/v1.0.0/schema.json",
"https://stac-extensions.github.io/raster/v1.1.0/schema.json",
"https://stac-extensions.github.io/file/v1.0.0/schema.json",
"https://stac-extensions.github.io/ml-aoi/v0.2.0/schema.json"
],
"type": "Feature",
"id": "resnet-18_sentinel-2_all_moco_classification",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-7.882190080512502,
37.13739173208318
],
[
-7.882190080512502,
58.21798141355221
],
[
27.911651652899925,
58.21798141355221
],
[
27.911651652899925,
37.13739173208318
],
[
-7.882190080512502,
37.13739173208318
]
]
]
},
"bbox": [
-7.882190080512502,
37.13739173208318,
27.911651652899923,
58.21798141355221
],
"properties": {
"description": "Sourced from torchgeo python library, identifier is ResNet18_Weights.SENTINEL2_ALL_MOCO",
"datetime": null,
"start_datetime": "1900-01-01T00:00:00Z",
"end_datetime": "9999-12-31T23:59:59Z",
"mlm:name": "Resnet-18 Sentinel-2 ALL MOCO",
"mlm:tasks": [
"classification"
],
"mlm:architecture": "ResNet",
"mlm:framework": "pytorch",
"mlm:framework_version": "2.1.2+cu121",
"file:size": 43000000,
"mlm:memory_size": 1,
"mlm:total_parameters": 11700000,
"mlm:pretrained_source": "EuroSat Sentinel-2",
"mlm:accelerator": "cuda",
"mlm:accelerator_constrained": false,
"mlm:accelerator_summary": "Unknown",
"mlm:batch_size_suggestion": 256,
"mlm:input": [
{
"name": "RGB",
"bands": [
"B04",
"B03",
"B02"
],
"input": {
"shape": [
-1,
3,
64,
64
],
"dim_order": [
"batch",
"channel",
"height",
"width"
],
"data_type": "uint16"
},
"norm_by_channel": false,
"norm_type": null,
"resize_type": null
},
{
"name": "NDVI",
"bands": [
"B04",
"B08"
],
"pre_processing_function": {
"format": "gdal-calc",
"expression": "(A - B) / (A + B)"
},
"input": {
"shape": [
-1,
1,
64,
64
],
"dim_order": [
"batch",
"ndvi",
"height",
"width"
],
"data_type": "uint16"
}
}
],
"mlm:output": [
{
"name": "vegetation-segmentation",
"tasks": [
"semantic-segmentation"
],
"result": {
"shape": [
-1,
1
],
"dim_order": [
"batch",
"class"
],
"data_type": "uint8"
},
"classification_classes": [
{
"value": 0,
"name": "NON_VEGETATION",
"description": "background pixels",
"color_hint": null
},
{
"value": 1,
"name": "VEGETATION",
"description": "pixels where vegetation was detected",
"color_hint": [0, 255, 0]
}
],
"post_processing_function": null
},
{
"name": "inverse-mask",
"tasks": [
"semantic-segmentation"
],
"result": {
"shape": [
-1,
1
],
"dim_order": [
"batch",
"class"
],
"data_type": "uint8"
},
"classification_classes": [
{
"value": 0,
"name": "NON_VEGETATION",
"description": "background pixels",
"color_hint": [255, 255, 255]
},
{
"value": 1,
"name": "VEGETATION",
"description": "pixels where vegetation was detected",
"color_hint": [0, 0, 0]
}
],
"post_processing_function": {
"format": "gdal-calc",
"expression": "logical_not(A)"
}
}
],
"raster:bands": [
{
"name": "B02 - blue",
"nodata": 0,
"data_type": "uint16",
"bits_per_sample": 15,
"spatial_resolution": 10,
"scale": 0.0001,
"offset": 0,
"unit": "m"
},
{
"name": "B03 - green",
"nodata": 0,
"data_type": "uint16",
"bits_per_sample": 15,
"spatial_resolution": 10,
"scale": 0.0001,
"offset": 0,
"unit": "m"
},
{
"name": "B04 - red",
"nodata": 0,
"data_type": "uint16",
"bits_per_sample": 15,
"spatial_resolution": 10,
"scale": 0.0001,
"offset": 0,
"unit": "m"
},
{
"name": "B08 - nir",
"nodata": 0,
"data_type": "uint16",
"bits_per_sample": 15,
"spatial_resolution": 10,
"scale": 0.0001,
"offset": 0,
"unit": "m"
}
]
},
"assets": {
"weights": {
"href": "https://huggingface.co/torchgeo/resnet50_sentinel2_rgb_moco/blob/main/resnet50_sentinel2_rgb_moco.pth",
"title": "Pytorch weights checkpoint",
"description": "A Resnet-50 classification model trained on Sentinel-2 RGB imagery with torchgeo.",
"type": "application/octet-stream; application=pytorch",
"roles": [
"mlm:model",
"mlm:weights"
]
}
}
}
Loading

0 comments on commit 2d6c70b

Please sign in to comment.