Datasets:

Modalities:
Image
Formats:
parquet
Languages:
English
DOI:
Libraries:
Datasets
Dask
License:
jpodivin commited on
Commit
01880af
1 Parent(s): 8608511

Adding fields to dataset

Browse files

Signed-off-by: Jiri Podivin <[email protected]>

Files changed (1) hide show
  1. plantorgans.py +25 -22
plantorgans.py CHANGED
@@ -11,13 +11,6 @@ _CITATION = """"""
11
 
12
  _LICENSE = "MIT"
13
 
14
- _NAMES = [
15
- 'Leaf',
16
- 'Stem',
17
- 'Flower',
18
- 'Fruit',
19
- ]
20
-
21
  _BASE_URL = "https://huggingface.co/datasets/jpodivin/plantorgans/resolve/main/"
22
  _TRAIN_URLS = [_BASE_URL + f"sourcedata_labeled.tar.{i:02}" for i in range(0, 8)]
23
  _TEST_URLS = [_BASE_URL + f"sourcedata_labeled.tar.{i:02}" for i in range(8, 12)]
@@ -60,18 +53,20 @@ class PlantOrgans(datasets.GeneratorBasedBuilder):
60
 
61
  def _info(self):
62
  return datasets.DatasetInfo(
63
- description=_DESCRIPTION,
64
- features=datasets.Features(
65
- {
66
- "image": datasets.Image(),
67
- "mask": datasets.Image(),
68
- }
69
- ),
70
- supervised_keys=("image", "annotation"),
71
- homepage=_HOMEPAGE,
72
- citation=_CITATION,
73
- license=_LICENSE,
74
- )
 
 
75
 
76
 
77
  def _split_generators(self, dl_manager):
@@ -118,6 +113,7 @@ class PlantOrgans(datasets.GeneratorBasedBuilder):
118
  """
119
  images: path to image directory
120
  metadata_path: path to metadata csv
 
121
  """
122
 
123
  # Get local image paths
@@ -137,6 +133,13 @@ class PlantOrgans(datasets.GeneratorBasedBuilder):
137
 
138
  # Make examples and yield
139
  for i, r in metadata.iterrows():
140
-
141
- # Each example must contain path to image and list of annotations under object key
142
- yield i, {'mask': r['mask_path'], 'image': r['image_path']}
 
 
 
 
 
 
 
 
11
 
12
  _LICENSE = "MIT"
13
 
 
 
 
 
 
 
 
14
  _BASE_URL = "https://huggingface.co/datasets/jpodivin/plantorgans/resolve/main/"
15
  _TRAIN_URLS = [_BASE_URL + f"sourcedata_labeled.tar.{i:02}" for i in range(0, 8)]
16
  _TEST_URLS = [_BASE_URL + f"sourcedata_labeled.tar.{i:02}" for i in range(8, 12)]
 
53
 
54
  def _info(self):
55
  return datasets.DatasetInfo(
56
+ description=_DESCRIPTION,
57
+ features=datasets.Features(
58
+ {
59
+ "image": datasets.Image(),
60
+ "mask": datasets.Image(),
61
+ "score": datasets.Value(dtype='double'),
62
+ "image_name": datasets.Value(dtype="string")
63
+ }
64
+ ),
65
+ supervised_keys=("image", "mask"),
66
+ homepage=_HOMEPAGE,
67
+ citation=_CITATION,
68
+ license=_LICENSE,
69
+ )
70
 
71
 
72
  def _split_generators(self, dl_manager):
 
113
  """
114
  images: path to image directory
115
  metadata_path: path to metadata csv
116
+ masks_path: path to masks
117
  """
118
 
119
  # Get local image paths
 
133
 
134
  # Make examples and yield
135
  for i, r in metadata.iterrows():
136
+ # Example contains paths to mask, source image, certainty of label,
137
+ # and name of source image.
138
+ example = {
139
+ 'mask': r['mask_path'],
140
+ 'image': r['image_path'],
141
+ 'image_name': Path(r['image_path']).parts[-1],
142
+ 'score': r['score']
143
+ }
144
+
145
+ yield i, example