-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxml_jpg_seg.py
24 lines (21 loc) · 977 Bytes
/
xml_jpg_seg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 原始数据xml文件和jpg文件是交叉混合在一起的,我们先将他们从
# D:\iqiyi\short_expose\labeled_20_9_25\labeled_20_9_25
# 分开到 D:\iqiyi\short_expose\labeled_20_9_25\prepared_20_9_25\annotations
# 和 D:\iqiyi\short_expose\labeled_20_9_25\prepared_20_9_25\jpgs
import os
import shutil
source = r'D:\iqiyi\short_expose\labeled_20_9_25\labeled_20_9_25'
ann_path = r'D:\iqiyi\short_expose\labeled_20_9_25\prepared_20_9_25\annotations'
jpg_path = r'D:\iqiyi\short_expose\labeled_20_9_25\prepared_20_9_25\jpgs'
xml_jpg = os.listdir(source)
for item in xml_jpg:
if item[-3:] == 'jpg':
filepath = os.path.join(source, item)
newfile = os.path.join(jpg_path, item)
shutil.copyfile(filepath, newfile)
elif item[-3:] == 'xml':
filepath = os.path.join(source, item)
newfile = os.path.join(ann_path, item)
shutil.copyfile(filepath, newfile)
else:
print("wrong logic")