# safe-maoer **Repository Path**: jian.yang/safe-maoer ## Basic Information - **Project Name**: safe-maoer - **Description**: safe maoer - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2018-12-28 - **Last Updated**: 2020-12-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Safety Cap in Pytorch This repo is forked from [pytorch-ssd](https://github.com/qfgaohao/pytorch-ssd). - [x] we use MobileNetV2 as basenet,Image input size is 300x300 - [x] convert to ncnn - [x] rebuild a valid test set - [ ] optimize training process for higher accuracy - [x] optimize network structure, including anchor, conv layers and conventient transplantation #### Face with safety cap ![Example of face with safety cap](eval_results/face_with_cap1.png) ![Example of face with safety cap](eval_results/face_with_cap2.png) #### Face without safety cap ![Example of face without safety cap](eval_results/face_witouth_cap.png) #### Attack Samples ![Example of attack samples](eval_results/face_attack_cap1.png) ![Example of attack samples](eval_results/face_attack_cap2.png) ## Dependencies 1. Python 3.6+ 2. OpenCV 3. Pytorch 0.4+ 4. Caffe2 5. Pandas ## Dataset > generate_onlyface.py # 生成仅仅为人脸的样本,图像会被放在Images/00里 > parse_from_video.py # video里面是攻击性质的样本,图像会被放在Images/02里 > helmet_safemao.py # 里面是一个比赛的安全帽数据集,然后通过中心裁剪生成新样本,图像被放在Image/03里 > generate_safemao.py # 安全帽有标注的时候才能使用该脚本 > split_train_test.py # 用42的随机种子分割训练集和测试集,生成trainval.txt和test.txt两个路径文件 ## Train > train_ssd.py #train file ## Test > eval_ssd.py # evaluation file,评估精度 > test_single.py # 直接测试某个文件夹里的图像,并进行可视化 ### 部署 详细见 > PytorchConverter/cvt_anquanmao.py > PytorchConverter/ssd > PytorchConverter/safety_cap.cpp 注意在训练的时候要使用pytorch0.4以上,部署转换模型的时候要用pytorch0.2 #### 2019-1-14 - 通过PytorchConverter转换了SSD模型,但因为pytoch0.2和0.4兼容性的问题,用relu代替relu6。另外softmax是二维形式的, 虽然可以转换,但使用的时候有问题,因此参考pytorch C源码和NCNN源码,用C++重新写了这个层,还有一些后处理的部分。精度保 持在小数点后3位以上,精损不大,可以直接使用。 #### 2019-1-15上午 - 程序还存在一些内存bug,地址冲突,目前还没查明原因 - 优化softmax,nms,后处理在i5-8500上在1ms左右,速度还不错,当前300*300的mobileNetV2SSD在3288上平均在800+-200ms 接下来优化SSD网络,主要是从输入尺度,anchor尺度进行优化 #### 2019-1-15下午 - 缩小尺寸到150x150,修改了anchor和deploy的一些兼容性问题,在3288上测试时间到150ms+-50ms,基本可以接受, #### 2019-2-14 - 增加了helmet数据集 还没有改channel和layer