SIA86 commited on
Commit
ed8f186
·
1 Parent(s): 07c3866

Update WaterFlowCountersRecognition.py

Browse files
Files changed (1) hide show
  1. WaterFlowCountersRecognition.py +13 -9
WaterFlowCountersRecognition.py CHANGED
@@ -22,13 +22,13 @@ _REGION_NAME = ['value_a', 'value_b', 'serial']
22
 
23
  _REGION_ROTETION = ['0', '90', '180', '270']
24
 
25
- _ANNOTATIONS_PATH = "WaterFlowCounter.json"
26
 
27
 
28
  class WaterFlowCounterConfig(datasets.BuilderConfig):
29
  """Builder Config for WaterFlowCounter"""
30
 
31
- def __init__(self, data_url, **kwargs):
32
  """BuilderConfig for WaterFlowCounter.
33
  Args:
34
  data_url: `string`, url to download the photos.
@@ -37,6 +37,7 @@ class WaterFlowCounterConfig(datasets.BuilderConfig):
37
  """
38
  super(WaterFlowCounterConfig, self).__init__(version=datasets.Version("1.0.0"), **kwargs)
39
  self.data_url = data_url
 
40
 
41
 
42
 
@@ -48,10 +49,12 @@ class WaterFlowCounter(datasets.GeneratorBasedBuilder):
48
  name="WFCR_full",
49
  description="Full dataset which contains coordinates and names of regions and information about rotation",
50
  data_url={
51
- "train": "data/train_photos.zip",
52
- "test": "data/test_photos.zip",
53
  },
54
-
 
 
55
  )
56
  ]
57
 
@@ -79,25 +82,26 @@ class WaterFlowCounter(datasets.GeneratorBasedBuilder):
79
 
80
  def _split_generators(self, dl_manager):
81
  data_files = dl_manager.download_and_extract(self.config.data_url)
 
82
 
83
  return [
84
  datasets.SplitGenerator(
85
  name=datasets.Split.TRAIN,
86
  gen_kwargs={
87
  "folder_dir": data_files["train"],
88
-
89
  },
90
  ),
91
  datasets.SplitGenerator(
92
  name=datasets.Split.TEST,
93
  gen_kwargs={
94
  "folder_dir": data_files["test"],
95
-
96
  },
97
  )
98
  ]
99
 
100
- def _generate_examples(self, folder_dir):
101
  name_to_id = {}
102
  rotation_to_id = {}
103
 
@@ -108,7 +112,7 @@ class WaterFlowCounter(datasets.GeneratorBasedBuilder):
108
  rotation_to_id[name] = indx
109
 
110
 
111
- with open(_ANNOTATIONS_PATH, "r", encoding='utf-8') as f:
112
  annotations = json.load(f)
113
 
114
  #print(annotations['_via_image_id_list'][0:5])
 
22
 
23
  _REGION_ROTETION = ['0', '90', '180', '270']
24
 
25
+
26
 
27
 
28
  class WaterFlowCounterConfig(datasets.BuilderConfig):
29
  """Builder Config for WaterFlowCounter"""
30
 
31
+ def __init__(self, data_url, metadata_url, **kwargs):
32
  """BuilderConfig for WaterFlowCounter.
33
  Args:
34
  data_url: `string`, url to download the photos.
 
37
  """
38
  super(WaterFlowCounterConfig, self).__init__(version=datasets.Version("1.0.0"), **kwargs)
39
  self.data_url = data_url
40
+ self.metadata_url = metadata_url
41
 
42
 
43
 
 
49
  name="WFCR_full",
50
  description="Full dataset which contains coordinates and names of regions and information about rotation",
51
  data_url={
52
+ "train": "https://huggingface.co/datasets/SIA86/WaterFlowCountersRecognition/blob/main/data/train_photos.zip",
53
+ "test": "https://huggingface.co/datasets/SIA86/WaterFlowCountersRecognition/blob/main/data/test_photos.zip",
54
  },
55
+ metadata_url={
56
+ 'full': "https://huggingface.co/datasets/SIA86/WaterFlowCountersRecognition/blob/main/WaterFlowCounter.json
57
+ }
58
  )
59
  ]
60
 
 
82
 
83
  def _split_generators(self, dl_manager):
84
  data_files = dl_manager.download_and_extract(self.config.data_url)
85
+ meta_file = dl_manager.download(self.config.metadata_url)
86
 
87
  return [
88
  datasets.SplitGenerator(
89
  name=datasets.Split.TRAIN,
90
  gen_kwargs={
91
  "folder_dir": data_files["train"],
92
+ "metadata_path": meta_file['full']
93
  },
94
  ),
95
  datasets.SplitGenerator(
96
  name=datasets.Split.TEST,
97
  gen_kwargs={
98
  "folder_dir": data_files["test"],
99
+ "metadata_path": meta_file['full']
100
  },
101
  )
102
  ]
103
 
104
+ def _generate_examples(self, folder_dir, metadata_path):
105
  name_to_id = {}
106
  rotation_to_id = {}
107
 
 
112
  rotation_to_id[name] = indx
113
 
114
 
115
+ with open(metadata_path, "r", encoding='utf-8') as f:
116
  annotations = json.load(f)
117
 
118
  #print(annotations['_via_image_id_list'][0:5])