風格遷移學習筆記

風格遷移大做業


學習規劃

  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:
  • 參考:https://blog.csdn.net/gongxsh00/article/details/81318404
  • python 版本與 anaconda 對應儘可能最新
  • 激活虛擬環境,退出虛擬環境html

    activate tensorflow
    deactivatepython

  • tansorflow 、pip 都更新到最新 :git

    pip install --upgrade pipgithub

  • 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)
    http://www.javashuo.com/article/p-vmlgincf-ba.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中文文檔 瞭解含義算法

  • 甚至並不用深刻理解代碼。。。跟着感受把代碼改了一下。。。莫名其妙代碼一遍改好。。。跑一下就把結果跑出來了。。。編程

相關文章
相關標籤/搜索