macos上的硬盘检测工具_如何在MacOS上使用双镜头面部检测器(DSFD)实现90%以上的精度

macos上的硬盘检测工具

新程序员指南: (New Programmer’s Guide:)

介绍: (Introduction:)

This article is for those of us still early in our programming path — keep going

本文适用于尚处于编程道路初期的我们这些人-继续前进

If you’re still new to programming, I encourage you to complete this tutorial because DSFD is worth it and going through this process will stretch you.

如果您还不熟悉编程,建议您完成本教程,因为DSFD是值得的,并且逐步完成此过程将使您受益匪浅。

It’s intentionally thorough, so you should have everything you need.

这是有意为之的,因此您应该拥有所需的一切。

But if something isn’t covered, leave a comment and we’ll figure it out.

但是,如果未涵盖某些内容,请发表评论,我们会解决。

This article is written for MacOS, but it’s also available for Windows.

本文是针对MacOS编写的,但也适用于Windows 。

背景: (Background:)

In this paper, Tencent introduces its open-sourced Dual Shot Face Detector (DSFD) algorithm. DSFD is a new face detection network that addresses three key areas of facial detection. This includes better feature learning, progressive loss design, and anchor assign based data augmentation.

在本文中 ,腾讯介绍了其开源的双镜头面部检测器 (DSFD)算法。 DSFD是一个新的面部检测网络 ,解决了面部检测的三个关键领域。 这包括更好的功能学习,渐进式损失设计以及基于锚分配的数据扩充。

In 2018, the DSFD algorithm ranked first across the board in the WIDER FACE Face Detection Benchmark.

在2018年,DSFD算法在WIDER FACE人脸检测基准测试中全面排名第一。

macos上的硬盘检测工具_如何在MacOS上使用双镜头面部检测器(DSFD)实现90%以上的精度_第1张图片
DSFD DSFD提供

The benchmark evaluation tested the detection systems for mean average precision (mAP) on set portions of the dataset split into three difficulty levels.

基准评估测试了检测系统在分为三个难度级别的数据集的设置部分的平均平均精度 (mAP)。

Validation set scores:

验证集分数:

  • 96.6% (mAP) in the easy difficulty level

    轻松难度水平为96.6%(mAP)
  • 95.7% (mAP) in the medium difficulty level

    中难度水平为95.7%(mAP)
  • 90.4% (mAP) in the hard difficulty level

    困难难度等级为90.4%(mAP)

Test set scores:

测试集分数:

  • 96.0% (mAP) in the easy difficulty level

    轻松难度水平为96.0%(mAP)
  • 95.3% (mAP) in the medium difficulty level

    中难度水平为95.3%(mAP)
  • 90.0% (mAP) in the hard difficulty level

    困难难度等级为90.0%(mAP)

In this paper, the Multitask Cascade CNN (MTCNN) was evaluated using the same WIDER FACE Face Detection Benchmark.

本文使用相同的WIDER FACE人脸检测基准对多任务级联CNN(MTCNN)进行了评估。

Validation set scores:

验证集分数:

  • 84.8% (mAP) in the easy difficulty level

    轻松难度水平为84.8%(mAP)
  • 82.5% (mAP) in the medium difficulty level

    中难度水平为82.5%(mAP)
  • 60.7% (mAP) in the hard difficulty level

    困难难度水平为60.7%(mAP)

Test set scores:

测试集分数:

  • 85.1% (mAP) in the easy difficulty level

    轻松难度水平为85.1%(mAP)
  • 82.0% (mAP) in the medium difficulty level

    中难度水平为82.0%(mAP)
  • 60.7% (mAP) in the hard difficulty level

    困难难度水平为60.7%(mAP)

克隆存储库: (Clone the Repository:)

First, we’ll open Terminal:

首先,我们打开终端:

  1. Press “Command ⌘”

    按“ Command⌘”
  2. Enter “Terminal”

    输入“终端”
  3. Press “Return”

    按“返回”

Next, we’ll use the mkdir command to create the project directory:

接下来,我们将使用mkdir命令创建项目目录:

  1. Copy the command from below these instructions

    从这些说明下面复制命令
  2. Paste the command into Terminal

    将命令粘贴到终端
  3. Press “Return”

    按“返回”
mkdir $HOME/Desktop/Projects/

Next, we’ll use the cd command to navigate to the project directory:

接下来,我们将使用cd命令导航到项目目录:

  1. Copy the command from below these instructions

    从这些说明下面复制命令
  2. Paste the command into Terminal

    将命令粘贴到终端
  3. Press “Return”

    按“返回”
