風格遷移大作業
學習規劃
- 跑通一份代碼!!!(done)
- 對照代碼、Blog和論文理解相應的算法過程
- 規劃下一步,修改代碼(done),實現預計功能(done)
- 調參,跑出較好
Problem Queue
- 算法和代碼對應?細化?(盡量搞吧。。。PPT/報告里講啥?
- 代碼修改?
- 損失函權重參數、多張圖片風格漸變效果?
損失函數形式- 本代碼的生成圖片的初始值是內容圖片,可以改成普通的白噪聲/突出重點的黑白輪廓圖/摳圖。實際上,將初始值設定為內容圖像,就是以這個作為迭代的起點,一定程度上掩蓋了迭代次數少的問題。
- 融合2個以上的風格,跑個比較優美的風格過度效果?(掩蓋一下垃圾的圖片效果。
- 可以參考:https://zhuanlan.zhihu.com/p/27512619 展示圖片效果。。
- 只包含風格的圖像
- 只包含內容的圖像
- 玄學感受?風格圖片元素單一,不要過于復雜,最好不要有明顯的"主角"或者關鍵點,火?;內容圖像相反需要有明顯的”主角“和重點,大頭貼、肖像;初始化圖片需要對內容圖片做一些處理得到。。比如強調"主角",模糊甚至抹去背景,顏色重?
- 怎樣挑數據?
- 參考網上一些以有的比較好的效果圖片,查找類似的圖片
- 對照測試,需要跑出比較好的結果
- 把 GPU 版還是配好吧。。。 迭代次數增加10-20倍?從十幾個小時編程幾十分鐘。。。次數不夠跑不出好效果吧。。。是可以分組跑的,用上一次迭代的結果作為這一次迭代的初始值。
跑通一份代碼!!!
- 嘗試配置 win 下pycharm + tensorflow (done) anaconda 大法好
Note:
- 參考:https://blog.csdn.net/gongxsh00/article/details/81318404
- python 版本與 anaconda 對應盡量最新
激活虛擬環境,退出虛擬環境
activate tensorflow
deactivatetansorflow 、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)
- 找一份代碼、運行成功 (done)
https://www.cnblogs.com/andrewwang/p/10836929.htmlhttps://blog.csdn.net/dcrmg/article/details/81269653
https://blog.csdn.net/u010900574/article/details/53427544
https://github.com/keras-team/keras - 學會遠程使用服務器,調用老師提供的顯卡計算,配置環境 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)) * slstyle_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中文文檔 了解含義
甚至并不用深入理解代碼。。。跟著感覺把代碼改了一下。。。莫名其妙代碼一遍改好。。。跑一下就把結果跑出來了。。。