official code:GitHub - NVlabs/stylegan2-ada-pytorch: StyleGAN2-ADA - Official PyTorch implementation
运行过程中我出现了错误:
1、subprocess.CalledProcessError:Command '['ninja','-v']' returned non-zero exit status 1.:
注意最后一步一定要安装Install Visual Studio 2019里面的C++,其他的都默认不要选
2、训练时,卡在Setting up PyTorch plugin "filtered_lrelu_plugin"...不动时,删去C:\Users\ma_pe\AppData\Local\torch_extensions\torch_extensions\Cache\里的所有文件,并重新训练。
如果遇到RuntimeError:shape ‘[X, X, X, X, X]‘ is invalid for input of size XX,将batch_size设置为2的n次方。
3、页面文件太小,无法完成操作
把workers改小一点就行了
4、你需要修改VSCODE编译器的位置
def _find_compiler_bindir():
patterns = [
'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64',
]
for pattern in patterns:
matches = sorted(glob.glob(pattern))
if len(matches):
return matches[-1]
return None
出现的问题:
我在训练我自己的模型的时候出现了model collapse 问题(输出基本一样),然后我搜索相关的答案:
1)、It's fairly simple: absolute collapse is when all the outputs are exactly the same, irrespective of the input z
. If this happens, then there's no other option but to restart the training from zero. A more usual form of collapse is when there are several images being generated by G
, but they don't really differ by much. For example, this issue in StyleGAN2-ADA. Note that there is diversity in color, so the key there was to continue training to see if the model could get out of the collapse and that's exactly what happened (this is not always the case, but it's good to try).
我看答案说就是重新训练或者继续训练有可能会解决这个问题
使用预训练模型生成图像:
cifar10:
python generate.py --outdir=out --seeds=0-35 --class=1 --network=pretrained/cifar10.pkl
afhqcat:
python generate.py --outdir=out --seeds=0-35 --class=1 --network=pretrained/afhqcat.pkl
数据处理:
python dataset_tool.py --source=data/downloads/afhq/train/cat --dest=data/datasets/afhqcat.zip
可选操作:Scaled down 256x256 resolution.
python dataset_tool.py --source=data/downloads/afhq/train/cat --dest=data/datasets/afhqcat1.zip --width=256 --height=256
这里我来处理14万张 imageMol 图像为256*256:
python dataset_tool.py --source=D:\pycharm_workspace\1\ImageMol\datasets\pretraining\data\224 --dest=data/datasets/molecular.zip --width=256 --height=256 --max-images=140000
开始训练:
python train.py --outdir=data/training-runs --data=data/datasets/cifar10.zip
python train.py --outdir=data/training-runs --data=data/datasets/afhqcat.zip
训练14万张分子图像:
python train.py --outdir=data/training-runs --data=data/datasets/molecular.zip
option:是否断点续训?(resumes a previous training run.)
--resume=data/training-runs/<NAME>/network-snapshot-<INT>.pkl