Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ff478e4

Browse files
authoredMar 10, 2022
Merge pull request #11 from Project-AgML/dev
Release 0.2.6
2 parents 5b462aa + 0d3ecd4 commit ff478e4

File tree

2 files changed

+23
-35
lines changed

2 files changed

+23
-35
lines changed
 

‎agml/_assets/public_datasources.json

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"platform": "ground_fixed",
7777
"input_data_format": "png",
7878
"annotation_format": "directory_names",
79-
"n_images": "5588",
79+
"n_images": "5539",
8080
"docs_url": "https://vision.eng.au.dk/plant-seedlings-dataset/",
8181
"stats": {
8282
"mean": [
@@ -381,38 +381,6 @@
381381
},
382382
"external_image_sources": []
383383
},
384-
"cotton_seedling_counting": {
385-
"ml_task": "object_detection",
386-
"ag_task": "seedling_counting",
387-
"location": {
388-
"continent": "worldwide",
389-
"country": "worldwide"
390-
},
391-
"sensor_modality": "rgb",
392-
"real_synthetic": "real",
393-
"platform": "ground",
394-
"input_data_format": "png",
395-
"annotation_format": "coco_json",
396-
"n_images": "2290",
397-
"docs_url": "https://github.com/UGA-BSAIL/deepseedling",
398-
"stats": {
399-
"mean": [
400-
0.6695063710212708,
401-
0.5673825144767761,
402-
0.4538835883140564
403-
],
404-
"std": [
405-
0.07037307322025299,
406-
0.07951230555772781,
407-
0.07661264389753342
408-
]
409-
},
410-
"classes": {
411-
"0": "Plant",
412-
"1": "Weed"
413-
},
414-
"external_image_sources": []
415-
},
416384
"mango_detection_australia": {
417385
"ml_task": "object_detection",
418386
"ag_task": "fruit_detection",

‎agml/data/metadata.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,24 @@
2525
)
2626

2727

28+
class _MetadataDict(dict):
29+
"""Dictionary subclass that throws a custom error for metadata accesses."""
30+
def __init__(self, *args, dataset = None, **kwargs):
31+
if dataset is None:
32+
raise ValueError(
33+
"Cannot instantiate metadata dictionary without the dataset name.")
34+
super(_MetadataDict, self).__init__(*args, **kwargs)
35+
self._dataset = dataset
36+
37+
def __getitem__(self, item):
38+
try:
39+
return super(_MetadataDict, self).__getitem__(item)
40+
except KeyError:
41+
raise KeyError(
42+
f"The dataset '{self._dataset}' is missing metadata '{item}'. "
43+
f"Please bring this issue to the attention of the AgML team.")
44+
45+
2846
class DatasetMetadata(AgMLSerializable):
2947
"""Stores metadata about a certain AgML dataset.
3048
@@ -88,10 +106,12 @@ def _load_source_info(self, name):
88106
f"Interpreted dataset '{name}' as '{name.replace('-', '_')}.'")
89107
name = name.replace('-', '_')
90108
self._name = name
91-
self._metadata = source_info[name]
109+
self._metadata = _MetadataDict(
110+
**source_info[name], dataset = name)
92111

93112
# Load citation information.
94-
self._citation_meta = load_citation_sources()[name]
113+
self._citation_meta = _MetadataDict(
114+
**load_citation_sources()[name], dataset = name)
95115

96116
def __getattr__(self, key):
97117
try:

0 commit comments

Comments
 (0)
Please sign in to comment.