[Pytorch系列-66]:生成对抗网络GAN - 图像生成开源项目pytorch-CycleGAN-and-pix2pix - 使用预训练模型测试pix2pix模型
win 10
打开Anaconda Prompt (Anaconda3)
激活环境
activate yolov5_tpz
切换到d盘
输入: d:
切换到 D:\tpz\the-third-paper\pytorch-CycleGAN-and-pix2pix-master
输入: cd D:\tpz\the-third-paper\pytorch-CycleGAN-and-pix2pix-master
运行命令
输入:
python test.py --dataroot ./datasets/facades --direction BtoA --model pix2pix --name facades_label2photo_pretrained
运行效果
----------------- Options ---------------
aspect_ratio: 1.0
batch_size: 1
checkpoints_dir: ./checkpoints
crop_size: 256
dataroot: ./datasets/facades [default: None]
dataset_mode: aligned
direction: BtoA [default: AtoB]
display_winsize: 256
epoch: latest
eval: False
gpu_ids: 0
init_gain: 0.02
init_type: normal
input_nc: 3
isTrain: False [default: None]
load_iter: 0 [default: 0]
load_size: 256
max_dataset_size: inf
model: pix2pix [default: test]
n_layers_D: 3
name: facades_label2photo_pretrained [default: experiment_name]
ndf: 64
netD: basic
netG: unet_256
ngf: 64
no_dropout: False
no_flip: False
norm: batch
num_test: 50
num_threads: 4
output_nc: 3
phase: test
preprocess: resize_and_crop
results_dir: ./results/
serial_batches: False
suffix:
use_wandb: False
verbose: False
----------------- End -------------------
dataset [AlignedDataset] was created
initialize network with normal
model [Pix2PixModel] was created
loading the model from ./checkpoints\facades_label2photo_pretrained\latest_net_G.pth
---------- Networks initialized -------------
[Network G] Total number of parameters : 54.414 M
-----------------------------------------------
creating web directory ./results/facades_label2photo_pretrained\test_latest
D:\Anaconda3\envs\yolov5_tpz\lib\site-packages\torchvision\transforms\transforms.py:280: UserWarning: Argument interpolation should be of type InterpolationMode instead of int. Please, use InterpolationMode enum.
warnings.warn(
processing (0000)-th image... ['./datasets/facades\\test\\1.jpg']
processing (0005)-th image... ['./datasets/facades\\test\\103.jpg']
processing (0010)-th image... ['./datasets/facades\\test\\12.jpg']
processing (0015)-th image... ['./datasets/facades\\test\\17.jpg']
processing (0020)-th image... ['./datasets/facades\\test\\21.jpg']
processing (0025)-th image... ['./datasets/facades\\test\\26.jpg']
processing (0030)-th image... ['./datasets/facades\\test\\30.jpg']
processing (0035)-th image... ['./datasets/facades\\test\\35.jpg']
processing (0040)-th image... ['./datasets/facades\\test\\4.jpg']
processing (0045)-th image... ['./datasets/facades\\test\\44.jpg']
parser.add_argument('--dataroot', default='datasets/facades', help='path to images (should have subfolders trainA, trainB, valA, valB, etc)')
parser.add_argument('--name', type=str, default='facades_label2photo_pretrained', help='name of the experiment. It decides where to store samples and models')
parser.add_argument('--model', type=str, default='pix2pix', help='chooses which model to use. [cycle_gan | pix2pix | test | colorization]')
parser.add_argument('--direction', type=str, default='BtoA', help='AtoB or BtoA')
parser.set_defaults(model='pix2pix')
注意:
如果不将 parser.set_defaults(model='test ') 更改为 parser.set_defaults(model=‘pix2pix’),将会出现以下错误:
AttributeError: ‘Sequential’ object has no attribute ‘model’
解决方案参考