小工具,文件夹内容过大,只选取前N张图片。
import os
from shutil
import copy
i
= 0
save_dir
= 'E:/test'
if not os
.path
.isdir
(save_dir
):
os
.mkdir
(save_dir
)
file_path
= 'E:\dataset\VOC07+12\JPEGImages'
img_name
= os
.listdir
(file_path
)
img_name
.sort
()
for img
in img_name
:
img_path
= os
.path
.join
(file_path
, img
)
copy
(img_path
, save_dir
)
i
+= 1
if i
> 9:
break
转载请注明原文地址:https://blackberry.8miu.com/read-36008.html