pervin0527 / pervinco Goto Github PK
View Code? Open in Web Editor NEWVision Deep-Learning using Tensorflow, Keras.
Vision Deep-Learning using Tensorflow, Keras.
A.Rotate(limit=(-90,90), border_mode=4, p=1.0),
Traceback (most recent call last):
File "f:/hello/a6.py", line 252, in <module>
augmentation(image_list, xml_list, output_shape, visual)
File "f:/hello/a6.py", line 200, in augmentation
modify_coordinate(output_path, transformed, xml, x, output_shape)
File "f:/hello/a6.py", line 122, in modify_coordinate
bbox_original.find('xmin').text = str(int(bbox_mod[x][0]))
IndexError: list index out of range
Image Size
2048*1500
XML
<annotation>
<folder>20481500NG</folder>
<filename>NG_16.JPG</filename>
<path>D:\hello\NG_16.JPG</path>
<source>
<database>Unknown</database>
</source>
<size>
<width>2048</width>
<height>1500</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>Hei</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>581</xmin>
<ymin>467</ymin>
<xmax>606</xmax>
<ymax>494</ymax>
</bndbox>
</object>
<object>
<name>Hei</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>574</xmin>
<ymin>490</ymin>
<xmax>580</xmax>
<ymax>499</ymax>
</bndbox>
</object>
<object>
<name>Dian</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1734</xmin>
<ymin>397</ymin>
<xmax>1743</xmax>
<ymax>405</ymax>
</bndbox>
</object>
<object>
<name>Hei</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1707</xmin>
<ymin>380</ymin>
<xmax>1717</xmax>
<ymax>393</ymax>
</bndbox>
</object>
<object>
<name>Hei</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1882</xmin>
<ymin>450</ymin>
<xmax>1893</xmax>
<ymax>462</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1805</xmin>
<ymin>512</ymin>
<xmax>1814</xmax>
<ymax>523</ymax>
</bndbox>
</object>
<object>
<name>Dian</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1735</xmin>
<ymin>489</ymin>
<xmax>1745</xmax>
<ymax>504</ymax>
</bndbox>
</object>
<object>
<name>Dian</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1594</xmin>
<ymin>473</ymin>
<xmax>1605</xmax>
<ymax>484</ymax>
</bndbox>
</object>
<object>
<name>TuCeng</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1520</xmin>
<ymin>464</ymin>
<xmax>1534</xmax>
<ymax>480</ymax>
</bndbox>
</object>
<object>
<name>Dian</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1473</xmin>
<ymin>441</ymin>
<xmax>1483</xmax>
<ymax>454</ymax>
</bndbox>
</object>
<object>
<name>Dian</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1338</xmin>
<ymin>426</ymin>
<xmax>1350</xmax>
<ymax>444</ymax>
</bndbox>
</object>
<object>
<name>Dian</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1298</xmin>
<ymin>530</ymin>
<xmax>1309</xmax>
<ymax>542</ymax>
</bndbox>
</object>
<object>
<name>Dian</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1296</xmin>
<ymin>428</ymin>
<xmax>1308</xmax>
<ymax>444</ymax>
</bndbox>
</object>
<object>
<name>Dian</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1236</xmin>
<ymin>445</ymin>
<xmax>1249</xmax>
<ymax>465</ymax>
</bndbox>
</object>
<object>
<name>Dian</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1185</xmin>
<ymin>444</ymin>
<xmax>1197</xmax>
<ymax>462</ymax>
</bndbox>
</object>
<object>
<name>Dian</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1176</xmin>
<ymin>499</ymin>
<xmax>1189</xmax>
<ymax>517</ymax>
</bndbox>
</object>
<object>
<name>Dian</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1093</xmin>
<ymin>497</ymin>
<xmax>1104</xmax>
<ymax>513</ymax>
</bndbox>
</object>
<object>
<name>Hei</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1135</xmin>
<ymin>529</ymin>
<xmax>1144</xmax>
<ymax>542</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1017</xmin>
<ymin>409</ymin>
<xmax>1027</xmax>
<ymax>421</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1092</xmin>
<ymin>524</ymin>
<xmax>1100</xmax>
<ymax>535</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1080</xmin>
<ymin>508</ymin>
<xmax>1089</xmax>
<ymax>518</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1100</xmin>
<ymin>436</ymin>
<xmax>1108</xmax>
<ymax>448</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1169</xmin>
<ymin>409</ymin>
<xmax>1177</xmax>
<ymax>420</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>969</xmin>
<ymin>519</ymin>
<xmax>979</xmax>
<ymax>535</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>946</xmin>
<ymin>408</ymin>
<xmax>956</xmax>
<ymax>418</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>957</xmin>
<ymin>436</ymin>
<xmax>970</xmax>
<ymax>448</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>894</xmin>
<ymin>402</ymin>
<xmax>904</xmax>
<ymax>415</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>887</xmin>
<ymin>468</ymin>
<xmax>897</xmax>
<ymax>481</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>904</xmin>
<ymin>510</ymin>
<xmax>920</xmax>
<ymax>521</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>784</xmin>
<ymin>502</ymin>
<xmax>795</xmax>
<ymax>518</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>803</xmin>
<ymin>449</ymin>
<xmax>818</xmax>
<ymax>463</ymax>
</bndbox>
</object>
<object>
<name>TuCeng</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>744</xmin>
<ymin>415</ymin>
<xmax>801</xmax>
<ymax>456</ymax>
</bndbox>
</object>
<object>
<name>TuCeng</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>738</xmin>
<ymin>482</ymin>
<xmax>752</xmax>
<ymax>507</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>692</xmin>
<ymin>474</ymin>
<xmax>705</xmax>
<ymax>486</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>704</xmin>
<ymin>512</ymin>
<xmax>716</xmax>
<ymax>525</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>687</xmin>
<ymin>521</ymin>
<xmax>695</xmax>
<ymax>532</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>694</xmin>
<ymin>537</ymin>
<xmax>702</xmax>
<ymax>546</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>620</xmin>
<ymin>424</ymin>
<xmax>632</xmax>
<ymax>437</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>615</xmin>
<ymin>459</ymin>
<xmax>623</xmax>
<ymax>472</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>509</xmin>
<ymin>438</ymin>
<xmax>521</xmax>
<ymax>455</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>427</xmin>
<ymin>497</ymin>
<xmax>440</xmax>
<ymax>508</ymax>
</bndbox>
</object>
<object>
<name>Dian</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>466</xmin>
<ymin>496</ymin>
<xmax>475</xmax>
<ymax>506</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>381</xmin>
<ymin>414</ymin>
<xmax>401</xmax>
<ymax>439</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>238</xmin>
<ymin>426</ymin>
<xmax>253</xmax>
<ymax>442</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>225</xmin>
<ymin>486</ymin>
<xmax>234</xmax>
<ymax>497</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>247</xmin>
<ymin>488</ymin>
<xmax>253</xmax>
<ymax>498</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>204</xmin>
<ymin>521</ymin>
<xmax>215</xmax>
<ymax>532</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>221</xmin>
<ymin>524</ymin>
<xmax>236</xmax>
<ymax>541</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>246</xmin>
<ymin>508</ymin>
<xmax>257</xmax>
<ymax>520</ymax>
</bndbox>
</object>
<object>
<name>TuCeng</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>318</xmin>
<ymin>463</ymin>
<xmax>335</xmax>
<ymax>485</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>327</xmin>
<ymin>526</ymin>
<xmax>340</xmax>
<ymax>540</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>293</xmin>
<ymin>528</ymin>
<xmax>309</xmax>
<ymax>544</ymax>
</bndbox>
</object>
<object>
<name>Hui</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>489</xmin>
<ymin>554</ymin>
<xmax>498</xmax>
<ymax>567</ymax>
</bndbox>
</object>
</annotation>
공유해 주셔서 감사합니다. 작은 문제가 발생했습니다.
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'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.