SIA86 commited on
Commit
3022e89
·
1 Parent(s): 7a83f60

Update WaterFlowCountersRecognition.py

Browse files
Files changed (1) hide show
  1. WaterFlowCountersRecognition.py +8 -2
WaterFlowCountersRecognition.py CHANGED
@@ -66,7 +66,8 @@ class WaterFlowCounter(datasets.GeneratorBasedBuilder):
66
  "width": datasets.Value('int32'),
67
  "height": datasets.Value('int32'),
68
  "annotations": datasets.Sequence(
69
- {
 
70
  "bbox": datasets.Sequence(datasets.Value("int64"), length=4),
71
  "area": datasets.Value("int64"),
72
  "segmentation": datasets.Sequence(datasets.Sequence(datasets.Value("int64"))),
@@ -119,6 +120,7 @@ class WaterFlowCounter(datasets.GeneratorBasedBuilder):
119
  annotations = json.load(f)
120
 
121
  idx = 0
 
122
 
123
  for file in os.listdir(folder_dir):
124
  filepath = os.path.join(folder_dir, file)
@@ -134,12 +136,15 @@ class WaterFlowCounter(datasets.GeneratorBasedBuilder):
134
  all_segmentation = []
135
  names = []
136
  rotated = []
 
137
 
138
  for el in annotations['_via_img_metadata']:
139
 
140
  if annotations['_via_img_metadata'][el]['filename'] == file:
141
 
142
  for region in annotations['_via_img_metadata'][el]['regions']:
 
 
143
  all_x = region['shape_attributes']['all_points_x']
144
  all_y = region['shape_attributes']['all_points_y']
145
  x_min = min(all_x)
@@ -155,7 +160,7 @@ class WaterFlowCounter(datasets.GeneratorBasedBuilder):
155
  all_bbox.append(bbox)
156
  all_area.append(area)
157
  all_segmentation.append(segmentation)
158
-
159
  for name in list(region['region_attributes']['name'].keys()):
160
  names.append(name_to_id[name])
161
  try:
@@ -171,6 +176,7 @@ class WaterFlowCounter(datasets.GeneratorBasedBuilder):
171
  "width": width,
172
  "height": height,
173
  "annotations": {
 
174
  "area": all_area,
175
  "bbox": all_bbox,
176
  "segmentation": all_segmentation,
 
66
  "width": datasets.Value('int32'),
67
  "height": datasets.Value('int32'),
68
  "annotations": datasets.Sequence(
69
+ {
70
+ "id": datasets.Value('int32'),
71
  "bbox": datasets.Sequence(datasets.Value("int64"), length=4),
72
  "area": datasets.Value("int64"),
73
  "segmentation": datasets.Sequence(datasets.Sequence(datasets.Value("int64"))),
 
120
  annotations = json.load(f)
121
 
122
  idx = 0
123
+ id = 0
124
 
125
  for file in os.listdir(folder_dir):
126
  filepath = os.path.join(folder_dir, file)
 
136
  all_segmentation = []
137
  names = []
138
  rotated = []
139
+ ids = []
140
 
141
  for el in annotations['_via_img_metadata']:
142
 
143
  if annotations['_via_img_metadata'][el]['filename'] == file:
144
 
145
  for region in annotations['_via_img_metadata'][el]['regions']:
146
+ ids.append(id)
147
+ id += 1
148
  all_x = region['shape_attributes']['all_points_x']
149
  all_y = region['shape_attributes']['all_points_y']
150
  x_min = min(all_x)
 
160
  all_bbox.append(bbox)
161
  all_area.append(area)
162
  all_segmentation.append(segmentation)
163
+
164
  for name in list(region['region_attributes']['name'].keys()):
165
  names.append(name_to_id[name])
166
  try:
 
176
  "width": width,
177
  "height": height,
178
  "annotations": {
179
+ "id": = ids,
180
  "area": all_area,
181
  "bbox": all_bbox,
182
  "segmentation": all_segmentation,