cd $HOME/Desktop/Projects/

Next, we’ll use the git clone command to download the repository:

接下来,我们将使用git clone命令下载存储库:

  1. Copy the command from below these instructions

    从这些说明下面复制命令
  2. Paste the command into Terminal

    将命令粘贴到终端
  3. Press “Return”

    按“返回”
git clone https://github.com/Tencent/FaceDetection-DSFD

Next, we’ll use the cd command to navigate to the repository directory:

接下来,我们将使用cd命令导航到存储库目录:

  1. Copy the command from below these instructions

    从这些说明下面复制命令
  2. Paste the command into Terminal

    将命令粘贴到终端
  3. Press “Return”

    按“返回”
cd FaceDetection-DSFD

设置Python要求: (Set Up the Python Requirement:)

First, we’ll download Python 3.6:

首先,我们将下载Python 3.6:

  1. Visit the download page on the official website

    访问官方网站上的下载页面

  2. Scroll to the “Files” section

    滚动到“文件”部分
  3. Download the “MacOS 64-Bit/32-Bit Installer”

    下载“ MacOS 64位/ 32位安装程序”

Next, we’ll install the required Python version:

接下来,我们将安装所需的Python版本:

  1. Open the downloaded file

    打开下载的文件
  2. Perform the default installation

    执行默认安装

创建虚拟环境: (Create the Virtual Environment:)

The virtualenv command creates a virtual environment with the specified Python version. The command format is command name, Python parameter, Python executable file, virtual environment name.

virtualenv命令使用指定的Python版本创建虚拟环境。 命令格式为命令名称,Python参数,Python可执行文件,虚拟环境名称。

First, we’ll install virtualenv:

首先,我们将安装virtualenv:

  1. Reopen Terminal

    重新打开终端
  2. Copy the command from below these instructions

    从这些说明下面复制命令
  3. Paste the command into Terminal

    将命令粘贴到终端
  4. Press “Return”

    按“返回”
python -m pip install virtualenv

Next, we’ll create the virtual environment with Python 3.6:

接下来,我们将使用Python 3.6创建虚拟环境:

  1. Copy the command from below these instructions

    从这些说明下面复制命令
  2. Paste the command into Terminal

    将命令粘贴到终端
  3. Press “Return”

    按“返回”
virtualenv -p python36 venv36

Next, we’re going to activate the virtual environment:

接下来,我们将激活虚拟环境:

  1. Copy the command from below these instructions

    从这些说明下面复制命令
  2. Paste the command into Terminal

    将命令粘贴到终端
  3. Press “Return”

    按“返回”

The virtual environment name will appear on the command-line while active.

虚拟环境名称在活动时将显示在命令行上。

All pip installations will now be saved in the local virtual environment.

现在,所有pip安装都将保存在本地虚拟环境中。

source venv36/bin/activate

设置火炬要求: (Set Up the Torch Requirement:)

First, we’ll download Torch 0.3.1:

首先,我们将下载Torch 0.3.1:

  1. Visit the download page for your Cuda version: [Cpu Only]

    访问您的Cuda版本的下载页面:[ 仅Cpu ]

  2. Scroll to the wheel file from below these instructions

    从这些说明下面滚动到wheel文件
  3. Click the link to download the file

    点击链接下载文件

The Torch version required isn’t available in pip or anaconda.

所需的Torch版本在pip或anaconda中不可用。

torch-0.3.1-cp36-cp36m-macosx_10_7_x86_64.whl

Next, we’ll use the mouse to move the wheel file:

接下来,我们将使用鼠标移动wheel文件:

  1. Open Finder

    打开查找器
  2. Click “Downloads” in the left panel

    点击左侧面板中的“下载”
  3. Scroll to the file from below these instructions

    从这些说明下面滚动到文件
  4. Right-click the provided file

    右键单击提供的文件
  5. Click “Copy”

    点击“复制”
  6. Navigate to the repository directory

    导航到存储库目录
  7. Right-click inside the directory

    在目录内右键单击
  8. Press and Hold “Option⌥”

    按住“Option⌥”
  9. Click “Move Item Here”

    点击“在此处移动项目”
  10. Release “Option ⌥”

    释放“选项⌥”
torch-0.3.1-cp36-cp36m-macosx_10_7_x86_64.whl

Lastly, we’ll install Torch:

