cyclegan(pix2pix)訓練測試

github:
https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix

在網站中有以下一段話,原來以爲使用自己的圖片集需要改pytorch-CycleGAN-and-pix2pix/data/template_dataset.py,其實只要把數據集存放的文件夾名字改成和example dataset一樣就可以了
Custom Model and Dataset
If you plan to implement custom models and dataset for your new applications, we provide a dataset template and a model template as a starting point.

後來使用bash ./datasets/download_cyclegan_dataset.sh facades下了個最小的facades dataset進行example的訓練,直接使用python train.py --dataroot ./datasets/facades --name facades_cyclegan --model cycle_gan就可以開始訓練了。

看了下./datasets/facades下有四個文件夾,testA,testB,TrainA,TrainB,然後就自己在./datasets/下創建數據集文件夾裏放入四個和這四個文件夾名字相同的空文件夾,再把自己有的一種風格的所有圖片放入TrainA,另一種風格的所有圖片放入TrainB,我這裏爲了保險,TrainA和TrainB的圖片數目相同,不同的沒測,圖片命名忘了命名成TrainA和TrainB中一樣但依然可以使用上述訓練命名在終端上進行訓練。具體的其他選項可以根據./options/base_options.py,./options/train_options.py在上述命令上修改。

最後單邊cyclegan測試的話得把./checkpoints/yourname_cyclegan/中的latest_net_G_A.pth或latest_net_G_B.pth改成latest_net_G.pth,具體是看從需要從A領域轉到B領域還是從B領域轉到A領域。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章