SIA86 commited on
Commit
39d8995
·
1 Parent(s): b460a33

Update WaterFlowCountersRecognition.py

Browse files
Files changed (1) hide show
  1. WaterFlowCountersRecognition.py +5 -4
WaterFlowCountersRecognition.py CHANGED
@@ -114,14 +114,15 @@ class WaterFlowCounter(datasets.GeneratorBasedBuilder):
114
  with open(metadata_path, "r", encoding='utf-8') as f:
115
  annotations = json.load(f)
116
 
117
-
 
118
  for file in os.listdir(folder_dir):
119
  filepath = os.path.join(folder_dir, file)
120
  #print(filepath)
121
  with open(filepath, "rb") as f:
122
  image_bytes = f.read()
123
  #print(image_bytes)
124
- idx = 0
125
  all_x = []
126
  all_y = []
127
  names = []
@@ -130,7 +131,7 @@ class WaterFlowCounter(datasets.GeneratorBasedBuilder):
130
  for el in annotations['_via_img_metadata']:
131
 
132
  if annotations['_via_img_metadata'][el]['filename'] == file:
133
- id = str(annotations['_via_img_metadata'][el]['size']) + '-' +str(idx)
134
  for region in annotations['_via_img_metadata'][el]['regions']:
135
  all_x.append(region['shape_attributes']['all_points_x'])
136
  all_y.append(region['shape_attributes']['all_points_y'])
@@ -144,7 +145,7 @@ class WaterFlowCounter(datasets.GeneratorBasedBuilder):
144
 
145
 
146
  yield idx, {
147
- "id": id,
148
  "image": {"path": filepath, "bytes": image_bytes},
149
  "regions": {
150
  "all_points_x": all_x,
 
114
  with open(metadata_path, "r", encoding='utf-8') as f:
115
  annotations = json.load(f)
116
 
117
+ idx = 0
118
+
119
  for file in os.listdir(folder_dir):
120
  filepath = os.path.join(folder_dir, file)
121
  #print(filepath)
122
  with open(filepath, "rb") as f:
123
  image_bytes = f.read()
124
  #print(image_bytes)
125
+
126
  all_x = []
127
  all_y = []
128
  names = []
 
131
  for el in annotations['_via_img_metadata']:
132
 
133
  if annotations['_via_img_metadata'][el]['filename'] == file:
134
+
135
  for region in annotations['_via_img_metadata'][el]['regions']:
136
  all_x.append(region['shape_attributes']['all_points_x'])
137
  all_y.append(region['shape_attributes']['all_points_y'])
 
145
 
146
 
147
  yield idx, {
148
+ "id": file,
149
  "image": {"path": filepath, "bytes": image_bytes},
150
  "regions": {
151
  "all_points_x": all_x,