2023-05-30 01:25:04 +08:00

24 lines
610 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import os
# 第一步。对目录环境进行检查,是否满足处理要求
def file_exists(filename, message):
if not os.path.exists(filename):
raise FileExistsError(message)
def make_dirs(dirs):
try:
os.makedirs(dirs)
except FileExistsError:
print(dirs + ' 目录存在,自动跳过')
# 第二步。创建关键目录
file_exists('Annotations', 'VOC标注Annotations目录不存在')
file_exists('JPEGImages', 'VOC标注JPEGImages 图片目录不存在')
make_dirs('images/train')
make_dirs('images/val')
make_dirs('labels/train')
make_dirs('labels/val')