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文件夹里。
本文介绍了在 CentOS 18.3 操作系统和 RTX 3090 显卡环境下,使用 PyTorch 1.8.1 和 CUDA 11.1 进行深度学习项目开发的过程。作者详细记录了遇到的两个常见错误及其解决方案,包括数据广播问题和视图尺寸不匹配问题。涵盖了从代码准备到模型训练、迁移和应用的完整步骤。
2643





