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

news2024/9/29 21:33:55

一. 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 _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "D:\Anaconda3\envs\paddlepaddle\lib\multiprocessing\context.py", line 322, in _Popen
    return 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 dump
    ForkingPickler(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 the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is 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 the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is 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_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "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_connection
    sock.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_main
    exitcode = _main(fd)
  File "D:\Anaconda3\envs\paddlepaddle\lib\multiprocessing\spawn.py", line 115, in _main
    self = 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_tensor
    from torchvision.ops.misc import _output_size

修改为

import torchvision
if float(torchvision.__version__[2:4]) < 7:
    from torchvision.ops import _new_empty_tensor
    from 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_properties
    raise 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 the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is 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)

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

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

相关文章

深入理解Zookeeper系列-4.Watcher原理

&#x1f44f;作者简介&#xff1a;大家好&#xff0c;我是爱吃芝士的土豆倪&#xff0c;24届校招生Java选手&#xff0c;很高兴认识大家&#x1f4d5;系列专栏&#xff1a;Spring源码、JUC源码、Kafka原理、分布式技术原理&#x1f525;如果感觉博主的文章还不错的话&#xff…

深入浅出理解kafka

1.Kafka简介 Kafka 本质上是一个 MQ&#xff08;Message Queue&#xff09;&#xff0c;使用消息队列的优点&#xff1a; 解耦&#xff1a;允许独立的扩展或修改队列两边的处理过程。可恢复性&#xff1a;即使一个处理消息的进程挂掉&#xff0c;加入队列中的消息仍然可以在系…

LinuxBasicsForHackers笔记 -- 控制文件和目录权限

对于每个文件和目录&#xff0c;我们可以指定文件所有者、特定用户组以及所有其他用户的权限状态。 不同类型的用户 在Linux中&#xff0c;root用户是拥有一切权力的。 root 用户基本上可以在系统上执行任何操作。 系统上的其他用户具有有限的能力和权限&#xff0c;并且几乎…

使用正则表达式时-可能会导致性能下降的情况

目录 前言 正则表达式引擎 NFA自动机的回溯 解决方案 前言 正则表达式是一个用正则符号写出的公式&#xff0c;程序对这个公式进行语法分析&#xff0c;建立一个语法分析树&#xff0c;再根据这个分析树结合正则表达式的引擎生成执行程序(这个执行程序我们把它称作状态机&a…

GitHub项目推荐-Deoldify

有小伙伴推荐了一个老照片上色的GitHub项目&#xff0c;看了简介&#xff0c;还不错&#xff0c;推荐给大家。 项目地址 GitHub - SpenserCai/sd-webui-deoldify: DeOldify for Stable Diffusion WebUI&#xff1a;This is an extension for StableDiffusions AUTOMATIC1111 w…

IDEA 下载mysql驱动下载在不下来

结合一下 https://www.cnblogs.com/dadian/p/11936056.htmlhttps://www.cnblogs.com/dadian/p/11936056.html并且下载的 在idea改名 加入 加入到库 等待一会就要你输入sql的root和密码了,就OK

React创建项目

React创建项目 提前安装好nodejs再进行下面的操作&#xff0c;通过node -v验证是否安装 1.设置源地址 npm config set registry https://registry.npmmirror.com/2.确认源地址 npm config get registry返回如下 https://registry.npmmirror.com/3.输入命令 npx create-re…

SpringCloud | Dubbo 微服务实战——注册中心详解

前言 「作者主页」&#xff1a;雪碧有白泡泡 「个人网站」&#xff1a;雪碧的个人网站 |Eureka,Nacos,Consul,Zookeeper在Spring Cloud和Dubbo中实战 引言 在项目开发过程中&#xff0c;随着项目不断扩大&#xff0c;也就是业务的不断增多&#xff0c;我们将采用集群&#xf…

(C语言)通过循环按行顺序为一个矩阵赋予1,3,5,7,9,等奇数,然后输出矩阵左下角的值。

