Update hugging_face.py
Browse files- hugging_face.py +4 -6
hugging_face.py
CHANGED
@@ -111,18 +111,18 @@ class RDD2020_Dataset(datasets.GeneratorBasedBuilder):
|
|
111 |
]
|
112 |
|
113 |
def _generate_examples(self, base_path, split):
|
114 |
-
print(base_path)
|
115 |
# Iterate over each country directory
|
116 |
for country_dir in ['Czech', 'India', 'Japan']:
|
117 |
-
images_dir = f"{
|
118 |
-
annotations_dir = f"{
|
119 |
|
120 |
# Iterate over each image in the country's image directory
|
121 |
for image_file in os.listdir(images_dir):
|
122 |
if not image_file.endswith('.jpg'):
|
123 |
continue
|
124 |
|
125 |
-
image_id = f"{
|
|
|
126 |
image_path = os.path.join(images_dir, image_file)
|
127 |
if annotations_dir:
|
128 |
annotation_file = image_id + '.xml'
|
@@ -147,12 +147,10 @@ class RDD2020_Dataset(datasets.GeneratorBasedBuilder):
|
|
147 |
crack_type = []
|
148 |
crack_coordinates = []
|
149 |
|
150 |
-
image_resolution = {"width": 600, "height": 600, "depth": 3}
|
151 |
yield image_id, {
|
152 |
"image_id": image_id,
|
153 |
"country": country_dir,
|
154 |
"type": split,
|
155 |
-
"image_resolution": image_resolution,
|
156 |
"image_path": image_path,
|
157 |
"crack_type": crack_type,
|
158 |
"crack_coordinates": crack_coordinates,
|
|
|
111 |
]
|
112 |
|
113 |
def _generate_examples(self, base_path, split):
|
|
|
114 |
# Iterate over each country directory
|
115 |
for country_dir in ['Czech', 'India', 'Japan']:
|
116 |
+
images_dir = f"{extracted_path}/{country_dir}/images"
|
117 |
+
annotations_dir = f"{extracted_path}/{country_dir}/annotations/xmls" if split == "train" else None
|
118 |
|
119 |
# Iterate over each image in the country's image directory
|
120 |
for image_file in os.listdir(images_dir):
|
121 |
if not image_file.endswith('.jpg'):
|
122 |
continue
|
123 |
|
124 |
+
image_id = f"{image_file.split('.')[0]}"
|
125 |
+
|
126 |
image_path = os.path.join(images_dir, image_file)
|
127 |
if annotations_dir:
|
128 |
annotation_file = image_id + '.xml'
|
|
|
147 |
crack_type = []
|
148 |
crack_coordinates = []
|
149 |
|
|
|
150 |
yield image_id, {
|
151 |
"image_id": image_id,
|
152 |
"country": country_dir,
|
153 |
"type": split,
|
|
|
154 |
"image_path": image_path,
|
155 |
"crack_type": crack_type,
|
156 |
"crack_coordinates": crack_coordinates,
|