最后,我们将安装Torch:

  1. Reopen Terminal

    重新打开终端
  2. Copy the command from below these instructions

    从这些说明下面复制命令
  3. Paste the command into Terminal

    将命令粘贴到终端
  4. Press “Return”

    按“返回”
pip install torch-0.3.1-cp36-cp36m-macosx_10_7_x86_64.whl

设置TorchVision要求: (Set Up the TorchVision Requirement:)

First, we’ll download Torchvision 0.2.1:

首先,我们将下载Torchvision 0.2.1:

  1. Visit the archive page for your system type: [All]

    访问存档页面以查找您的系统类型:[ 全部 ]

  2. Scroll to the wheel file from below these instructions

    从这些说明下面滚动到wheel文件
  3. Click the link to download the file

    点击链接下载文件

The TorchVision version required isn’t available in pip or anaconda.

所需的TorchVision版本在pip或anaconda中不可用。

torchvision-0.2.1-py2.py3-none-any.whl

Next, we’ll use the mouse to move the wheel file:

接下来,我们将使用鼠标移动wheel文件:

  1. Reopen Finder

    重新开启搜寻器
  2. Click “Downloads” in the left panel

    点击左侧面板中的“下载”
  3. Scroll to the file from below these instructions

    从这些说明下面滚动到文件
  4. Right-click the provided file

    右键单击提供的文件
  5. Click “Copy”

    点击“复制”
  6. Navigate to the repository directory

    导航到存储库目录
  7. Right-click inside the directory

    在目录内右键单击
  8. Press and Hold “Option⌥”

    按住“Option⌥”
  9. Click “Move Item Here”

    点击“在此处移动项目”
  10. Release “Option ⌥”

    释放“选项⌥”
torchvision-0.2.1-py2.py3-none-any.whl

Lastly, we’ll install Torchvision:

最后,我们将安装Torchvision:

  1. Reopen Terminal

    重新打开终端
  2. Copy the command from below these instructions

    从这些说明下面复制命令
  3. Paste the command into Terminal

    将命令粘贴到终端
  4. Press “Return”

    按“返回”
pip install torchvision-0.2.1-py2.py3-none-any.whl

设置其他要求: (Set Up the Other Requirements:)

First, we’ll install the other requirements:

首先,我们将安装其他要求:

  1. Reopen Terminal

    重新打开终端
  2. Copy the command from below these instructions

    从这些说明下面复制命令
  3. Paste the command into Terminal

    将命令粘贴到终端
  4. Press “Return”

    按“返回”
pip install matplotlib opencv-python scipy

Next, we’ll use the mkdir command to create a subdirectory:

接下来,我们将使用mkdir命令创建一个子目录:

  1. Reopen Terminal

    重新打开终端
  2. Copy the command from below these instructions

    从这些说明下面复制命令
  3. Paste the command into Terminal

    将命令粘贴到终端
  4. Press “Return”

    按“返回”

This subdirectory is used to store the output images.

该子目录用于存储输出图像。

mkdir eval_tools

设置模型: (Set Up the Model:)

First, we’ll download the model file:

首先,我们将下载模型文件:

  1. Visit the DSFD Google Drive

    访问DSFD Google云端硬盘

  2. Click the “Download” button

    点击“下载”按钮
  3. Click the “Download anyway” button

    点击“仍然下载”按钮

Next, we’ll use the mkdir command to create a subdirectory:

接下来,我们将使用mkdir命令创建一个子目录:

  1. Reopen Terminal

    重新打开终端
  2. Copy the command from below these instructions

    从这些说明下面复制命令
  3. Paste the command into Terminal

    将命令粘贴到终端
  4. Press “Return”

    按“返回”
mkdir weights 

Next, we’ll use the mouse to move the model file:

接下来,我们将使用鼠标移动模型文件:

  1. Reopen Finder

    重新开启搜寻器
  2. Click “Downloads” in the left panel

    点击左侧面板中的“下载”
  3. Scroll to the file from below these instructions

    从这些说明下面滚动到文件
  4. Right-click the provided file

    右键单击提供的文件
  5. Click “Copy”

    点击“复制”
  6. Navigate to the repository directory

    导航到存储库目录
  7. Open the “weights” subdirectory

    打开“ weights”子目录
  8. Right-click inside the directory

    在目录内右键单击
  9. Press and Hold “Option⌥”

    按住“Option⌥”
  10. Click “Move Item Here”

    点击“在此处移动项目”
  11. Release “Option ⌥”

    释放“选项⌥”
WIDERFace_DSFD_RES152.pth

设置注释: (Set Up the Annotations:)