#include<stdio.h> int main() {int a[5][5];int n 1;for(int i 0;i < 5;i ){for(int j 0;j < 5;j ){a[i][j] n;n 2;}}for(int i 0;i < 5;i ){for(int j 0;j < i;j )printf("%-5d",a[i][j]);printf("\n");}return 0; } 运行截图…

Win7 旗舰版打开Rustdesk软件提示无法启动程序 ,计算机中丢失api-ms-win-shcore-scaling-|1-1-1.dll

环境: Win7 旗舰版 64位 Rustdesk1.19自编译客户端 问题描述: Win7 旗舰版打开Rustdesk软件提示无法启动程序 ,计算机中丢失api-ms-win-shcore-scaling-|1-1-1.dll "api-ms-win-shcore-scaling-|1-1-1.dll" 是一个系统动态链接库文件,它是Windows操作系统的一…

迪文串口5使用查询方式发送数据

迪文屏串口5寄存器如下 发送数据我采用的不是中断&#xff0c;而是查询发送标志位实现的。 串口5不像串口2一样&#xff08;串口2可以位寻址&#xff0c;串口5不行&#xff09;&#xff0c;所以如果采用查询模式&#xff0c;需要判断寄存器的数据&#xff0c;我的写法比较简单…

tex中的边框

文章目录 利用tcolorbox宏包给公式加框 利用tcolorbox宏包 tcolorbox可以创建一个盒子的环境&#xff0c;例如&#xff1a; \documentclass{article} \usepackage{tcolorbox} \begin{document}\begin{tcolorbox}[left1cm, right1cm, top0.5cm, bottom0.5cm,colbackblue!10!wh…

初步认识结构体

hello&#xff0c;hello&#xff0c;各位小伙伴&#xff0c;本篇文章跟大家一起学习结构体&#xff0c;并跟大家一边做题一边进行学习和理解。感谢大家对我上一篇的支持&#xff0c;如有什么问题&#xff0c;还请多多指教&#xff01; 如果本篇文章对你有帮助&#xff0c;还请…

H5流媒体播放器EasyPlayer播放H.265新增倍速播放功能,具体如何实现?

目前我们TSINGSEE青犀视频所有的视频监控平台&#xff0c;集成的都是EasyPlayer.js版播放器&#xff0c;它属于一款高效、精炼、稳定且免费的流媒体播放器&#xff0c;可支持多种流媒体协议播放&#xff0c;包括WebSocket-FLV、HTTP-FLV&#xff0c;HLS&#xff08;m3u8&#x…

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

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

大模型技术的发展与实践

一、大模型的概念 大型语言模型&#xff0c;也称大语言模型、大模型&#xff08;Large Language Model&#xff0c;LLM&#xff1b;Large Language Models&#xff0c;LLMs) 。 大语言模型是一种深度学习模型&#xff0c;特别是属于自然语言处理&#xff08;NLP&#xff09;的…

二叉树(判断是否为平衡二叉树)

题目&#xff08;力扣&#xff09;&#xff1a; 观察题目&#xff0c;发现最重要的条件就是&#xff0c;两颗子树的高度差的绝对值不超过1&#xff0c;我们就可以用递归将所有左子树和右子树都遍历一个&#xff0c;求出他们的高度差&#xff0c;若差值 > 1&#xff0c;则返回…

C语言数组(上)

# 数组的概念 数组是一组相同类型元素的集合。数组中存放的是一个或多个数据&#xff0c;但是数组中的元素个数不能为零&#xff1b;数组中存放的所有元素&#xff08;数据&#xff09;的类型必须是相同的。 数组分为一维数组和多维数组&#xff0c;多维数组一般比较多见的是二…

案例研究|作为一家BI厂商,飞致云是如何人人使用DataEase的?

杭州飞致云信息科技有限公司&#xff08;以下简称为飞致云&#xff09;长期秉持“软件用起来才有价值&#xff0c;才有改进的机会”的核心价值观&#xff0c;以“为数字经济时代创造好软件”为使命&#xff0c;致力于成为中国数字化团队首选的通用工具软件提供商。在软件产品不…