• 风格迁移学习笔记


    风格迁移大作业


    学习规划

    1. 跑通一份代码!!!(done)
    2. 对照代码、Blog和论文理解相应的算法过程
    3. 规划下一步,修改代码(done),实现预计功能(done)
    4. 调参,跑出较好

    Problem Queue

    1. 算法和代码对应?细化?(尽量搞吧。。。PPT/报告里讲啥?
    2. 代码修改?
    • 损失函权重参数、多张图片风格渐变效果?
    • 损失函数形式
    • 本代码的生成图片的初始值是内容图片,可以改成普通的白噪声/突出重点的黑白轮廓图/抠图。实际上,将初始值设定为内容图像,就是以这个作为迭代的起点,一定程度上掩盖了迭代次数少的问题。
    • 融合2个以上的风格,跑个比较优美的风格过度效果?(掩盖一下垃圾的图片效果。
    • 可以参考:https://zhuanlan.zhihu.com/p/27512619 展示图片效果。。
    • 只包含风格的图像
    • 只包含内容的图像
    • 玄学感受?风格图片元素单一,不要过于复杂,最好不要有明显的"主角"或者关键点,火?;内容图像相反需要有明显的”主角“和重点,大头贴、肖像;初始化图片需要对内容图片做一些处理得到。。比如强调"主角",模糊甚至抹去背景,颜色重?
    1. 怎样挑数据?
    • 参考网上一些以有的比较好的效果图片,查找类似的图片
    • 对照测试,需要跑出比较好的结果
    1. 把 GPU 版还是配好吧。。。 迭代次数增加10-20倍?从十几个小时编程几十分钟。。。次数不够跑不出好效果吧。。。是可以分组跑的,用上一次迭代的结果作为这一次迭代的初始值。

    跑通一份代码!!!

    1. 尝试配置 win 下pycharm + tensorflow (done) anaconda 大法好
      Note:

    activate tensorflow
    deactivate

    • tansorflow 、pip 都更新到最新 :

    pip install --upgrade pip

    • pip 链接超时,可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple
    • 无权限更新,就开管理员
    • 大部分问题都是因为版本不对应
    • 注意目录
    • 对应的 python 以及 python/scripts 要加入环境变量(多加没坏处。
    • pycharm 版本改成最新的 (pycharm 有些奇怪的坑,尽量用 anaconda)
    • pip .ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. (使用:pip install *** --default-timeout=1000)
    1. 找一份代码、运行成功 (done)
      https://www.cnblogs.com/andrewwang/p/10836929.html
      https://blog.csdn.net/dcrmg/article/details/81269653
      https://blog.csdn.net/u010900574/article/details/53427544
      https://github.com/keras-team/keras
    2. 学会远程使用服务器,调用老师提供的显卡计算,配置环境 tensorflow 运行样例代码(done)

    对照代码、Blog和论文理解相应的算法过程

    规划下一步流程,修改代码,实现预计功能

    修改样例代码实现加入2个风格(done)

    • Modify1
    parser.add_argument('style_reference_image_path_1', metavar='ref', type=str,
                        help='Path to the style reference image_1.')
    parser.add_argument('style_reference_image_path_2', metavar='ref', type=str,
                        help='Path to the style reference image_2.')
    
    • Modify2
    style_reference_image_path_1 = args.style_reference_image_path_1
    style_reference_image_path_2 = args.style_reference_image_path_2
    
    • Modify3
    style_reference_image_1 = K.variable(preprocess_image(style_reference_image_path_1))
    style_reference_image_2 = K.variable(preprocess_image(style_reference_image_path_2))
    
    • Modify4
      后边需要注意每个量的位置
    input_tensor = K.concatenate([base_image,
                                  style_reference_image_1,
                                  style_reference_image_2,
                                  combination_image], axis=0)
    
    • Modify5
      combination_features由于4操作这里需要注意维数的变化
    combination_features = layer_features[3, :, :, :]
    
    • Modify6
      修改损失函数(待修改)
    for layer_name in feature_layers:
        layer_features = outputs_dict[layer_name]
        style_reference_features_1 = layer_features[1, :, :, :]
        combination_features = layer_features[3, :, :, :]
        sl = style_loss(style_reference_features_1, combination_features)
        loss += (style_weight / len(feature_layers)) * sl
    
        style_reference_features_2 = layer_features[2, :, :, :]
        combination_features = layer_features[3, :, :, :]
        sl = style_loss(style_reference_features_2, combination_features)
        loss += (style_weight / len(feature_layers)) * sl
    

    Note

    • 主要代码可以根据 keras中文文档 了解含义

    • 甚至并不用深入理解代码。。。跟着感觉把代码改了一下。。。莫名其妙代码一遍改好。。。跑一下就把结果跑出来了。。。

  • 相关阅读:
    从 LengthFieldBasedFrameDecoder 看 netty 处理拆包
    nacos 服务的实例变化
    nacos 中的服务和实例
    idea 编译 brooklin
    idea 编译 netty 源码
    consumeQueue 和 indexFile 文件
    rocketMQ 事务消息
    特殊符号存入mysql数据库时报错:Incorrect string value: 'xF0x9Fx98x84xF0x9F的解决方法
    面试中常用排序算法的python实现和性能分析
    获取编写代码所在文件的上级文件和上上级文件的相对路径
  • 原文地址:https://www.cnblogs.com/RRRR-wys/p/11010491.html
Copyright © 2020-2023  润新知