1. 硬件环境
操作系统:CentOS 18.3
显卡:RTX 3090
2. 软件环境
Pytorch版本:1.8.1
PyTorch的CUDA版本:11.1
3. 代码/数据准备
代码获取:代码gitHub地址
数据获取:数据网盘地址 提取码: 8aum
pair.txt获取:txt网盘地址 提取码:poma
4. 报错处理
(1)报错1:RuntimeError: output with shape [1,256,192] doesn't match the broadcast shape [3,256,192]
解决方法:修改dataset.py 第23行代码。
修改前:
修改后:
(2)报错2:RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(.. .) instead. 
解决方法:修改networks.py第93行代码。
修改前:
修改后:
5. 运行过程
(1)运行train_gmm.py
$ python train_gmm.py
会生成训练中保存的图形,会发现慢慢趋于拟合,以及epoch的模型文件pth。
(2)运行run_gmm.py
$ python run_gmm.py
然后运行结束后会在data /train 和test 或者val中各添加两个拟合,与掩码图片(wrap-cloth、wrap-cloth-mask):
(3)运行 train_tom.py
$ python train_tom.py
运行此文件需要一个VGG19的模型,运行的时候会自动下载
运行结束后会在…/result/TOM下生成模型pth
(4)运行run_tom.py
$ python run_tom.py
text_paris.txt文件中,第一列是人物照片,第二列是衣服照片,运行次pyhotn代码后,会将结果保存在data/test/tryon-person文件夹里。