风格迁移网络修改流程(自用版)

一. AdaAttN-Revisit Attention Mechanism in Arbitrary Neural Style Transfer(ICCV2021)

  1. 下载vgg_normalised.pth
  2. 打开visdom
python -m visdom.server
  1. 在 train_adaattn.sh 中配置 content_path、style_path 和 image_encoder_path,分别表示训练内容图像、训练样式图像和 "vgg_normalised.pth "文件夹的路径。
python train.py --content_path F:\RefDayDataset\KAIST_256\trainA --style_path F:\RefDayDataset\KAIST_256\trainB --name AdaAttN_kaist --model adaattn --dataset_mode unaligned --no_dropout --load_size 286 --crop_size 256 --image_encoder_path C:\Users\64883\Desktop\AdaAttN-main\models\vgg_normalised.pth --gpu_ids 0 --batch_size 1 --n_epochs 2 --n_epochs_decay 3 --display_freq 1 --display_port 8097 --display_env AdaAttN --lambda_local 3 --lambda_global 10 --lambda_content 0 --shallow_layer --skip_connection_3

问题1

OSError: [WinError 1455] 页面文件太小,无法完成操作。 Error loading "D:\Anaconda3\envs\paddlepaddle\lib\site-packages\torch\lib\cudnn_cnn_infer64_8.dll" or one of its dependencies.self._popen = self._Popen(self)File "D:\Anaconda3\envs\paddlepaddle\lib\multiprocessing\context.py", line 223, in _Popenreturn _default_context.get_context().Process._Popen(process_obj)File "D:\Anaconda3\envs\paddlepaddle\lib\multiprocessing\context.py", line 322, in _Popenreturn Popen(process_obj)File "D:\Anaconda3\envs\paddlepaddle\lib\multiprocessing\popen_spawn_win32.py", line 89, in __init__reduction.dump(process_obj, to_child)File "D:\Anaconda3\envs\paddlepaddle\lib\multiprocessing\reduction.py", line 60, in dumpForkingPickler(file, protocol).dump(obj)
BrokenPipeError: [Errno 32] Broken pipe

解决方法

parser.add_argument('--num_threads', default=4, type=int, help='# threads for loading data')

修改为

parser.add_argument('--num_threads', default=0, type=int, help='# threads for loading data')

问题2

torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 4.08 GiB (GPU 0; 8.00 GiB total capacity; 134.76 MiB already allocated; 4.94 GiB free; 748.00 MiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for M
emory Management and PYTORCH_CUDA_ALLOC_CONF

解决方法:降低分辨率

问题3 输出频率太频繁了
在这里插入图片描述
解决方法

--display_freq 1

更改为

--display_freq 1000

问题4 内容损失始终为0
解决方法

--lambda_content 0

修改为

--lambda_content 10

问题5 训练轮次过少
解决方法

--n_epochs 2 --n_epochs_decay 3 

修改为

--n_epochs 100 --n_epochs_decay 100

二. ArtFlow- Unbiased Image Style Transfer via Reversible Neural Flows(CVPR2021)

  1. 下载VGG模型,创建models文件夹,将模型移动到models文件夹下
  2. 修改训练代码
    创建experiments文件夹
python -u train.py --content_dir F:/RefDayDataset/KAIST_256/trainA --style_dir F:/RefDayDataset/KAIST_256/trainB --save_dir ./experiments/ArtFlow-AdaIN --n_flow 8 --n_block 2 --batch_size 4 --operator adain 

问题1

Traceback (most recent call last):File "train.py", line 152, in <module>content_dataset = FlatFolderDataset(args.content_dir, content_tf)File "train.py", line 37, in __init__self.paths = os.listdir(self.root)
OSError: [WinError 123] 文件名、目录名或卷标语法不正确。: "'F:\\RefDayDataset\\KAIST_256\\trainA'"

解决方法:把单引号删除

问题2

RuntimeError:An attempt has been made to start a new process before thecurrent process has finished its bootstrapping phase.This probably means that you are not using fork to start yourchild processes and you have forgotten to use the proper idiomin the main module:if __name__ == '__main__':freeze_support()...The "freeze_support()" line can be omitted if the programis not going to be frozen to produce an executable.

解决方法

parser.add_argument('--n_threads', type=int, default=8)

修改为

parser.add_argument('--n_threads', type=int, default=0)

问题3

torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 36.00 MiB (GPU 0; 8.00 GiB total capacity; 7.42 GiB already allocated; 0 bytes free; 7.47 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memor
y Management and PYTORCH_CUDA_ALLOC_CONF

解决方法:降低batchsize,降低分辨率

--batch_size 4

修改为

--batch_size 1

三. IEST- Artistic Style Transfer with Internal-external Learning and Contrastive Learning(NeurIPS2021)

  1. 下载VGG模型,并移动到models文件夹下
  2. 修改训练代码
python train.py --content_dir F:/RefDayDataset/KAIST_256/trainA --style_dir F:/RefDayDataset/KAIST_256/trainB

问题1

RuntimeError:An attempt has been made to start a new process before thecurrent process has finished its bootstrapping phase.This probably means that you are not using fork to start yourchild processes and you have forgotten to use the proper idiomin the main module:if __name__ == '__main__':freeze_support()...The "freeze_support()" line can be omitted if the programis not going to be frozen to produce an executable.

解决方法

parser.add_argument('--n_threads', type=int, default=16)

修改为

parser.add_argument('--n_threads', type=int, default=0)

问题2

torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 36.00 MiB (GPU 0; 8.00 GiB total capacity; 7.42 GiB already allocated; 0 bytes free; 7.47 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memor
y Management and PYTORCH_CUDA_ALLOC_CONF

解决方法:降低batchsize,降低分辨率

parser.add_argument('--batch_size', type=int, default=12)

修改为

parser.add_argument('--batch_size', type=int, default=2)

问题3

RuntimeError: CUDA error: device-side assert triggered
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.

解决方法:试试在另外一张卡,或者改变num_workers

四. CAST- Domain Enhanced Arbitrary Image Style Transfer via Contrastive Learning(SIGGRAPH2022)

  1. 下载pretrained style classification model和pretrained content encoder
  2. 修改训练代码
python train.py --dataroot F:/RefDayDataset/KAIST_256 --name cast

问题1

  File "<frozen importlib._bootstrap>", line 1006, in _gcd_importFile "<frozen importlib._bootstrap>", line 983, in _find_and_loadFile "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 677, in _load_unlockedFile "<frozen importlib._bootstrap_external>", line 728, in exec_moduleFile "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removedFile "C:\Users\64883\Desktop\CAST_pytorch-main\models\cast_model.py", line 11, in <module>import kornia.augmentation as K
ModuleNotFoundError: No module named 'kornia'

解决方法

pip install kornia

问题2

requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8097): Max retries exceeded with url: /env/main (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000230810E0588>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。')
)
[WinError 10061] 由于目标计算机积极拒绝,无法连接。
on_close() takes 1 positional argument but 3 were given
Visdom python client failed to establish socket to get messages from the server. This feature is optional and can be disabled by initializing Visdom with `use_incoming_socket=False`, which will prevent waiting for this request to timeout.
Traceback (most recent call last):File "D:\Anaconda3\envs\paddlepaddle\lib\site-packages\urllib3\util\connection.py", line 85, in create_connectionsock.connect(sa)
ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。During handling of the above exception, another exception occurred:

解决方法

python -m visdom.server

问题3

Traceback (most recent call last):File "<string>", line 1, in <module>File "D:\Anaconda3\envs\paddlepaddle\lib\multiprocessing\spawn.py", line 105, in spawn_mainexitcode = _main(fd)File "D:\Anaconda3\envs\paddlepaddle\lib\multiprocessing\spawn.py", line 115, in _mainself = reduction.pickle.load(from_parent)
EOFError: Ran out of input

解决方法

parser.add_argument('--num_threads', default=4, type=int, help='# threads for loading data')

修改为

parser.add_argument('--num_threads', default=0, type=int, help='# threads for loading data')

问题4

torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 4.08 GiB (GPU 0; 8.00 GiB total capacity; 751.44 MiB already allocated; 4.37 GiB free; 1.30 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Mem
ory Management and PYTORCH_CUDA_ALLOC_CONF

解决方法:降低batchsize,降低分辨率

五. StyTr2- Image Style Transfer with Transformers(CVPR2022)

  1. 下载VGG模型,移动到models文件夹下
  2. 修改训练代码
python train.py --content_dir F:/RefDayDataset/KAIST_256/trainA --style_dir F:/RefDayDataset/KAIST_256/trainB --save_dir experiments/ --batch_size 1

问题1

ImportError: cannot import name '_new_empty_tensor' from 'torchvision.ops' (D:\python\lib\site-packages\torchvision\ops\__init__.py)

解决方法

import torchvision
if float(torchvision.__version__[:3]) < 0.7:from torchvision.ops import _new_empty_tensorfrom torchvision.ops.misc import _output_size

修改为

import torchvision
if float(torchvision.__version__[2:4]) < 7:from torchvision.ops import _new_empty_tensorfrom torchvision.ops.misc import _output_size

问题2

ImportError: cannot import name 'container_abcs' from 'torch._six' (D:\Anaconda3\envs\paddlepaddle\lib\site-packages\torch\_six.py)

解决方法

from torch._six import container_abcs

修改为

import collections.abc as container_abcs

问题3

  File "D:\Anaconda3\envs\paddlepaddle\lib\site-packages\torch\_utils.py", line 577, in <lambda>return [_get_device_attr(lambda m: m.get_device_properties(i)) for i in device_ids]File "D:\Anaconda3\envs\paddlepaddle\lib\site-packages\torch\cuda\__init__.py", line 374, in get_device_propertiesraise AssertionError("Invalid device id")
AssertionError: Invalid device id

解决方法
train中116行注释掉

# network = nn.DataParallel(network, device_ids=[0,1])

问题4

RuntimeError:An attempt has been made to start a new process before thecurrent process has finished its bootstrapping phase.This probably means that you are not using fork to start yourchild processes and you have forgotten to use the proper idiomin the main module:if __name__ == '__main__':freeze_support()...The "freeze_support()" line can be omitted if the programis not going to be frozen to produce an executable.

解决方法

parser.add_argument('--n_threads', type=int, default=16)

修改为

parser.add_argument('--n_threads', type=int, default=0)

问题5

Traceback (most recent call last):File "train.py", line 135, in <module>{'params': network.module.transformer.parameters()},File "D:\Anaconda3\envs\paddlepaddle\lib\site-packages\torch\nn\modules\module.py", line 1270, in __getattr__type(self).__name__, name))
AttributeError: 'StyTrans' object has no attribute 'module'

这个错误通常在使用 PyTorch 的多 GPU 训练时出现。在多 GPU 训练中,模型通常会被包装在 nn.DataParallel 或 nn.parallel.DistributedDataParallel 中,以实现并行计算。这会导致模型对象的属性访问发生变化。

解决方法

optimizer = torch.optim.Adam([ {'params': network.module.transformer.parameters()},{'params': network.module.decode.parameters()},{'params': network.module.embedding.parameters()},], lr=args.lr)

更改为

optimizer = torch.optim.Adam([ {'params': network.transformer.parameters()},{'params': network.decode.parameters()},{'params': network.embedding.parameters()},], lr=args.lr)

六. QuantArt- Quantizing Image Style Transfer Towards High Visual Fidelity(CVPR2023)

  1. 创建kaist.yaml
  2. 运行训练代码
python -u main.py --base configs/kaist.yaml -t True --gpus 0

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/205487.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

固态硬盘速度测试:硬盘实际性能是否符合标准?

在进行固态硬盘速度测试之前我们先来了解一下固态硬盘的读写速度是什么。固态硬盘的读写速度主要分为顺序读写和随机读写&#xff08;4K&#xff09;。 ​顺序读写&#xff1a;指的是硬盘在读写连贯、集中大文件时候的速度。比如在读取、拷贝单个视频文件时&#xff0c;就是硬盘…

剑指YOLOv5独家最新改进(全网无重复)《感知聚合SERDetect检测头》高效涨点,即插即用|检测头新颖改进

💡本篇内容:YOLOv5独家最新改进《感知聚合SERDetect检测头》高效涨点,即插即用|检测头新颖改进 💡🚀🚀🚀本博客 YOLO系列 + 感知聚合SERDetect检测头 改进创新点改进源代码改进 适用于 YOLOv5 按步骤操作运行改进后的代码即可 💡附改进源代码及教程,适合用来…

【项目问题解决】IDEA2020.3 使用 lombok 插件 java: 找不到符号 符号: 方法 builder()

目录 lombok找不到符号问题修改 1.问题描述2.问题原因3.解决思路4.解决方案5.总结6.参考 文章所属专区 项目问题解决 1.问题描述 IDEA2020.3 使用 lombok 插件 java: 找不到符号 符号: 方法 builder()&#xff0c;无法使用lombok下应有的注解&#xff0c;一度怀疑是版本问题 …

【cc++】volatile关键字的作用

​​volatile​​描述 ​​volatile​​ 是C和C都支持的一个关键字&#xff0c;是一种类型修饰符。这个关键字被设计用来告诉编译器&#xff0c;一个变量可能会在程序之外被改变&#xff0c;例如&#xff0c;它可能被中断服务程序修改&#xff0c;或者它可能映射到一个硬件寄存…

使用Inno Setup 打包程序文件 怎么把其中一个文件安装时复制到指定系统文件夹

环境: Inno Setup 6.6 Win10 专业版 问题描述: 使用Inno Setup 打包程序文件 怎么把其中一个文件安装时复制到指定系统文件夹 将文件api-ms-win-shcore-scaling-l1-1-1.dll复制到system32里面 解决方案: 1.由于安全和权限的限制,直接在Inno Setup脚本中复制文件到C:\…

C++新经典模板与泛型编程:用成员函数重载实现std::is_class

用成员函数重载实现is_class std::is_class功能&#xff0c;是一个C11标准中用于判断某个类型是否为一个类类型&#xff08;但不是联合类型&#xff09;的类模板。当时在讲解的时候并没有涉及std::is_class的实现代码&#xff0c;在这里实现一下。简单地书写一个IsClass类模板…

python pydoc生成API文档

pydoc是python内置的一个文档生成模块。 pydoc 模块会根据 Python 模块来自动生成文档。 生成的文档可在控制台中显示为文本页面&#xff0c;提供给 Web 浏览器访问或者保存为 HTML 文件。 对于模块、类、函数和方法&#xff0c;显示的文档内容取自文档字符串&#xff08;即 _…

(Note)Chromium浏览器插件

Chromium浏览器插件 1.TamperMonkey Home | Tampermonkey 2.GreasyFork Greasy Fork - 安全、实用的用户脚本大全

泰凌微(Telink)8258配置串口收发自定义数据

在官网下载SDK后&#xff08;以Mesh SDK为例&#xff09;使用Eclipse打开&#xff0c;对应MCU的配置文件在app_config_8258.h&#xff0c;默认的HCI接口是HCI_USE_NONE&#xff0c;如果改成HCI_USE_UART后可以通过串口收发数据&#xff0c;此时默认接收函数处理的是以Telink的协…

索引的优缺点是什么

数据是存储在磁盘上的&#xff0c;操作系统读取磁盘的最小单位是块&#xff0c;如果没有索引&#xff0c;会加载所有的数据到内存&#xff0c;依次进行检索&#xff0c;加载的总数据会很多&#xff0c;磁盘IO多。如果有了索引&#xff0c;会以某个列为key创建索引&#xff0c;M…

音视频学习(二十)——rtsp收流(udp方式)

前言 本文主要介绍通过udp方式实现rtsp拉流。 流程图 流程说明&#xff1a; 相较于tcp方式“信令数据”复用同一连接拉流&#xff0c;udp方式拉流“信令数据”采用不同的连接&#xff0c;信令传输采用tcp&#xff0c;流数据传输采用udp&#xff1b;客户端向服务端&#xff0…

数据库增删改查(CRUD)进阶版

目录 数据库约束 约束类型 表的设计 1.一对一 2.一对多 3.多对多 增删查改进阶操作 1. 插入查询结果 2.查询 聚合查询 聚合函数 group by having 联合查询 内连接 外连接 自连接 子查询 合并查询 数据库约束 创建表的时候制定的一些规则&#xff0c;在后续…

在Windows 10或11中,复制和粘贴不起作用,不一定是键盘的问题

以下建议将帮助你解决复制和粘贴无法正常工作的问题。 以下提示主要适用于Windows 10和Windows 11,但也可能解决旧版本Windows上的复制和粘贴问题。 为什么我的复制粘贴不起作用 复制和粘贴不起作用的问题可能以以下方式之一出现。 其他正在运行的应用程序或进程可能会使用…

智能优化算法应用:基于北方苍鹰算法无线传感器网络(WSN)覆盖优化 - 附代码

智能优化算法应用&#xff1a;基于北方苍鹰算法无线传感器网络(WSN)覆盖优化 - 附代码 文章目录 智能优化算法应用&#xff1a;基于北方苍鹰算法无线传感器网络(WSN)覆盖优化 - 附代码1.无线传感网络节点模型2.覆盖数学模型及分析3.北方苍鹰算法4.实验参数设定5.算法结果6.参考…

生成式人工智能笔记-AIGC笔记

生成式人工智能笔记-AIGC笔记 十多年前&#xff0c;人工智能还只是一个不被人看好的小众领域&#xff0c;但是现在&#xff0c;它却已经成了街头巷尾的热点谈资&#xff0c;几乎任何事情都可以和人工智能联系在一起。 人工智能包括基础层、技术层和应用层。 基础层是人工智能…

收藏!当今最流行的10 种人工智能算法

人工智能的概念始于1956年的达特茅斯会议&#xff0c;由于受到数据、计算力、智能算法等多方面因素的影响&#xff0c;人工智能技术和应用发展经历了多次高潮和低谷。 2022年以来&#xff0c;以ChatGPT为代表的大模型一夜爆火&#xff0c;它能够基于在预训练阶段所见的模式和统…

Python中如何判断List中是否包含某个元素

更多资料获取 &#x1f4da; 个人网站&#xff1a;ipengtao.com 在Python中&#xff0c;判断一个列表&#xff08;List&#xff09;是否包含某个特定元素是常见的任务之一。在本文中&#xff0c;将深入探讨多种判断List成员包含性的方法&#xff0c;并提供丰富的示例代码&…

二、C#笔记

/// <summary> /// 第三章&#xff1a;方法和作用域 /// </summary> namespace Chapter3 { class Program { public static void Main(string[] args) { //3.1创建方法 Console.WriteLine($"{addValues(1, 2…

每日一题:LeetCode-11.盛水最多的容器

每日一题系列&#xff08;day 13&#xff09; 前言&#xff1a; &#x1f308; &#x1f308; &#x1f308; &#x1f308; &#x1f308; &#x1f308; &#x1f308; &#x1f308; &#x1f308; &#x1f308; &#x1f308; &#x1f308; &#x1f308; &#x1f50e…

UVa133救济金发放题解

题目 题目描述 n(n<20)个人站成一圈&#xff0c;逆时针编号为 1~n。有两个官员&#xff0c;A从1开始逆时针数&#xff0c;B从n开始顺时针数。在每一轮中&#xff0c;官员A数k个就停下来&#xff0c;官员B数m个就停下来&#xff08;两个官员有可能能停在同一个人上&#xff…