From 7d95cca4e8e854771ac2597076d388ad1b0ecc3e Mon Sep 17 00:00:00 2001 From: Francis Charette-Migneault Date: Thu, 18 Apr 2024 13:42:41 -0400 Subject: [PATCH] fix STAC MLM examples - remove old (invalid) DLM examples --- examples/collection.json | 49 +++-- examples/dlm-legacy/item.json | 256 ----------------------- examples/dlm-legacy/item.yml | 357 -------------------------------- examples/item_basic.json | 20 +- examples/item_eo_bands.json | 37 ++-- examples/item_multi_io.json | 25 ++- examples/item_raster_bands.json | 37 ++-- examples/model-arch-summary.txt | 155 -------------- package.json | 4 +- stac_model/examples.py | 34 ++- 10 files changed, 142 insertions(+), 832 deletions(-) delete mode 100644 examples/dlm-legacy/item.json delete mode 100644 examples/dlm-legacy/item.yml delete mode 100644 examples/model-arch-summary.txt diff --git a/examples/collection.json b/examples/collection.json index c710628..7a71b3f 100644 --- a/examples/collection.json +++ b/examples/collection.json @@ -4,46 +4,43 @@ "https://stac-extensions.github.io/item-assets/v1.0.0/schema.json" ], "type": "Collection", - "id": "EO-DL-model-catalog", - "title": "A title", - "description": "Collection that refers to a STAC Item with DLM Extension", + "id": "ml-model-examples", + "title": "Machine Learning Model examples", + "description": "Collection of items contained in the Machine Learning Model examples.", "license": "Apache-2.0", "extent": { "spatial": { "bbox": [ [ - 172.9, - 1.3, - 173, - 1.4 + -7.882190080512502, + 37.13739173208318, + 27.911651652899923, + 58.21798141355221 ] ] }, "temporal": { "interval": [ [ - "2015-06-23T00:00:00Z", - null + "1900-01-01T00:00:00Z", + "9999-12-31T23:59:59Z" ] ] } }, - "assets": { - "example": { - "href": "item.json" - } - }, "item_assets": { - "data": { + "weights": { + "title": "model weights", "roles": [ - "data" - ], + "mlm:model", + "mlm:weights" + ] } }, "summaries": { "datetime": { - "minimum": "2015-06-23T00:00:00Z", - "maximum": "2019-07-10T13:44:56Z" + "minimum": "1900-01-01T00:00:00Z", + "maximum": "9999-12-31T23:59:59Z" } }, "links": [ @@ -52,7 +49,19 @@ "rel": "self" }, { - "href": "item.json", + "href": "item_basic.json", + "rel": "item" + }, + { + "href": "item_eo_bands.json", + "rel": "item" + }, + { + "href": "item_raster_bands.json", + "rel": "item" + }, + { + "href": "item_multi_io.json", "rel": "item" } ] diff --git a/examples/dlm-legacy/item.json b/examples/dlm-legacy/item.json deleted file mode 100644 index 850a604..0000000 --- a/examples/dlm-legacy/item.json +++ /dev/null @@ -1,256 +0,0 @@ -{ - "stac_version": "1.0.0", - "stac_extensions": [ - "https://schemas.stacspec.org/v1.0.0-beta.3/extensions/dl-model/json-schema/schema.json", - "https://stac-extensions.github.io/eo/v1.1.0/schema.json", - "https://stac-extensions.github.io/processing/v1.1.0/schema.json", - "https://stac-extensions.github.io/scientific/v1.0.0/schema.json" - ], - "id": "dlm-resnet18-unet-scse", - "type": "Feature", - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - 180, - 90 - ], - [ - -180, - -90 - ], - [ - -180, - 90 - ], - [ - 180, - 90 - ], - [ - 180, - -90 - ] - ] - ] - }, - "bbox": [ - -180, - -90, - 180, - 90 - ], - "collection": "EO-DL-model-catalog", - "links": [ - { - "rel": "self", - "href": "https://landsat-stac.s3.amazonaws.com/some-eo-models/example-thelper-item.json" - }, - { - "rel": "collection", - "href": "https://landsat-stac.s3.amazonaws.com/some-eo-models/catalog.json" - } - ], - "assets": [ - { - "model_archive": { - "href": "https://drive.google.com/file/d/1PYyZVgH95454sb9LYHSfchbg8GuT__fR/view?usp=sharing", - "type": "application/zip", - "title": "model archive", - "description": "model archive as a google drive link", - "role": [ - "model artefact" - ] - } - } - ], - "properties": { - "datetime": "2016-05-03T13:22:30Z", - "title": "resnet18+unet_scse", - "description": "UNet architecture with a resnet18 backbone and a SCSE layer fine-tuned on Pleiade imagery", - "license": "MIT", - "created": "2020-12-12T00:00:01.000Z", - "updated": "2021-01-04T00:30:55.000Z", - "providers": [ - { - "name": "Effigis Inc.", - "roles": [ - "image licensor" - ], - "url": "https://effigis.com/en/" - }, - { - "name": "Airbus Inc.", - "roles": [ - "image provider" - ], - "url": "https://www.intelligence-airbusds.com/" - } - ], - "platform": "Pleiade", - "gsd": 0.5, - "eo:bands": [ - { - "name": "50-cm panchromatic", - "common_name": "pancro", - "center_wavelength": 400 - }, - { - "name": "blue", - "common_name": "blue", - "center_wavelength": 490 - }, - { - "name": "green", - "common_name": "green", - "center_wavelength": 500 - }, - { - "name": "red", - "common_name": "red", - "center_wavelength": 660 - }, - { - "name": "Near Infrared", - "common_name": "nir", - "center_wavelength": 850 - } - ], - "sci:publications": [ - { - "citation": "Abhijit Guha Roy and Nassir Navab and Christian Wachinger (2018). Concurrent Spatial and Channel Squeeze & Excitation in Fully Convolutional Networks, arXiv 1803.02579", - "doi": "10.1007/978-3-030-00928-1_48" - } - ], - "processing:level": "L4", - "dlm:runtime": { - "framework": "PyTorch", - "version": 1.5, - "model_handler": "thelper.cli.inference_session", - "model_src_url": "https://github.com/crim-ca/gin-model-repo", - "model_commit_hash": null, - "requirement_file": null, - "docker": { - "docker_file": "https://github.com/crim-ca/CCCOT03/blob/main/docker/thelper-geo.dockerfile", - "image_name": "thelper-geo:latest", - "tag": null, - "gpu": true, - "working_dir": "/workspace", - "run": "thelper infer --config /workspace/config.yml --save-dir /workspace --ckpt-path /workspace/ckpt.best.pth" - } - }, - "dlm:archive": [ - { - "name": "config.yml", - "role": [ - "config file" - ] - }, - { - "name": "./test_pleiade/256/input_test.tif", - "role": [ - "test set" - ] - }, - { - "name": "ckpt.best.pth", - "role": [ - "model weight" - ] - } - ], - "dlm:data": { - "process_level": "ortho", - "dtype": "uint16", - "number_of_bands": 4, - "useful_bands": [ - { - "index": 2, - "name": "red" - }, - { - "index": 1, - "name": "green" - }, - { - "index": 3, - "name": "nir" - } - ], - "nodata_value": 0, - "test_file": "input_test.tif", - "item_examples": [ - { - "title": "a pleiade stac item", - "url": "https://example.com/stac/pleiade/item.json" - } - ] - }, - "dlm:inputs": { - "name": "data", - "input_tensors": { - "batch": 1, - "channels": 3, - "height": 224, - "width": 224 - }, - "scaling_factor": 0.003921569, - "normalization:mean": [ - 0.245, - 0.34, - 0.67 - ], - "normalization:std": [ - 0.1, - 0.1, - 0.2 - ], - "selected_bands": [ - 0, - 1, - 3 - ], - "pre_processing_function": null - }, - "dlm:outputs": { - "task": "semantic segmentation", - "number_of_classes": 5, - "dont_care_index": 0, - "final_layer_size": [ - 1, - 5, - 64, - 64 - ], - "class_name_mapping": [ - { - "0": "dontcare" - }, - { - "1": "Bare Exposed Rock" - }, - { - "2": "High density Residential" - }, - { - "3": "Cropland" - }, - { - "4": "Mixed Forest Land" - }, - { - "5": "Lake" - } - ], - "post_processing_function": null - }, - "dlm:architecture": { - "total_nb_parameters": 42813873, - "estimated_total_size_mb": 183.72, - "type": "unet-resnet-18-scse", - "pretrained": "imagenet", - "summary": "----------------------------------------------------------------\n Layer (type) Output Shape Param\n================================================================\n Conv2d-1 [-1, 64, 32, 32] 9,408\n BatchNorm2d-2 [-1, 64, 32, 32] 128\n ReLU-3 [-1, 64, 32, 32] 0\n MaxPool2d-4 [-1, 64, 16, 16] 0\n Conv2d-5 [-1, 64, 16, 16] 36,864\n BatchNorm2d-6 [-1, 64, 16, 16] 128\n ReLU-7 [-1, 64, 16, 16] 0\n Conv2d-8 [-1, 64, 16, 16] 36,864\n BatchNorm2d-9 [-1, 64, 16, 16] 128\n ReLU-10 [-1, 64, 16, 16] 0\n BasicBlock-11 [-1, 64, 16, 16] 0\n Conv2d-12 [-1, 64, 16, 16] 36,864\n BatchNorm2d-13 [-1, 64, 16, 16] 128\n ReLU-14 [-1, 64, 16, 16] 0\n Conv2d-15 [-1, 64, 16, 16] 36,864\n BatchNorm2d-16 [-1, 64, 16, 16] 128\n ReLU-17 [-1, 64, 16, 16] 0\n BasicBlock-18 [-1, 64, 16, 16] 0\n Conv2d-19 [-1, 128, 8, 8] 73,728\n BatchNorm2d-20 [-1, 128, 8, 8] 256\n ReLU-21 [-1, 128, 8, 8] 0\n Conv2d-22 [-1, 128, 8, 8] 147,456\n BatchNorm2d-23 [-1, 128, 8, 8] 256\n Conv2d-24 [-1, 128, 8, 8] 8,192\n BatchNorm2d-25 [-1, 128, 8, 8] 256\n ReLU-26 [-1, 128, 8, 8] 0\n BasicBlock-27 [-1, 128, 8, 8] 0\n Conv2d-28 [-1, 128, 8, 8] 147,456\n BatchNorm2d-29 [-1, 128, 8, 8] 256\n ReLU-30 [-1, 128, 8, 8] 0\n Conv2d-31 [-1, 128, 8, 8] 147,456\n BatchNorm2d-32 [-1, 128, 8, 8] 256\n ReLU-33 [-1, 128, 8, 8] 0\n BasicBlock-34 [-1, 128, 8, 8] 0\n Conv2d-35 [-1, 256, 4, 4] 294,912\n BatchNorm2d-36 [-1, 256, 4, 4] 512\n ReLU-37 [-1, 256, 4, 4] 0\n Conv2d-38 [-1, 256, 4, 4] 589,824\n BatchNorm2d-39 [-1, 256, 4, 4] 512\n Conv2d-40 [-1, 256, 4, 4] 32,768\n BatchNorm2d-41 [-1, 256, 4, 4] 512\n ReLU-42 [-1, 256, 4, 4] 0\n BasicBlock-43 [-1, 256, 4, 4] 0\n Conv2d-44 [-1, 256, 4, 4] 589,824\n BatchNorm2d-45 [-1, 256, 4, 4] 512\n ReLU-46 [-1, 256, 4, 4] 0\n Conv2d-47 [-1, 256, 4, 4] 589,824\n BatchNorm2d-48 [-1, 256, 4, 4] 512\n ReLU-49 [-1, 256, 4, 4] 0\n BasicBlock-50 [-1, 256, 4, 4] 0\n Conv2d-51 [-1, 512, 2, 2] 1,179,648\n BatchNorm2d-52 [-1, 512, 2, 2] 1,024\n ReLU-53 [-1, 512, 2, 2] 0\n Conv2d-54 [-1, 512, 2, 2] 2,359,296\n BatchNorm2d-55 [-1, 512, 2, 2] 1,024\n Conv2d-56 [-1, 512, 2, 2] 131,072\n BatchNorm2d-57 [-1, 512, 2, 2] 1,024\n ReLU-58 [-1, 512, 2, 2] 0\n BasicBlock-59 [-1, 512, 2, 2] 0\n Conv2d-60 [-1, 512, 2, 2] 2,359,296\n BatchNorm2d-61 [-1, 512, 2, 2] 1,024\n ReLU-62 [-1, 512, 2, 2] 0\n Conv2d-63 [-1, 512, 2, 2] 2,359,296\n BatchNorm2d-64 [-1, 512, 2, 2] 1,024\n ReLU-65 [-1, 512, 2, 2] 0\n BasicBlock-66 [-1, 512, 2, 2] 0\n MaxPool2d-67 [-1, 512, 1, 1] 0\n Conv2d-68 [-1, 1024, 1, 1] 4,719,616\n BatchNorm2d-69 [-1, 1024, 1, 1] 2,048\n ReLU-70 [-1, 1024, 1, 1] 0\n_ActivatedBatchNorm-71 [-1, 1024, 1, 1] 0 AdaptiveAvgPool2d-72 [-1, 1024, 1, 1] 0\n Linear-73 [-1, 64] 65,600\n ReLU-74 [-1, 64] 0\n Linear-75 [-1, 1024] 66,560\n Conv2d-76 [-1, 1, 1, 1] 1,024\n SCSEBlock-77 [-1, 1024, 1, 1] 0\n ConvTranspose2d-78 [-1, 512, 2, 2] 8,389,120\n DecoderUnetSCSE-79 [-1, 512, 2, 2] 0\n Conv2d-80 [-1, 1024, 2, 2] 9,438,208\n BatchNorm2d-81 [-1, 1024, 2, 2] 2,048\n ReLU-82 [-1, 1024, 2, 2] 0\n_ActivatedBatchNorm-83 [-1, 1024, 2, 2] 0 AdaptiveAvgPool2d-84 [-1, 1024, 1, 1] 0\n Linear-85 [-1, 64] 65,600\n ReLU-86 [-1, 64] 0\n Linear-87 [-1, 1024] 66,560\n Conv2d-88 [-1, 1, 2, 2] 1,024\n SCSEBlock-89 [-1, 1024, 2, 2] 0\n ConvTranspose2d-90 [-1, 256, 4, 4] 4,194,560\n DecoderUnetSCSE-91 [-1, 256, 4, 4] 0\n Conv2d-92 [-1, 512, 4, 4] 2,359,808\n BatchNorm2d-93 [-1, 512, 4, 4] 1,024\n ReLU-94 [-1, 512, 4, 4] 0\n_ActivatedBatchNorm-95 [-1, 512, 4, 4] 0 AdaptiveAvgPool2d-96 [-1, 512, 1, 1] 0\n Linear-97 [-1, 32] 16,416\n ReLU-98 [-1, 32] 0\n Linear-99 [-1, 512] 16,896\n Conv2d-100 [-1, 1, 4, 4] 512\n SCSEBlock-101 [-1, 512, 4, 4] 0\nConvTranspose2d-102 [-1, 128, 8, 8] 1,048,704 DecoderUnetSCSE-103 [-1, 128, 8, 8] 0\n Conv2d-104 [-1, 256, 8, 8] 590,080\n BatchNorm2d-105 [-1, 256, 8, 8] 512\n ReLU-106 [-1, 256, 8, 8] 0\n_ActivatedBatchNorm-107 [-1, 256, 8, 8] 0 AdaptiveAvgPool2d-108 [-1, 256, 1, 1] 0\n Linear-109 [-1, 16] 4,112\n ReLU-110 [-1, 16] 0\n Linear-111 [-1, 256] 4,352\n Conv2d-112 [-1, 1, 8, 8] 256\n SCSEBlock-113 [-1, 256, 8, 8] 0\nConvTranspose2d-114 [-1, 64, 16, 16] 262,208 DecoderUnetSCSE-115 [-1, 64, 16, 16] 0\n Conv2d-116 [-1, 128, 16, 16] 147,584\n BatchNorm2d-117 [-1, 128, 16, 16] 256\n ReLU-118 [-1, 128, 16, 16] 0\n_ActivatedBatchNorm-119 [-1, 128, 16, 16] 0 AdaptiveAvgPool2d-120 [-1, 128, 1, 1] 0\n Linear-121 [-1, 8] 1,032\n ReLU-122 [-1, 8] 0\n Linear-123 [-1, 128] 1,152\n Conv2d-124 [-1, 1, 16, 16] 128\n SCSEBlock-125 [-1, 128, 16, 16] 0\nConvTranspose2d-126 [-1, 32, 32, 32] 65,568 DecoderUnetSCSE-127 [-1, 32, 32, 32] 0\n Conv2d-128 [-1, 64, 32, 32] 55,360\n BatchNorm2d-129 [-1, 64, 32, 32] 128\n ReLU-130 [-1, 64, 32, 32] 0\n_ActivatedBatchNorm-131 [-1, 64, 32, 32] 0 AdaptiveAvgPool2d-132 [-1, 64, 1, 1] 0\n Linear-133 [-1, 4] 260\n ReLU-134 [-1, 4] 0\n Linear-135 [-1, 64] 320\n Conv2d-136 [-1, 1, 32, 32] 64\n SCSEBlock-137 [-1, 64, 32, 32] 0\nConvTranspose2d-138 [-1, 16, 64, 64] 16,400 DecoderUnetSCSE-139 [-1, 16, 64, 64] 0\n Conv2d-140 [-1, 64, 64, 64] 31,808\n BatchNorm2d-141 [-1, 64, 64, 64] 128\n ReLU-142 [-1, 64, 64, 64] 0\n_ActivatedBatchNorm-143 [-1, 64, 64, 64] 0\n Conv2d-144 [-1, 5, 64, 64] 325\nEncoderDecoderNet-145 [-1, 5, 64, 64] 0 ================================================================ Total params= 42,813,873 Trainable params= 42,813,873 Non-trainable params= 0 ---------------------------------------------------------------- Input size (MB)= 0.05 Forward/backward pass size (MB)= 20.35 Params size (MB)= 163.32 Estimated Total Size (MB)= 183.72 ----------------------------------------------------------------" - } - } -} diff --git a/examples/dlm-legacy/item.yml b/examples/dlm-legacy/item.yml deleted file mode 100644 index 812c61e..0000000 --- a/examples/dlm-legacy/item.yml +++ /dev/null @@ -1,357 +0,0 @@ -stac_version: 1.0.0-beta.2 # schema version -stac_extensions: # stac extension required - - dl-model # deep-learning model extension - - eo # eo extension - - scientific # scientific extension required for citations - - provider # metadata about providers -id: 11234 # Some ID for this item -type: Feature # Required by STAC item -geometry: # Required by STAC item - type: Polygon - coordinates: - - - - 180.0 - - 90.0 - - - -180.0 - - -90 - - - -180.0 - - 90.0 - - - 180.0 - - 90.0 - - - 180.0 - - -90.0 -bbox: # Required by STAC item - - -180.0 - - -90.0 - - 180.0 - - 90 -collection: a eo model catalog # name of the model catalog -# -# Links and assets (part of the core specs) -# -links: - - rel: self - href: https://landsat-stac.s3.amazonaws.com/some-eo-models/example-thelper-item.json - - rel: collection - href: https://landsat-stac.s3.amazonaws.com/some-eo-models/catalog.json -assets: - - model_archive: - href: https://drive.google.com/file/d/1PYyZVgH95454sb9LYHSfchbg8GuT__fR/view?usp=sharing - type: application/zip - title: model archive - description: model archive as a google drive link - role: - - model artefact -properties: - # - # General properties defined in the item core schema - # - datetime: "2016-05-03T13:22:30Z" - title: resnet18+unet_scse # short name of the model - description: >- # short description - UNet architecture with a resnet18 backbone and a SCSE layer - fine-tuned on Pleiade imagery - license: MIT # license of utilisation - created: 2020-12-12T00:00:01Z - updated: 2021-01-04T00:30:55Z - providers: # optional provider information (data, etc.) - - name: Effigis Inc. - roles: - - image licensor - url: https://effigis.com/en/ - - name: Airbus Inc. - roles: - - image provider - url: https://www.intelligence-airbusds.com/ - # Section on instruments (core stac item) - platform: Pleiade - gsd: 0.50 - # eo extension fields (describe the sensor spectal bands) - eo:bands: - - name: 50-cm panchromatic - common_name: pancro - center_wavelength: 400 - - name: blue - common_name: blue - center_wavelength: 490 - - name: green - common_name: green - center_wavelength: 500 - - name: red - common_name: red - center_wavelength: 660 - - name: Near Infrared - common_name: nir - center_wavelength: 850 - # - # Scientific references - # Based on STAC scientific extension - # - sci:publications: # relevant publications - - citation: >- - Abhijit Guha Roy and Nassir Navab and Christian Wachinger (2018). - Concurrent Spatial and Channel Squeeze & Excitation in Fully Convolutional Networks, - arXiv 1803.02579 - # - # Runtime metadata - # Describes the runtime environment - # - dlm:runtime: - framework: PyTorch # deep learning framework used - version: 1.5 # framework version - model_handler: thelper.cli.inference_session - model_src_url: https://github.com/crim-ca/gin-model-repo - model_commit_hash: - requirement_file: - # - # Docker specifications (optional) - # - docker: - docker_file: https://github.com/crim-ca/CCCOT03/blob/main/docker/thelper-geo.dockerfile # link to the docker file - image_name: thelper-geo:latest # official image name for the inference - tag: - gpu: true # we specify if this image needs a gpu or not - working_dir: /workspace # docker instance working directory - run: thelper infer --config /workspace/config.yml --save-dir /workspace --ckpt-path /workspace/ckpt.best.pth - # - # Describe the content of the model archive - # - dlm:archive: - - name: config.yml - role: - - config file - - name: ./test_pleiade/256/input_test.tif - role: - - test set - - name: ckpt.best.pth - role: - - model weight - # - # EO data description (required) - # - dlm:data: - process_level: ortho # expected processing level - dtype: uint16 # data type (enum) - number_of_bands: 4 # number of bands in the test file - useful_bands: # describes the bands that should be loaded - - index: 2 - name: red - - index: 1 - name: green - - index: 3 - name: nir - nodata_value: 0 - test_file: input_test.tif # name of a test file in the model archive - item_examples: # points toward relevant eo items - - title: a pleiade stac item - url: https://example.com/stac/pleiade/item.json - # - # Model input description (required) - # - dlm:inputs: - name: data # expected variable name - input_tensors: - batch: 1 # batch size - channels: 3 # number of channels - height: 224 # tensor height - width: 224 # tensor width - scaling_factor: 0.003921569 # scaling factor (usually 1/255) - normalization:mean: # input statistical normalization (mean) - - 0.245 - - 0.34 - - 0.67 - normalization:std: # input statistical normalization (std) - - 0.1 - - 0.1 - - 0.2 - selected_bands: # selected bands (0 is the first band) - - 0 - - 1 - - 3 - pre_processing_function: - # - # Model output description (required) - # - dlm:outputs: - task: semantic segmentation # describe the ML task (enum) - number_of_classes: 5 # number of classes - dont_care_index: 0 # Index value used for the excluded segments (don't care data) - final_layer_size: # size of the output - - 1 - - 5 - - 64 - - 64 - class_name_mapping: # mapping to short class names - - 0: dontcare - - 1: Bare Exposed Rock - - 2: High density Residential - - 3: Cropland - - 4: Mixed Forest Land - - 5: Lake - post_processing_function: - # - # Describes the model architecture - # - dlm:architecture: # describe the model architecture - total_nb_parameters: 42813873 # total number of parameters - estimated_total_size_mb: 183.72 # Total memory size in MB - type: unet-resnet-18-scse # type of architecture - pretrained: imagenet - summary: >- - ---------------------------------------------------------------- - Layer (type) Output Shape Param - ================================================================ - Conv2d-1 [-1, 64, 32, 32] 9,408 - BatchNorm2d-2 [-1, 64, 32, 32] 128 - ReLU-3 [-1, 64, 32, 32] 0 - MaxPool2d-4 [-1, 64, 16, 16] 0 - Conv2d-5 [-1, 64, 16, 16] 36,864 - BatchNorm2d-6 [-1, 64, 16, 16] 128 - ReLU-7 [-1, 64, 16, 16] 0 - Conv2d-8 [-1, 64, 16, 16] 36,864 - BatchNorm2d-9 [-1, 64, 16, 16] 128 - ReLU-10 [-1, 64, 16, 16] 0 - BasicBlock-11 [-1, 64, 16, 16] 0 - Conv2d-12 [-1, 64, 16, 16] 36,864 - BatchNorm2d-13 [-1, 64, 16, 16] 128 - ReLU-14 [-1, 64, 16, 16] 0 - Conv2d-15 [-1, 64, 16, 16] 36,864 - BatchNorm2d-16 [-1, 64, 16, 16] 128 - ReLU-17 [-1, 64, 16, 16] 0 - BasicBlock-18 [-1, 64, 16, 16] 0 - Conv2d-19 [-1, 128, 8, 8] 73,728 - BatchNorm2d-20 [-1, 128, 8, 8] 256 - ReLU-21 [-1, 128, 8, 8] 0 - Conv2d-22 [-1, 128, 8, 8] 147,456 - BatchNorm2d-23 [-1, 128, 8, 8] 256 - Conv2d-24 [-1, 128, 8, 8] 8,192 - BatchNorm2d-25 [-1, 128, 8, 8] 256 - ReLU-26 [-1, 128, 8, 8] 0 - BasicBlock-27 [-1, 128, 8, 8] 0 - Conv2d-28 [-1, 128, 8, 8] 147,456 - BatchNorm2d-29 [-1, 128, 8, 8] 256 - ReLU-30 [-1, 128, 8, 8] 0 - Conv2d-31 [-1, 128, 8, 8] 147,456 - BatchNorm2d-32 [-1, 128, 8, 8] 256 - ReLU-33 [-1, 128, 8, 8] 0 - BasicBlock-34 [-1, 128, 8, 8] 0 - Conv2d-35 [-1, 256, 4, 4] 294,912 - BatchNorm2d-36 [-1, 256, 4, 4] 512 - ReLU-37 [-1, 256, 4, 4] 0 - Conv2d-38 [-1, 256, 4, 4] 589,824 - BatchNorm2d-39 [-1, 256, 4, 4] 512 - Conv2d-40 [-1, 256, 4, 4] 32,768 - BatchNorm2d-41 [-1, 256, 4, 4] 512 - ReLU-42 [-1, 256, 4, 4] 0 - BasicBlock-43 [-1, 256, 4, 4] 0 - Conv2d-44 [-1, 256, 4, 4] 589,824 - BatchNorm2d-45 [-1, 256, 4, 4] 512 - ReLU-46 [-1, 256, 4, 4] 0 - Conv2d-47 [-1, 256, 4, 4] 589,824 - BatchNorm2d-48 [-1, 256, 4, 4] 512 - ReLU-49 [-1, 256, 4, 4] 0 - BasicBlock-50 [-1, 256, 4, 4] 0 - Conv2d-51 [-1, 512, 2, 2] 1,179,648 - BatchNorm2d-52 [-1, 512, 2, 2] 1,024 - ReLU-53 [-1, 512, 2, 2] 0 - Conv2d-54 [-1, 512, 2, 2] 2,359,296 - BatchNorm2d-55 [-1, 512, 2, 2] 1,024 - Conv2d-56 [-1, 512, 2, 2] 131,072 - BatchNorm2d-57 [-1, 512, 2, 2] 1,024 - ReLU-58 [-1, 512, 2, 2] 0 - BasicBlock-59 [-1, 512, 2, 2] 0 - Conv2d-60 [-1, 512, 2, 2] 2,359,296 - BatchNorm2d-61 [-1, 512, 2, 2] 1,024 - ReLU-62 [-1, 512, 2, 2] 0 - Conv2d-63 [-1, 512, 2, 2] 2,359,296 - BatchNorm2d-64 [-1, 512, 2, 2] 1,024 - ReLU-65 [-1, 512, 2, 2] 0 - BasicBlock-66 [-1, 512, 2, 2] 0 - MaxPool2d-67 [-1, 512, 1, 1] 0 - Conv2d-68 [-1, 1024, 1, 1] 4,719,616 - BatchNorm2d-69 [-1, 1024, 1, 1] 2,048 - ReLU-70 [-1, 1024, 1, 1] 0 - _ActivatedBatchNorm-71 [-1, 1024, 1, 1] 0 - AdaptiveAvgPool2d-72 [-1, 1024, 1, 1] 0 - Linear-73 [-1, 64] 65,600 - ReLU-74 [-1, 64] 0 - Linear-75 [-1, 1024] 66,560 - Conv2d-76 [-1, 1, 1, 1] 1,024 - SCSEBlock-77 [-1, 1024, 1, 1] 0 - ConvTranspose2d-78 [-1, 512, 2, 2] 8,389,120 - DecoderUnetSCSE-79 [-1, 512, 2, 2] 0 - Conv2d-80 [-1, 1024, 2, 2] 9,438,208 - BatchNorm2d-81 [-1, 1024, 2, 2] 2,048 - ReLU-82 [-1, 1024, 2, 2] 0 - _ActivatedBatchNorm-83 [-1, 1024, 2, 2] 0 - AdaptiveAvgPool2d-84 [-1, 1024, 1, 1] 0 - Linear-85 [-1, 64] 65,600 - ReLU-86 [-1, 64] 0 - Linear-87 [-1, 1024] 66,560 - Conv2d-88 [-1, 1, 2, 2] 1,024 - SCSEBlock-89 [-1, 1024, 2, 2] 0 - ConvTranspose2d-90 [-1, 256, 4, 4] 4,194,560 - DecoderUnetSCSE-91 [-1, 256, 4, 4] 0 - Conv2d-92 [-1, 512, 4, 4] 2,359,808 - BatchNorm2d-93 [-1, 512, 4, 4] 1,024 - ReLU-94 [-1, 512, 4, 4] 0 - _ActivatedBatchNorm-95 [-1, 512, 4, 4] 0 - AdaptiveAvgPool2d-96 [-1, 512, 1, 1] 0 - Linear-97 [-1, 32] 16,416 - ReLU-98 [-1, 32] 0 - Linear-99 [-1, 512] 16,896 - Conv2d-100 [-1, 1, 4, 4] 512 - SCSEBlock-101 [-1, 512, 4, 4] 0 - ConvTranspose2d-102 [-1, 128, 8, 8] 1,048,704 - DecoderUnetSCSE-103 [-1, 128, 8, 8] 0 - Conv2d-104 [-1, 256, 8, 8] 590,080 - BatchNorm2d-105 [-1, 256, 8, 8] 512 - ReLU-106 [-1, 256, 8, 8] 0 - _ActivatedBatchNorm-107 [-1, 256, 8, 8] 0 - AdaptiveAvgPool2d-108 [-1, 256, 1, 1] 0 - Linear-109 [-1, 16] 4,112 - ReLU-110 [-1, 16] 0 - Linear-111 [-1, 256] 4,352 - Conv2d-112 [-1, 1, 8, 8] 256 - SCSEBlock-113 [-1, 256, 8, 8] 0 - ConvTranspose2d-114 [-1, 64, 16, 16] 262,208 - DecoderUnetSCSE-115 [-1, 64, 16, 16] 0 - Conv2d-116 [-1, 128, 16, 16] 147,584 - BatchNorm2d-117 [-1, 128, 16, 16] 256 - ReLU-118 [-1, 128, 16, 16] 0 - _ActivatedBatchNorm-119 [-1, 128, 16, 16] 0 - AdaptiveAvgPool2d-120 [-1, 128, 1, 1] 0 - Linear-121 [-1, 8] 1,032 - ReLU-122 [-1, 8] 0 - Linear-123 [-1, 128] 1,152 - Conv2d-124 [-1, 1, 16, 16] 128 - SCSEBlock-125 [-1, 128, 16, 16] 0 - ConvTranspose2d-126 [-1, 32, 32, 32] 65,568 - DecoderUnetSCSE-127 [-1, 32, 32, 32] 0 - Conv2d-128 [-1, 64, 32, 32] 55,360 - BatchNorm2d-129 [-1, 64, 32, 32] 128 - ReLU-130 [-1, 64, 32, 32] 0 - _ActivatedBatchNorm-131 [-1, 64, 32, 32] 0 - AdaptiveAvgPool2d-132 [-1, 64, 1, 1] 0 - Linear-133 [-1, 4] 260 - ReLU-134 [-1, 4] 0 - Linear-135 [-1, 64] 320 - Conv2d-136 [-1, 1, 32, 32] 64 - SCSEBlock-137 [-1, 64, 32, 32] 0 - ConvTranspose2d-138 [-1, 16, 64, 64] 16,400 - DecoderUnetSCSE-139 [-1, 16, 64, 64] 0 - Conv2d-140 [-1, 64, 64, 64] 31,808 - BatchNorm2d-141 [-1, 64, 64, 64] 128 - ReLU-142 [-1, 64, 64, 64] 0 - _ActivatedBatchNorm-143 [-1, 64, 64, 64] 0 - Conv2d-144 [-1, 5, 64, 64] 325 - EncoderDecoderNet-145 [-1, 5, 64, 64] 0 - ================================================================ - Total params= 42,813,873 - Trainable params= 42,813,873 - Non-trainable params= 0 - ---------------------------------------------------------------- - Input size (MB)= 0.05 - Forward/backward pass size (MB)= 20.35 - Params size (MB)= 163.32 - Estimated Total Size (MB)= 183.72 - ---------------------------------------------------------------- diff --git a/examples/item_basic.json b/examples/item_basic.json index a4333dd..c766f10 100644 --- a/examples/item_basic.json +++ b/examples/item_basic.json @@ -5,6 +5,7 @@ ], "type": "Feature", "id": "example-model", + "collection": "ml-model-examples", "geometry": { "type": "Polygon", "coordinates": [ @@ -18,11 +19,11 @@ 58.21798141355221 ], [ - 27.911651652899925, + 27.911651652899923, 58.21798141355221 ], [ - 27.911651652899925, + 27.911651652899923, 37.13739173208318 ], [ @@ -39,6 +40,7 @@ 58.21798141355221 ], "properties": { + "description": "Basic STAC Item with only the MLM extension and no other extension cross-references.", "datetime": null, "start_datetime": "1900-01-01T00:00:00Z", "end_datetime": "9999-12-31T23:59:59Z", @@ -120,5 +122,17 @@ "mlm:model" ] } - } + }, + "links": [ + { + "rel": "collection", + "href": "./collection.json", + "type": "application/json" + }, + { + "rel": "self", + "href": "./item_basic.json", + "type": "application/geo+json" + } + ] } diff --git a/examples/item_eo_bands.json b/examples/item_eo_bands.json index 920fd97..f5831ec 100644 --- a/examples/item_eo_bands.json +++ b/examples/item_eo_bands.json @@ -9,6 +9,7 @@ ], "type": "Feature", "id": "resnet-18_sentinel-2_all_moco_classification", + "collection": "ml-model-examples", "geometry": { "type": "Polygon", "coordinates": [ @@ -22,11 +23,11 @@ 58.21798141355221 ], [ - 27.911651652899925, + 27.911651652899923, 58.21798141355221 ], [ - 27.911651652899925, + 27.911651652899923, 37.13739173208318 ], [ @@ -486,14 +487,6 @@ } ] }, - "links": [ - { - "rel": "derived_from", - "href": "https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a", - "type": "application/json", - "ml-aoi:split": "train" - } - ], "assets": { "weights": { "href": "https://huggingface.co/torchgeo/resnet18_sentinel2_all_moco/resolve/main/resnet18_sentinel2_all_moco-59bfdff9.pth", @@ -549,8 +542,8 @@ }, "source_code": { "href": "https://github.com/microsoft/torchgeo/blob/61efd2e2c4df7ebe3bd03002ebbaeaa3cfe9885a/torchgeo/models/resnet.py#L207", - "title": null, - "description": null, + "title": "Model implementation.", + "description": "Source code to run the model.", "type": "text/x-python", "roles": [ "mlm:model", @@ -558,5 +551,23 @@ "metadata" ] } - } + }, + "links": [ + { + "rel": "collection", + "href": "./collection.json", + "type": "application/json" + }, + { + "rel": "self", + "href": "./item_eo_bands.json", + "type": "application/geo+json" + }, + { + "rel": "derived_from", + "href": "https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a", + "type": "application/json", + "ml-aoi:split": "train" + } + ] } diff --git a/examples/item_multi_io.json b/examples/item_multi_io.json index c5482e8..3975699 100644 --- a/examples/item_multi_io.json +++ b/examples/item_multi_io.json @@ -8,6 +8,7 @@ ], "type": "Feature", "id": "resnet-18_sentinel-2_all_moco_classification", + "collection": "ml-model-examples", "geometry": { "type": "Polygon", "coordinates": [ @@ -21,11 +22,11 @@ 58.21798141355221 ], [ - 27.911651652899925, + 27.911651652899923, 58.21798141355221 ], [ - 27.911651652899925, + 27.911651652899923, 37.13739173208318 ], [ @@ -250,5 +251,23 @@ "mlm:weights" ] } - } + }, + "links": [ + { + "rel": "collection", + "href": "./collection.json", + "type": "application/json" + }, + { + "rel": "self", + "href": "./item_multi_io.json", + "type": "application/geo+json" + }, + { + "rel": "derived_from", + "href": "https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a", + "type": "application/json", + "ml-aoi:split": "train" + } + ] } diff --git a/examples/item_raster_bands.json b/examples/item_raster_bands.json index ed1d765..4faed91 100644 --- a/examples/item_raster_bands.json +++ b/examples/item_raster_bands.json @@ -8,6 +8,7 @@ ], "type": "Feature", "id": "resnet-18_sentinel-2_all_moco_classification", + "collection": "ml-model-examples", "geometry": { "type": "Polygon", "coordinates": [ @@ -21,11 +22,11 @@ 58.21798141355221 ], [ - 27.911651652899925, + 27.911651652899923, 58.21798141355221 ], [ - 27.911651652899925, + 27.911651652899923, 37.13739173208318 ], [ @@ -337,14 +338,6 @@ } ] }, - "links": [ - { - "rel": "derived_from", - "href": "https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a", - "type": "application/json", - "ml-aoi:split": "train" - } - ], "assets": { "weights": { "href": "https://huggingface.co/torchgeo/resnet18_sentinel2_all_moco/resolve/main/resnet18_sentinel2_all_moco-59bfdff9.pth", @@ -358,8 +351,8 @@ }, "source_code": { "href": "https://github.com/microsoft/torchgeo/blob/61efd2e2c4df7ebe3bd03002ebbaeaa3cfe9885a/torchgeo/models/resnet.py#L207", - "title": null, - "description": null, + "title": "Model implementation.", + "description": "Source code to run the model.", "type": "text/x-python", "roles": [ "mlm:model", @@ -367,5 +360,23 @@ "metadata" ] } - } + }, + "links": [ + { + "rel": "collection", + "href": "./collection.json", + "type": "application/json" + }, + { + "rel": "self", + "href": "./item_raster_bands.json", + "type": "application/geo+json" + }, + { + "rel": "derived_from", + "href": "https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a", + "type": "application/json", + "ml-aoi:split": "train" + } + ] } diff --git a/examples/model-arch-summary.txt b/examples/model-arch-summary.txt deleted file mode 100644 index 60f0792..0000000 --- a/examples/model-arch-summary.txt +++ /dev/null @@ -1,155 +0,0 @@ - ---------------------------------------------------------------- - Layer (type) Output Shape Param - ================================================================ - Conv2d-1 [-1, 64, 32, 32] 9,408 - BatchNorm2d-2 [-1, 64, 32, 32] 128 - ReLU-3 [-1, 64, 32, 32] 0 - MaxPool2d-4 [-1, 64, 16, 16] 0 - Conv2d-5 [-1, 64, 16, 16] 36,864 - BatchNorm2d-6 [-1, 64, 16, 16] 128 - ReLU-7 [-1, 64, 16, 16] 0 - Conv2d-8 [-1, 64, 16, 16] 36,864 - BatchNorm2d-9 [-1, 64, 16, 16] 128 - ReLU-10 [-1, 64, 16, 16] 0 - BasicBlock-11 [-1, 64, 16, 16] 0 - Conv2d-12 [-1, 64, 16, 16] 36,864 - BatchNorm2d-13 [-1, 64, 16, 16] 128 - ReLU-14 [-1, 64, 16, 16] 0 - Conv2d-15 [-1, 64, 16, 16] 36,864 - BatchNorm2d-16 [-1, 64, 16, 16] 128 - ReLU-17 [-1, 64, 16, 16] 0 - BasicBlock-18 [-1, 64, 16, 16] 0 - Conv2d-19 [-1, 128, 8, 8] 73,728 - BatchNorm2d-20 [-1, 128, 8, 8] 256 - ReLU-21 [-1, 128, 8, 8] 0 - Conv2d-22 [-1, 128, 8, 8] 147,456 - BatchNorm2d-23 [-1, 128, 8, 8] 256 - Conv2d-24 [-1, 128, 8, 8] 8,192 - BatchNorm2d-25 [-1, 128, 8, 8] 256 - ReLU-26 [-1, 128, 8, 8] 0 - BasicBlock-27 [-1, 128, 8, 8] 0 - Conv2d-28 [-1, 128, 8, 8] 147,456 - BatchNorm2d-29 [-1, 128, 8, 8] 256 - ReLU-30 [-1, 128, 8, 8] 0 - Conv2d-31 [-1, 128, 8, 8] 147,456 - BatchNorm2d-32 [-1, 128, 8, 8] 256 - ReLU-33 [-1, 128, 8, 8] 0 - BasicBlock-34 [-1, 128, 8, 8] 0 - Conv2d-35 [-1, 256, 4, 4] 294,912 - BatchNorm2d-36 [-1, 256, 4, 4] 512 - ReLU-37 [-1, 256, 4, 4] 0 - Conv2d-38 [-1, 256, 4, 4] 589,824 - BatchNorm2d-39 [-1, 256, 4, 4] 512 - Conv2d-40 [-1, 256, 4, 4] 32,768 - BatchNorm2d-41 [-1, 256, 4, 4] 512 - ReLU-42 [-1, 256, 4, 4] 0 - BasicBlock-43 [-1, 256, 4, 4] 0 - Conv2d-44 [-1, 256, 4, 4] 589,824 - BatchNorm2d-45 [-1, 256, 4, 4] 512 - ReLU-46 [-1, 256, 4, 4] 0 - Conv2d-47 [-1, 256, 4, 4] 589,824 - BatchNorm2d-48 [-1, 256, 4, 4] 512 - ReLU-49 [-1, 256, 4, 4] 0 - BasicBlock-50 [-1, 256, 4, 4] 0 - Conv2d-51 [-1, 512, 2, 2] 1,179,648 - BatchNorm2d-52 [-1, 512, 2, 2] 1,024 - ReLU-53 [-1, 512, 2, 2] 0 - Conv2d-54 [-1, 512, 2, 2] 2,359,296 - BatchNorm2d-55 [-1, 512, 2, 2] 1,024 - Conv2d-56 [-1, 512, 2, 2] 131,072 - BatchNorm2d-57 [-1, 512, 2, 2] 1,024 - ReLU-58 [-1, 512, 2, 2] 0 - BasicBlock-59 [-1, 512, 2, 2] 0 - Conv2d-60 [-1, 512, 2, 2] 2,359,296 - BatchNorm2d-61 [-1, 512, 2, 2] 1,024 - ReLU-62 [-1, 512, 2, 2] 0 - Conv2d-63 [-1, 512, 2, 2] 2,359,296 - BatchNorm2d-64 [-1, 512, 2, 2] 1,024 - ReLU-65 [-1, 512, 2, 2] 0 - BasicBlock-66 [-1, 512, 2, 2] 0 - MaxPool2d-67 [-1, 512, 1, 1] 0 - Conv2d-68 [-1, 1024, 1, 1] 4,719,616 - BatchNorm2d-69 [-1, 1024, 1, 1] 2,048 - ReLU-70 [-1, 1024, 1, 1] 0 - _ActivatedBatchNorm-71 [-1, 1024, 1, 1] 0 - AdaptiveAvgPool2d-72 [-1, 1024, 1, 1] 0 - Linear-73 [-1, 64] 65,600 - ReLU-74 [-1, 64] 0 - Linear-75 [-1, 1024] 66,560 - Conv2d-76 [-1, 1, 1, 1] 1,024 - SCSEBlock-77 [-1, 1024, 1, 1] 0 - ConvTranspose2d-78 [-1, 512, 2, 2] 8,389,120 - DecoderUnetSCSE-79 [-1, 512, 2, 2] 0 - Conv2d-80 [-1, 1024, 2, 2] 9,438,208 - BatchNorm2d-81 [-1, 1024, 2, 2] 2,048 - ReLU-82 [-1, 1024, 2, 2] 0 - _ActivatedBatchNorm-83 [-1, 1024, 2, 2] 0 - AdaptiveAvgPool2d-84 [-1, 1024, 1, 1] 0 - Linear-85 [-1, 64] 65,600 - ReLU-86 [-1, 64] 0 - Linear-87 [-1, 1024] 66,560 - Conv2d-88 [-1, 1, 2, 2] 1,024 - SCSEBlock-89 [-1, 1024, 2, 2] 0 - ConvTranspose2d-90 [-1, 256, 4, 4] 4,194,560 - DecoderUnetSCSE-91 [-1, 256, 4, 4] 0 - Conv2d-92 [-1, 512, 4, 4] 2,359,808 - BatchNorm2d-93 [-1, 512, 4, 4] 1,024 - ReLU-94 [-1, 512, 4, 4] 0 - _ActivatedBatchNorm-95 [-1, 512, 4, 4] 0 - AdaptiveAvgPool2d-96 [-1, 512, 1, 1] 0 - Linear-97 [-1, 32] 16,416 - ReLU-98 [-1, 32] 0 - Linear-99 [-1, 512] 16,896 - Conv2d-100 [-1, 1, 4, 4] 512 - SCSEBlock-101 [-1, 512, 4, 4] 0 - ConvTranspose2d-102 [-1, 128, 8, 8] 1,048,704 - DecoderUnetSCSE-103 [-1, 128, 8, 8] 0 - Conv2d-104 [-1, 256, 8, 8] 590,080 - BatchNorm2d-105 [-1, 256, 8, 8] 512 - ReLU-106 [-1, 256, 8, 8] 0 - _ActivatedBatchNorm-107 [-1, 256, 8, 8] 0 - AdaptiveAvgPool2d-108 [-1, 256, 1, 1] 0 - Linear-109 [-1, 16] 4,112 - ReLU-110 [-1, 16] 0 - Linear-111 [-1, 256] 4,352 - Conv2d-112 [-1, 1, 8, 8] 256 - SCSEBlock-113 [-1, 256, 8, 8] 0 - ConvTranspose2d-114 [-1, 64, 16, 16] 262,208 - DecoderUnetSCSE-115 [-1, 64, 16, 16] 0 - Conv2d-116 [-1, 128, 16, 16] 147,584 - BatchNorm2d-117 [-1, 128, 16, 16] 256 - ReLU-118 [-1, 128, 16, 16] 0 - _ActivatedBatchNorm-119 [-1, 128, 16, 16] 0 - AdaptiveAvgPool2d-120 [-1, 128, 1, 1] 0 - Linear-121 [-1, 8] 1,032 - ReLU-122 [-1, 8] 0 - Linear-123 [-1, 128] 1,152 - Conv2d-124 [-1, 1, 16, 16] 128 - SCSEBlock-125 [-1, 128, 16, 16] 0 - ConvTranspose2d-126 [-1, 32, 32, 32] 65,568 - DecoderUnetSCSE-127 [-1, 32, 32, 32] 0 - Conv2d-128 [-1, 64, 32, 32] 55,360 - BatchNorm2d-129 [-1, 64, 32, 32] 128 - ReLU-130 [-1, 64, 32, 32] 0 - ReLU-134 [-1, 4] 0 - Linear-135 [-1, 64] 320 - Conv2d-136 [-1, 1, 32, 32] 64 - SCSEBlock-137 [-1, 64, 32, 32] 0 - ConvTranspose2d-138 [-1, 16, 64, 64] 16,400 - DecoderUnetSCSE-139 [-1, 16, 64, 64] 0 - Conv2d-140 [-1, 64, 64, 64] 31,808 - BatchNorm2d-141 [-1, 64, 64, 64] 128 - ReLU-142 [-1, 64, 64, 64] 0 - _ActivatedBatchNorm-143 [-1, 64, 64, 64] 0 - Conv2d-144 [-1, 5, 64, 64] 325 - EncoderDecoderNet-145 [-1, 5, 64, 64] 0 - ================================================================ - Total params= 42,813,873 - Trainable params= 42,813,873 - Non-trainable params= 0 - ---------------------------------------------------------------- - Input size (MB)= 0.05 - Forward/backward pass size (MB)= 20.35 - Params size (MB)= 163.32 - Estimated Total Size (MB)= 183.72 - ---------------------------------------------------------------- diff --git a/package.json b/package.json index da64d8c..24e9f20 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "test": "npm run check-markdown && npm run check-examples", "check-markdown": "remark . -f -r .github/remark.yaml -i .remarkignore", "format-markdown": "remark . -f -r .github/remark.yaml -i .remarkignore -o", - "check-examples": "stac-node-validator . --lint --verbose --schemaMap https://stac-extensions.github.io/template/v1.0.0/schema.json=./json-schema/schema.json", - "format-examples": "stac-node-validator . --format --schemaMap https://stac-extensions.github.io/template/v1.0.0/schema.json=./json-schema/schema.json" + "check-examples": "stac-node-validator . --lint --verbose --schemaMap https://stac-extensions.github.io/mlm/v1.0.0/schema.json=./json-schema/schema.json", + "format-examples": "stac-node-validator . --format --schemaMap https://stac-extensions.github.io/mlm/v1.0.0/schema.json=./json-schema/schema.json" }, "dependencies": { "remark-cli": "^8.0.0", diff --git a/stac_model/examples.py b/stac_model/examples.py index dcde946..df25326 100644 --- a/stac_model/examples.py +++ b/stac_model/examples.py @@ -12,7 +12,7 @@ def eurosat_resnet() -> ItemMLModelExtension: - input_array = InputStructure( + input_struct = InputStructure( shape=[-1, 13, 64, 64], dim_order=["batch", "channel", "height", "width"], data_type="float32", @@ -66,10 +66,10 @@ def eurosat_resnet() -> ItemMLModelExtension: MLMStatistic(mean=mean, stddev=stddev) for mean, stddev in zip(stats_mean, stats_stddev) ] - input = ModelInput( + model_input = ModelInput( name="13 Band Sentinel-2 Batch", bands=band_names, - input=input_array, + input=input_struct, norm_by_channel=True, norm_type="z-score", resize_type=None, @@ -79,7 +79,7 @@ def eurosat_resnet() -> ItemMLModelExtension: expression="torchgeo.datamodules.eurosat.EuroSATDataModule.collate_fn", ), # noqa: E501 ) - result_array = ModelResult( + result_struct = ModelResult( shape=[-1, 10], dim_order=["batch", "class"], data_type="float32" @@ -100,11 +100,11 @@ def eurosat_resnet() -> ItemMLModelExtension: MLMClassification(value=class_value, name=class_name) for class_name, class_value in class_map.items() ] - output = ModelOutput( + model_output = ModelOutput( name="classification", tasks={"classification"}, classes=class_objects, - result=result_array, + result=result_struct, post_processing_function=None, ) assets = { @@ -123,6 +123,8 @@ def eurosat_resnet() -> ItemMLModelExtension: ] ), "source_code": pystac.Asset( + title="Model implementation.", + description="Source code to run the model.", href="https://github.com/microsoft/torchgeo/blob/61efd2e2c4df7ebe3bd03002ebbaeaa3cfe9885a/torchgeo/models/resnet.py#L207", media_type="text/x-python", roles=[ @@ -147,8 +149,8 @@ def eurosat_resnet() -> ItemMLModelExtension: pretrained=True, pretrained_source="EuroSat Sentinel-2", total_parameters=11_700_000, - input=[input], - output=[output], + input=[model_input], + output=[model_output], ) # TODO, this can't be serialized but pystac.item calls for a datetime # in docs. start_datetime=datetime.strptime("1900-01-01", "%Y-%m-%d") @@ -162,9 +164,11 @@ def eurosat_resnet() -> ItemMLModelExtension: 58.21798141355221 ] geometry = shapely.geometry.Polygon.from_bounds(*bbox).__geo_interface__ - name = "_".join(ml_model_meta.name.split(" ")).lower() + item_name = "_".join(ml_model_meta.name.split(" ")).lower() + col_name = "ml-model-examples" item = pystac.Item( - id=name, + id=item_name, + collection=col_name, geometry=geometry, bbox=bbox, datetime=None, @@ -179,6 +183,16 @@ def eurosat_resnet() -> ItemMLModelExtension: ) item.add_derived_from("https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a") + # define more link references + example_catalog = pystac.Catalog( + "ml-model-examples", + "ml-model-examples", + catalog_type=pystac.CatalogType.RELATIVE_PUBLISHED, + href="https://raw.githubusercontent.com/crim-ca/dlm-extension/main/json-schema/", + ) + item.set_root(example_catalog) + item.set_self_href(f"./{item_name}") + model_asset = cast( FileExtension[pystac.Asset], pystac.extensions.file.FileExtension.ext(assets["model"], add_if_missing=True)