공유해 주셔서 감사합니다. 작은 문제가 발생했습니다.
D:/hello/
├── Annotations
│ ├── xxx1.xml
│ ├── xxx2.xml
│ ├── xxx3.xml
│ | ...
├── JPEGImages
│ ├── xxx1.jpg
│ ├── xxx2.jpg
│ ├── xxx3.jpg
if __name__ == "__main__":
# parser = argparse.ArgumentParser(description='Detection dataset augmentation')
# parser.add_argument('--image_path', type=str)
# parser.add_argument('--xml_path', type=str)
# parser.add_argument('--outpath', type=str)
# parser.add_argument('--outshape', type=str) # split or merge
# parser.add_argument('--num_aug', type=str, default=5)
# parser.add_argument('--visual', type=str2bool, default=False)
# args = parser.parse_args()
image_set_path = "D:/hello/JPEGImages/*.jpg"
image_list = sorted(glob.glob(image_set_path))
xml_set_path = "D:/hello/Annotations/*.xml"
xml_list = sorted(glob.glob(xml_set_path))
print(len(image_list), len(xml_list))
output_shape = "merge"
output_path = "D:/hello/VOC/"
aug_num = "10"
visual = False
26 26
0%| | 0/26 [00:00<?, ?it/s]0 Annotations\NG_1.xml This file does not contain objects.
1 Annotations\NG_10.xml This file does not contain objects.
2 Annotations\NG_100.xml This file does not contain objects.
12%|███████████████████▍ | 3/26 [00:00<00:00, 23.44it/s]3 Annotations\NG_101.xml This file does not contain objects.
4 Annotations\NG_102.xml This file does not contain objects.
5 Annotations\NG_103.xml This file does not contain objects.
23%|██████████████████████████████████████▊ | 6/26 [00:00<00:00, 24.69it/s]6 Annotations\NG_104.xml This file does not contain objects.
7 Annotations\NG_105.xml This file does not contain objects.
8 Annotations\NG_11.xml This file does not contain objects.
35%|██████████████████████████████████████████████████████████▏ | 9/26 [00:00<00:00, 25.21it/s]9 Annotations\NG_12.xml This file does not contain objects.
10 Annotations\NG_13.xml This file does not contain objects.
11 Annotations\NG_14.xml This file does not contain objects.
46%|█████████████████████████████████████████████████████████████████████████████ | 12/26 [00:00<00:00, 25.63it/s]12 Annotations\NG_15.xml This file does not contain objects.
13 Annotations\NG_16.xml This file does not contain objects.
14 Annotations\NG_2.xml This file does not contain objects.
58%|████████████████████████████████████████████████████████████████████████████████████████████████▎ | 15/26 [00:00<00:00, 24.95it/s]15 Annotations\NG_3.xml This file does not contain objects.
16 Annotations\NG_4.xml This file does not contain objects.
17 Annotations\NG_5.xml This file does not contain objects.
69%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 18/26 [00:00<00:00, 25.54it/s]18 Annotations\NG_6.xml This file does not contain objects.
19 Annotations\NG_7.xml This file does not contain objects.
20 Annotations\NG_8.xml This file does not contain objects.
81%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉ | 21/26 [00:00<00:00, 25.94it/s]21 Annotations\NG_9.xml This file does not contain objects.
22 Annotations\OK_1.xml This file does not contain objects.
23 Annotations\OK_2.xml This file does not contain objects.
92%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ | 24/26 [00:00<00:00, 26.12it/s]24 Annotations\OK_3.xml This file does not contain objects.
25 Annotations\OK_5.xml This file does not contain objects.
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 26/26 [00:01<00:00, 25.66it/s]
26 26
0%| | 0/26 [00:00<?, ?it/s]xml_name Annotations\NG_10010000.xml
0%| | 0/26 [00:00<?, ?it/s]
Traceback (most recent call last):
File "E:\anaconda3\envs\hello\lib\xml\etree\ElementTree.py", line 786, in _get_writer
write = file_or_filename.write
AttributeError: 'str' object has no attribute 'write'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "f:/Intsoft_AI/a6.py", line 247, in <module>
augmentation(image_list, xml_list, output_shape, visual)
File "f:/Intsoft_AI/a6.py", line 185, in augmentation
modify_coordinate(output_path, transformed, xml, x, output_shape)
File "f:/Intsoft_AI/a6.py", line 132, in modify_coordinate
tree.write(f"{output_path}/{str(idx)}/annotations/{filename}_{str(idx)}.xml")
File "E:\anaconda3\envs\hello\lib\xml\etree\ElementTree.py", line 756, in write
with _get_writer(file_or_filename, enc_lower) as write:
File "E:\anaconda3\envs\hello\lib\contextlib.py", line 113, in __enter__
return next(self.gen)
File "E:\anaconda3\envs\hello\lib\xml\etree\ElementTree.py", line 792, in _get_writer
file = open(file_or_filename, "w", encoding=encoding,
FileNotFoundError: [Errno 2] No such file or directory: 'D:/hello/VOC//0/annotations/Annotations\\NG_10010000_0.xml'