First, we’ll download the annotations file:

首先,我们将下载注释文件:

  1. Visit the WIDER FACE official site

    访问WIDER FACE 官方网站

  2. Scroll to the “Download” section

    滚动到“下载”部分
  3. Click “Face Annotations”

    点击“面部注释”

Next, we’ll use the mouse to move the annotations file:

接下来,我们将使用鼠标移动注释文件:

  1. Reopen Finder

    重新开启搜寻器
  2. Click “Downloads” in the left panel

    点击左侧面板中的“下载”
  3. Scroll to the file from below these instructions

    从这些说明下面滚动到文件
  4. Right-click the provided file

    右键单击提供的文件
  5. Click “Copy”

    点击“复制”
  6. Navigate to the repository directory in Finder

    导航到Finder中的存储库目录
  7. Open the “data” subdirectory

    打开“数据”子目录
  8. Right-click inside the directory

    在目录内右键单击
  9. Press and Hold “Option⌥”

    按住“Option⌥”
  10. Click “Move Item Here”

    点击“在此处移动项目”
  11. Release “Option ⌥”

    释放“选项⌥”
wider_face_split.zip

Lastly, we’ll unzip the annotations file:

最后,我们将解压注释文件:

  1. Click the “Back” button in Finder

    点击Finder中的“返回”按钮
  2. Right-click the file from below these instructions

    从这些说明下面右键单击文件
  3. Click “Open”

    点击“打开”
wider_face_split.zip

修正错误: (Fix the Errors:)

The following solutions were pieced together by:

以下解决方案组合在一起:

  • Reading through the “open” and “closed” issues section of the repository

    通读存储库的“ 打开 ”和“ 关闭 ”问题部分

  • Translating different languages with Google Translate extension

    使用Google翻译扩展程序翻译不同的语言

  • Googling the error message and reading through the first five results

    搜寻错误讯息并读取前五个结果

The line numbers are not exact and meant to be used as approximations.

行号不精确,只能用作近似值。

