Skip to content

Commit 9ddff24

Browse files
committed
export an example with stac common metadata, derived from link to dataset
1 parent 30269d4 commit 9ddff24

File tree

2 files changed

+234
-5
lines changed

2 files changed

+234
-5
lines changed

example.json

Lines changed: 229 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,232 @@
33
"stac_version": "1.0.0",
44
"id": "resnet-18_sentinel-2_all_moco_classification",
55
"properties": {
6-
"start_datetime":
6+
"start_datetime": "1900-01-01",
7+
"end_datetime": null,
8+
"mlm:name": "Resnet-18 Sentinel-2 ALL MOCO",
9+
"mlm:task": "classification",
10+
"mlm:framework": "pytorch",
11+
"mlm:framework_version": "2.1.2+cu121",
12+
"mlm:file_size": 1,
13+
"mlm:memory_size": 1,
14+
"mlm:input": [
15+
{
16+
"name": "13 Band Sentinel-2 Batch",
17+
"bands": [
18+
"B01",
19+
"B02",
20+
"B03",
21+
"B04",
22+
"B05",
23+
"B06",
24+
"B07",
25+
"B08",
26+
"B8A",
27+
"B09",
28+
"B10",
29+
"B11",
30+
"B12"
31+
],
32+
"input_array": {
33+
"shape": [
34+
-1,
35+
13,
36+
64,
37+
64
38+
],
39+
"dim_order": "bchw",
40+
"data_type": "float32"
41+
},
42+
"norm_by_channel": true,
43+
"norm_type": "z_score",
44+
"resize_type": "none",
45+
"parameters": null,
46+
"statistics": {
47+
"minimum": null,
48+
"maximum": null,
49+
"mean": [
50+
1354.40546513,
51+
1118.24399958,
52+
1042.92983953,
53+
947.62620298,
54+
1199.47283961,
55+
1999.79090914,
56+
2369.22292565,
57+
2296.82608323,
58+
732.08340178,
59+
12.11327804,
60+
1819.01027855,
61+
1118.92391149,
62+
2594.14080798
63+
],
64+
"stddev": [
65+
245.71762908,
66+
333.00778264,
67+
395.09249139,
68+
593.75055589,
69+
566.4170017,
70+
861.18399006,
71+
1086.63139075,
72+
1117.98170791,
73+
404.91978886,
74+
4.77584468,
75+
1002.58768311,
76+
761.30323499,
77+
1231.58581042
78+
],
79+
"count": null,
80+
"valid_percent": null
81+
},
82+
"norm_with_clip_values": null,
83+
"pre_processing_function": "https://github.com/microsoft/torchgeo/blob/545abe8326efc2848feae69d0212a15faba3eb00/torchgeo/datamodules/eurosat.py"
84+
}
85+
],
86+
"mlm:output": [
87+
{
88+
"task": "classification",
89+
"result_array": [
90+
{
91+
"shape": [
92+
-1,
93+
10
94+
],
95+
"dim_names": [
96+
"batch",
97+
"class"
98+
],
99+
"data_type": "float32"
100+
}
101+
],
102+
"classification_classes": [
103+
{
104+
"value": 0,
105+
"name": "Annual Crop",
106+
"description": null,
107+
"title": null,
108+
"color_hint": null,
109+
"nodata": false
110+
},
111+
{
112+
"value": 1,
113+
"name": "Forest",
114+
"description": null,
115+
"title": null,
116+
"color_hint": null,
117+
"nodata": false
118+
},
119+
{
120+
"value": 2,
121+
"name": "Herbaceous Vegetation",
122+
"description": null,
123+
"title": null,
124+
"color_hint": null,
125+
"nodata": false
126+
},
127+
{
128+
"value": 3,
129+
"name": "Highway",
130+
"description": null,
131+
"title": null,
132+
"color_hint": null,
133+
"nodata": false
134+
},
135+
{
136+
"value": 4,
137+
"name": "Industrial Buildings",
138+
"description": null,
139+
"title": null,
140+
"color_hint": null,
141+
"nodata": false
142+
},
143+
{
144+
"value": 5,
145+
"name": "Pasture",
146+
"description": null,
147+
"title": null,
148+
"color_hint": null,
149+
"nodata": false
150+
},
151+
{
152+
"value": 6,
153+
"name": "Permanent Crop",
154+
"description": null,
155+
"title": null,
156+
"color_hint": null,
157+
"nodata": false
158+
},
159+
{
160+
"value": 7,
161+
"name": "Residential Buildings",
162+
"description": null,
163+
"title": null,
164+
"color_hint": null,
165+
"nodata": false
166+
},
167+
{
168+
"value": 8,
169+
"name": "River",
170+
"description": null,
171+
"title": null,
172+
"color_hint": null,
173+
"nodata": false
174+
},
175+
{
176+
"value": 9,
177+
"name": "SeaLake",
178+
"description": null,
179+
"title": null,
180+
"color_hint": null,
181+
"nodata": false
182+
}
183+
],
184+
"post_processing_function": null
185+
}
186+
],
187+
"mlm:runtime": [
188+
{
189+
"asset": {
190+
"href": "https://huggingface.co/torchgeo/resnet18_sentinel2_all_moco/resolve/main/resnet18_sentinel2_all_moco-59bfdff9.pth",
191+
"title": null,
192+
"description": null,
193+
"type": null,
194+
"roles": null
195+
},
196+
"source_code": {
197+
"href": "https://github.com/microsoft/torchgeo/blob/61efd2e2c4df7ebe3bd03002ebbaeaa3cfe9885a/torchgeo/models/resnet.py#L207",
198+
"title": null,
199+
"description": null,
200+
"type": null,
201+
"roles": null
202+
},
203+
"accelerator": "cuda",
204+
"accelerator_constrained": false,
205+
"hardware_summary": "Unknown",
206+
"container": null,
207+
"commit_hash": null,
208+
"batch_size_suggestion": null
209+
}
210+
],
211+
"mlm:total_parameters": 11700000,
212+
"mlm:pretrained_source": "EuroSat Sentinel-2",
213+
"mlm:summary": "Sourced from torchgeo python library,identifier is ResNet18_Weights.SENTINEL2_ALL_MOCO",
214+
"datetime": null
215+
},
216+
"geometry": null,
217+
"links": [
218+
{
219+
"rel": "derived_from",
220+
"href": "https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a",
221+
"type": "application/json"
222+
}
223+
],
224+
"assets": {},
225+
"bbox": [
226+
-90,
227+
-180,
228+
90,
229+
180
230+
],
231+
"stac_extensions": [
232+
"https://raw.githubusercontent.com/crim-ca/dlm-extension/main/json-schema/schema.json"
233+
]
234+
}

stac_model/examples.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from datetime import datetime
2-
31
import pystac
42

53
from stac_model.schema import (
@@ -120,7 +118,7 @@ def eurosat_resnet():
120118
mlm_task="classification",
121119
mlm_framework="pytorch",
122120
mlm_framework_version="2.1.2+cu121",
123-
mlm_file_size=1,
121+
mlm_file_size=43000000,
124122
mlm_memory_size=1,
125123
mlm_summary=(
126124
"Sourced from torchgeo python library,"
@@ -132,7 +130,10 @@ def eurosat_resnet():
132130
mlm_runtime=[mlm_runtime],
133131
mlm_output=[mlm_output],
134132
)
135-
start_datetime = datetime.strptime("1900-01-01", "%Y-%m-%d")
133+
# TODO, this can't be serialized but pystac.item calls for a datetime
134+
# in docs. start_datetime=datetime.strptime("1900-01-01", "%Y-%m-%d")
135+
# Is this a problem that we don't do date validation if we supply as str?
136+
start_datetime = "1900-01-01"
136137
end_datetime = None
137138
geometry = None
138139
bbox = [-90, -180, 90, 180]

0 commit comments

Comments
 (0)