Home

Awesome

基于深度学习的2D虚拟试衣

项目介绍

本项目主要面向第 $14$ 届全国服务外包创新创业比赛 $A16$ 赛道虚拟试衣赛题,采用 $2D$ 虚拟试衣技术依托于 $VITON$ 开源数据集训练 $DNN$ 网络并着重进行工程化落地应用;项目选用了前沿顶刊论文的 $PFAFN$ 模型,在此基础上对模型进行优化改进,实现了模型压缩和推理加速并使用 $OpenVINO$ 框架进行部署应用,出色地完成了赛题的要求。

项目示例

项目开发环境

开发平台版本开发工具版本
Pycharm2022.3.2Visual Studio Code1.80.1
Visual Studio17.5.5
开发环境版本开发环境版本
neural-compressor2.2.1nncf2.5.0
numpy1.23.4onnx1.14.0
opencv-python4.7.0.72onnxruntime1.15.1
openvino2022.3.0pandas1.3.5
pytorch-fid0.3.0rembg2.0.50
pytorch2.0.0torch-pruning1.1.9
intel-openmp2021.4.0

环境配置

git clone https://github.com/LZHMS/Virtual-Tryon.git
pip install -r requirements.txt

项目文件介绍

本项目主要分为模型训练和工程化落地两部分,因此仓库创建了两个分支 mainPruingQuantization

模型结构介绍

本项目基于 $PFAFN$ 模型重新设计各个网络模块,具体结构如下图所示:

DNN网络结构

项目工程化落地

为了满足赛题方的要求,本项目开展了工程化落地部分,主要分为两个部分,模型训练和模型剪枝量化。项目工程化部署总图如下所示: 项目工程化部署总图

实验结果:通道剪枝

MetricsGFLOPsPara(M)SIZE(MB)Total SIZE(MB)Compresion RatioFIDFID Loss
Original Module6.639.3735.8112.0100.00%8.9060.00%
Ratio=0.2 with FineTuning5.237.2827.688.6979.19%9.0131.20%
Ratio=0.3 with FineTuning4.406.4824.865.7358.69%9.1132.32%
Ratio=0.4 with FineTuning3.795.6120.440.9736.58%9.3044.47%
Ratio=0.5 with FineTuning3.424.5516.835.4731.67%9.97712.03%
MetricsGFLOPsPara(M)SIZE(MB)Total SIZE(MB)Compresion RatioFIDFID Loss
Original Module21.9343.90167167100.00%8.9060.00%
Ratio=0.2 with FineTuning16.5435.02112.3112.367.25%9.2123.44%
Ratio=0.25 with FineTuning15.4531.9394.3994.3956.52%9.4055.60%
Ratio=0.3 with FineTuning13.9029.8980.2580.2548.05%9.6798.68%
Ratio=0.35 with FineTuning12.7827.3173.4973.4944.01%9.83510.43%
Ratio=0.4 with FineTuning11.2026.1268.5268.5241.03%10.52718.20%
ModelOriginal ModelSparsityPruned ModelFIDFPS
CWM112MB40%40.97MB9.5042.92
IGM167MB25%94.39MB9.5042.92

实验结果:量化感知训练

OptimizationCPU-FIDGPU-FIDOriginal ModelQuantized Model
Unquantized9.5049.483135.36MB135.36MB
Quantize CWM9.7839.70140.97MB10.85MB
Quantize IGM10.38210.24994.39MB24.10MB
Quantize CWM & IGM11.50311.379135.36MB34.95MB

实验结果:img2col 优化加速

RuntimesCorrTorch(s)Img2Col(s)FPSAcceleration Rate
n=1000147.849194.790210.811.5598
n=100001489.1325927.429310.771.6057
Average Time0.14880.02910.791.6017

参考文献