错误1: (Error #1:)

UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` instead

UserWarning:volatile已删除,现在无效。 使用`with torch.no_grad():`代替

In this section, we’ll add edit to the following files:

在本节中,我们将对以下文件添加编辑:

  • demo.py

    演示
  • face_ssd.py

    face_ssd.py
  • widerface_val.py

    wideface_val.py

错误2: (Error #2:)

RuntimeError: CUDA out of memory. Tried to allocate 44.25 MiB (GPU 0; 11.00 GiB total capacity; 9.56 GiB already allocated; 10.25 MiB free; 49.26 MiB cached)

RuntimeError:CUDA内存不足。 尝试分配44.25 MiB(GPU 0; 11.00 GiB总容量;已分配9.56 GiB; 10.25 MiB空闲; 49.26 MiB已缓存)

In this section, we’ll add edit to the following file:

在本节中,我们将编辑添加到以下文件:

  • demo.py

    演示

错误3: (Error #3:)

FileNotFoundError: [Errno 2] No such file or directory: ‘/data2/lijian/widerface/data/wider_face_split\\wider_face_val.mat’

FileNotFoundError:[错误2]没有这样的文件或目录:'/data2/lijian/widerface/data/wider_face_split\\wider_face_val.mat'

In this section, we’ll edit the following file :

在本节中,我们将编辑以下文件:

  • data\widerface.py

    数据\ widerface.py

错误4: (Error #4:)

ImportError: cannot import name ‘pa_sfd_match’

ImportError:无法导入名称“ pa_sfd_match”

In this section, we’ll edit the following file:

在本节中,我们将编辑以下文件:

  • layers\modules\multibox_loss.py

    图层\模块\ multibox_loss.py

错误5: (Error #5:)

TypeError: mul(): argument ‘other’ (position 1) must be Tensor, not numpy.ndarray

TypeError:mul():参数'other'(位置1)必须为Tensor,而不是numpy.ndarray

In this section, we’ll edit to the following file:

在本节中,我们将编辑以下文件:

  • demo.py

    演示

错误#6: (Error #6:)

RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=’cpu’ to map your storages to the CPU.

RuntimeError:尝试在CUDA设备上反序列化对象,但是torch.cuda.is_available()为False。 如果您在仅CPU的计算机上运行,​​请使用带有map_location ='cpu'的torch.load将存储映射到CPU。

This step only applies to computers that don’t have a GPU — CPU only.

此步骤仅适用于没有GPU的计算机-仅适用于CPU。

In this section, we’ll change edit the following file:

在本节中,我们将更改编辑以下文件:

  • venv36/lib/python3.6/site-packages/torch/serialization.py

    venv36 / lib / python3.6 / site-packages / torch / serialization.py

错误7: (Error #7:)

AssertionError: Torch not compiled with CUDA enabled.

AssertionError:火炬未在启用CUDA的情况下编译。

This step only applies to computers that don’t have a GPU — CPU only.

此步骤仅适用于没有GPU的计算机-仅适用于CPU。

In this section, we’ll edit in the following files:

在本节中,我们将编辑以下文件:

  • demo.py

    演示
  • widerface_val.py

    wideface_val.py

错误#8: (Error #8:)

UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details. “See the documentation of nn.Upsample for details.”.format(mode))

UserWarning:自0.4.0开始,当mode = bilinear更改为align_corners = False时,默认的上采样行为。 如果需要旧的行为,请指定align_corners = True。 有关详细信息,请参见nn.Upsample的文档。 “有关详细信息,请参见nn.Upsample的文档。”。format(mode))

Lastly, we’ll edit the following file:

最后,我们将编辑以下文件:

  • demo.py

    演示

获取命令行参数: (Get the Command-Line Parameters:)

Sometimes, the command-line parameters are not included in a repository’s description. In that case, the parameters can usually be found underneath the import section in the code file.

有时,命令行参数未包含在存储库的描述中。 在这种情况下,通常可以在代码文件的import部分下面找到参数。

Check the Add Argument method:

检查添加参数方法:

  • The first argument is the parameter.

    第一个参数是参数。
  • The last argument describes what it does

    最后一个参数描述了它的作用

For example:

例如:

  • “ — image_root” refers to the “location of test image directory”

    “ — image_root”是指“测试图像目录的位置”
  • “ — visual_threshold” refers to the “final confidence threshold”

    “ — visual_threshold”是指“最终置信度阈值”
demo.py:
parser = argparse.ArgumentParser(description='DSFD:Dual Shot Face Detector')
parser.add_argument('--trained_model', default='weights/WIDERFace_DSFD_RES152.pth',
type=str, help='Trained state_dict file path to open')
parser.add_argument('--save_folder', default='eval_tools/', type=str,
help='Dir to save results')
parser.add_argument('--visual_threshold', default=0.1, type=float,
help='Final confidence threshold')
parser.add_argument('--cuda', default=False, type=bool,
help='Use cuda to train model')
parser.add_argument('--img_root', default='./data/worlds-largest-selfie.jpg', help='Location of test images directory')
parser.add_argument('--widerface_root', default=WIDERFace_ROOT, help='Location of WIDERFACE root directory')
args = parser.parse_args()

测试演示 (Test the Demo)

In this section, we’ll test the demo.py file:

在本节中,我们将测试demo.py文件:

  1. Reopen Command Prompt

    重新打开命令提示符
  2. Copy the command from below these instructions

    从这些说明下面复制命令
  3. Paste the command into Command Prompt

    将命令粘贴到命令提示符中
  4. Press “Enter”

    按“ Enter”
python demo.py --img_root ./data/worlds-largest-selfie.jpg --visual_threshold 0.7

停用虚拟环境: (Deactivate the Virtual Environment:)

In this section, we’ll deactivate the virtual environment:

在本节中,我们将停用虚拟环境:

  1. Copy the command from below these instructions

    从这些说明下面复制命令
  2. Paste the command into Command Prompt

    将命令粘贴到命令提示符中
  3. Press “Enter”

    按“ Enter”

The virtual environment name will then disappear from the command-line.

然后,虚拟环境名称将从命令行中消失。

All pip installations will now be saved in the regular Python environment.

现在,所有pip安装都将保存在常规Python环境中。

deactivate

致谢: (Acknowledgments:)

@oyerst solved this issue

@ oyerst解决了这个问题

@hypadr1v3 solved this issue

@ hypadr1v3解决了这个问题

@lijiannuist solved this issue and that issue

@ lijiannuist解决了这个问题和那个问题

@vlad3996 solved this issue

@ vlad3996解决了这个问题

@yihongXU solved this issue

@yihongXU解决了这个问题

翻译自: https://medium.com/macoclock/how-to-implement-the-dual-shot-face-detector-dsfd-demo-on-macos-706dde217ead

macos上的硬盘检测工具

你可能感兴趣的:(macos上的硬盘检测工具_如何在MacOS上使用双镜头面部检测器(DSFD)实现90%以上的精度)