Update WaterFlowCountersRecognition.py
Browse files
WaterFlowCountersRecognition.py
CHANGED
|
@@ -60,7 +60,7 @@ class WaterFlowCounter(datasets.GeneratorBasedBuilder):
|
|
| 60 |
def _info(self):
|
| 61 |
features = datasets.Features(
|
| 62 |
{
|
| 63 |
-
"
|
| 64 |
"image": datasets.Image(),
|
| 65 |
"regions": datasets.Sequence(
|
| 66 |
{
|
|
@@ -114,7 +114,6 @@ class WaterFlowCounter(datasets.GeneratorBasedBuilder):
|
|
| 114 |
with open(metadata_path, "r", encoding='utf-8') as f:
|
| 115 |
annotations = json.load(f)
|
| 116 |
|
| 117 |
-
#print(annotations['_via_image_id_list'][0:5])
|
| 118 |
|
| 119 |
for file in os.listdir(folder_dir):
|
| 120 |
filepath = os.path.join(folder_dir, file)
|
|
@@ -131,7 +130,7 @@ class WaterFlowCounter(datasets.GeneratorBasedBuilder):
|
|
| 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,7 +144,7 @@ class WaterFlowCounter(datasets.GeneratorBasedBuilder):
|
|
| 145 |
|
| 146 |
|
| 147 |
yield idx, {
|
| 148 |
-
"
|
| 149 |
"image": {"path": filepath, "bytes": image_bytes},
|
| 150 |
"regions": {
|
| 151 |
"all_points_x": all_x,
|
|
|
|
| 60 |
def _info(self):
|
| 61 |
features = datasets.Features(
|
| 62 |
{
|
| 63 |
+
"id": datasets.Value("string"),
|
| 64 |
"image": datasets.Image(),
|
| 65 |
"regions": datasets.Sequence(
|
| 66 |
{
|
|
|
|
| 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)
|
|
|
|
| 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 |
|
| 145 |
|
| 146 |
yield idx, {
|
| 147 |
+
"id": id,
|
| 148 |
"image": {"path": filepath, "bytes": image_bytes},
|
| 149 |
"regions": {
|
| 150 |
"all_points_x": all_x,
|