pix2pix学习系列(1):预训练模型测试pix2pix

参考文献:

[Pytorch系列-66]:生成对抗网络GAN - 图像生成开源项目pytorch-CycleGAN-and-pix2pix - 使用预训练模型测试pix2pix模型

运行环境

win 10

1、代码下载

Github

2、下载pix2pix数据集

  • 通过URL手工下载:地址

  • 存放路径:pytorch-CycleGAN-and-pix2pix\datasets

3、下载预训练模型

  • 下载链接
  • 存放路径
    需要把模型的名称改为latest_net_G.pth,并存放在./checkpoints/facades_label2photo_pretrained目录中。

4. 使用Anaconda进行调试

  • 打开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.0batch_size: 1checkpoints_dir: ./checkpointscrop_size: 256dataroot: ./datasets/facades                   [default: None]dataset_mode: aligneddirection: BtoA                                 [default: AtoB]display_winsize: 256epoch: latesteval: Falsegpu_ids: 0init_gain: 0.02init_type: normalinput_nc: 3isTrain: False                                [default: None]load_iter: 0                                    [default: 0]load_size: 256max_dataset_size: infmodel: pix2pix                              [default: test]n_layers_D: 3name: facades_label2photo_pretrained       [default: experiment_name]ndf: 64netD: basicnetG: unet_256ngf: 64no_dropout: Falseno_flip: Falsenorm: batchnum_test: 50num_threads: 4output_nc: 3phase: testpreprocess: resize_and_cropresults_dir: ./results/serial_batches: Falsesuffix:use_wandb: Falseverbose: 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']
  • 查看结果
    图片位置: \results\facades_label2photo_pretrained\test_latest\images

5. 也可以使用pycharm进行调试

  • 设置 options/base_options.py
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')
  • 设置 options/test_options.py
parser.set_defaults(model='pix2pix')

注意:
如果不将 parser.set_defaults(model='test ') 更改为 parser.set_defaults(model=‘pix2pix’),将会出现以下错误:
AttributeError: ‘Sequential’ object has no attribute ‘model’

解决方案参考

  • 运行 test.py

pix2pix学习系列(1):预训练模型测试pix2pix相关推荐

  1. 深度学习之openvino预训练模型测试(车牌识别)

    0 背景 在上一篇文章<深度学习之openvino预训练模型测试>,我们介绍了如何使用 intel 提供的预训练模型完成语义分割任务.但在用 public 预训练模型时,发现我的 open ...

  2. 深度学习之openvino预训练模型测试

    0 背景 在<深度学习之win10安装配置openvino>中我们介绍了 openvino 的安装方法,本文对下一步的使用进行一个介绍. 1 模型介绍 openvino 提供了一系列的预训 ...

  3. [Pytorch系列-66]:生成对抗网络GAN - 图像生成开源项目pytorch-CycleGAN-and-pix2pix - 使用预训练模型测试pix2pix模型

    作者主页(文火冰糖的硅基工坊):文火冰糖(王文兵)的博客_文火冰糖的硅基工坊_CSDN博客 本文网址:https://blog.csdn.net/HiWangWenBing/article/detai ...

  4. 多模态模型学习1——CLIP对比学习 语言-图像预训练模型

    多模态模型学习1--CLIP对比学习 语言-图像预训练模型 学习前言 什么是CLIP模型 代码下载 CLIP实现思路 一.网络结构介绍 1.Image Encoder a.Patch+Position ...

  5. 深度学习进阶篇-预训练模型[3]:XLNet、BERT、GPT,ELMO的区别优缺点,模型框架、一些Trick、Transformer Encoder等原理详细讲解

    [深度学习入门到进阶]必看系列,含激活函数.优化策略.损失函数.模型调优.归一化算法.卷积模型.序列模型.预训练模型.对抗神经网络等 专栏详细介绍:[深度学习入门到进阶]必看系列,含激活函数.优化策略 ...

  6. python与机器学习(七)下——torchvision预训练模型测试真实图像分类

    任务要求:利用torchvision中的预训练CNN模型来对真实的图像进行分类,预测每张图片的top5类别. 数据: real_image, class_index.json 导入: import t ...

  7. OpenAI打破文本和图像次元壁,提出基于对比学习的多模态预训练模型CLIP

    OpenAI 打破了自然语言与视觉的次元壁,推出了一个连接文本与图像的神经网络模型CLIP. 相关资料 CLIP原论文:Radford et al. Learning transferable vis ...

  8. 【12】Caffe学习系列:训练和测试自己的图片

    一.准备数据 有条件的同学,可以去imagenet的官网http://www.image-net.org/download-images,下载imagenet图片来训练.验证码始终出不来需要翻墙(是g ...

  9. 【深度学习】使用预训练模型

    主要有两种方法: 特征提取 微调模型 特征提取 特征提取就是使用已经训练好的网络在新的样本上提取特征,然后将这些特征输入到新的分类器,从头开始训练的过程. 卷积神经网络分为两个部分: 一系列池化层+卷 ...

最新文章

  1. Xamarin Anroid开发教程之验证环境配置是否正确
  2. JavaScript定义函数的几种方式 1
  3. nginx源码分析—内存池结构ngx_pool_t及内存管理(精辟)
  4. LeetCode Algorithm 9. 回文数
  5. 吸尘车-真空吸尘车:真空吸尘车
  6. html5+hbuilder+夜神模拟器+webview
  7. 【渝粤题库】陕西师范大学200851 微机实用技术
  8. 关于easyUI在子页面增加显示tabs的一个问题
  9. Sublime text3 修改字体和行间距
  10. 都不写代码,架构师整天在干啥?
  11. zabbix 3.0 的web界面出现乱码如何解决?
  12. 嵌入式行业公司及所属产业
  13. 小赛毛游C记——初识C语言(3)
  14. Win10+1050Ti配置tensorflow-gpu教程 (解决1050ti配置cuda失败的问题)
  15. 详解pandas的read_csv方法
  16. Tensorflow实战(三)——验证码识别(二)
  17. 用力和应变片计算弹性模量_材料弹性模量及泊松比测试实验教案.
  18. 【linux系列】统计Linux系统缺页的次数
  19. python coding style_python coding style guide 的高速落地实践
  20. python 读取 url 图片并保存到本地

热门文章

  1. web前端字体居中_html里文字居中代码怎么写?_WEB前端开发
  2. Java使用POI操作Excel文件
  3. 前端新宠 Svelte,呜呜,卷不动了
  4. 软件生命周期模型及其选择
  5. 基于51单片机AS608指纹自动识别电路设计(毕业设计)
  6. 4.个性化自己的WordPress网站 | Astra主题Elementor插件
  7. Dig 命令是如何使用的
  8. homebrew介绍
  9. 历经艰辛终于面上了阿里……八股文我悟了
  10. JavaScript之DOM查询