疫情期间佩戴口罩检测之训练检测口罩模型算法实现口罩检测步骤以及报错解决
source link: https://blog.51cto.com/u_15702547/5429343
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
疫情期间佩戴口罩检测之训练检测口罩模型算法实现口罩检测步骤以及报错解决
原创训练检测口罩模型
https://github.com/Megvii-BaseDetection/YOLOX
pip install -r requirements.txt
pip install -c esri pycocotools
第一步下载数据集
在datasets文件夹下新建VOCdevkit文件夹并将下载的data文件夹放进去,并改名为VOC2020。 在VOC2020文件夹下新建ImageSets文件夹,在建Main文件夹。
下载make_train_and_test.py文件并运行
import random
train_percent = 0.8
test_percent = 0.2
xmlfilepath = 'VOCdevkit/VOC2020/Annotations'
txtsavepath = 'VOCdevkit/VOC2020/ImageSets'
total_xml = os.listdir(xmlfilepath)
num = len(total_xml)
list = range(num)
tr = int(num * train_percent)
te = int(num * test_percent)
train = random.sample(list, tr)
test = random.sample(list, te)
ftest = open('VOCdevkit/VOC2020/ImageSets/Main/test.txt', 'w')
ftrain = open('VOCdevkit/VOC2020/ImageSets/Main/train.txt', 'w')
for i in list:
name = total_xml[i][:-4] + '\n'
if i in train:
ftrain.write(name)
else:
ftest.write(name)
ftrain.close()
ftest.close()
生成训练样本和测试样本的下标
第二步修改代码
yolox_voc_s.py相关代码改为
voc_classea.pu改为
"no_masked",
"masked",
)
voc.py修改
python tools/train.py -f ./exps/example/yolox_voc/yolox_voc_s.py -d 1 -b 4 --fp 16 -o
会报错 Traceback (most recent call last): File "./tools/train.py", line 13, in <module> from yolox.core import launch ModuleNotFoundError: No module named 'yolox'
路径错误 在tools/train.py开头加上开头路径
sys.path.append(r"D:\PycharmProjects\YOLOX-main")
报错 DataLoader worker
yolox_voc_s.py添加
报错OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.
环境冲突 tools/train.py添加代码
os.environ['KMP_DUPLICATE_LIB_OK'] = 'True'
报错 ERROR | yolox.core.launch:98 - An error has been caught in function 'launch', process 'MainProcess' (22360), thread 'MainThread' (18700):
修改 voc.py
- 1赞
- 收藏
- 评论
- 分享
- 举报
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK