Guest User

ESRGAN training take 3

a guest
Jan 14th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.64 KB | None | 0 0
  1. ESRGAN training instructions for Windows v0.0000000000000001
  2.  
  3. Note: ESRGAN training appears to be slower on Windows than Linux by around 5x, at least on my machine.
  4.  
  5. If you haen't gotten ESRGAN set up for testing, please read this. Everything needed to test ESRGAN is also needed to train it. https://kingdomakrillic.tumblr.com/post/178254875891/i-figured-out-how-to-get-esrgan-and-sftgan
  6.  
  7. If you've already done all that, go to Step 1.
  8.  
  9. 1. Download BasicSR and the ESRGAN pretrained models.
  10.  
  11. Note: ESRGAN training appears to be slower on Windows than Linux by around 5x, at least on my machine.
  12.  
  13. If you haen't gotten ESRGAN set up for testing, please read this. Everything needed to test ESRGAN is also needed to train it. https://kingdomakrillic.tumblr.com/post/178254875891/i-figured-out-how-to-get-esrgan-and-sftgan
  14.  
  15. If you've already done all that, go to Step 1.
  16.  
  17. **1**. Download BasicSR and the ESRGAN pretrained models.
  18.  
  19. https://github.com/xinntao/BasicSR
  20. https://github.com/xinntao/BasicSR#pretrained-models
  21.  
  22. Place the models in (BasicSR directory)/experiments/pretrained_models
  23.  
  24. **2**. Download a dataset. The BasicSR creator uploaded several datasets to use here, but there's plenty of other datasets you can use online. I recommend 100 training image as an absolute minimum, but the more, the better.
  25.  
  26. https://github.com/xinntao/BasicSR#datasets
  27.  
  28. **2a**. Make absolutely sure that none of the images are greyscale or indexed colores. RGB only. You can use
  29.  
  30. InfranView or BIMP (see below) to convert the images to RGB.
  31.  
  32. **3.** You will need to split your "training" and "validation" images. Take about 5-10% of your images and put them in a separate folder; these will be your validation images.
  33.  
  34. 4. You will need to convert your dataset into fixed tiles. Open up codes/scripts/extract_subimgs_single.py.
  35.  
  36. Change crop_sz to 192 or 128 (I'd stick to the latter unless you have a beefy graphics card), input_folder to the full path name of your image folder, and save_folder to where you want to save the tiles to. If you're using Windows, replace all the slashes ("\") with double slashes, as "\" is an escape character.
  37.  
  38. Example:
  39.  
  40. input_folder = 'C:\\Users\\Username\\BasicSR-master\\General100'
  41.  
  42. save_folder = 'C:\\Users\\Username\\BasicSR-master\\General100_tiles'
  43.  
  44.  
  45. Double click to run it. Repeat this process for the validation images.
  46.  
  47. 5. You will need to batch convert these HR images to 4x downscaled versions. Download and open InfranView )https://www.irfanview.com/), press B to open the batch convert dialog, check "Use advanced options" and then click "Advanced" button to access the resize settings. You may want to check "Change Color Depth" or add some compression or dithering if you're specifically training it for low quality images. Make sure that both the LR and HR images have the same format and filename.
  48.  
  49. If you have GIMP installed, you can also download a batch manipulation plugin called BIMP and process the image that way.
  50.  
  51. 6. Go to codes/options/train/train_ESRGAN.json and make the following changes:
  52.  
  53. train : { dataroot_HR: location of the training HR images
  54.  
  55. train : { dataroot_LR: location of the training LR images
  56.  
  57. val : { dataroot_HR: location of the HR validation images
  58.  
  59. val : { dataroot_LR: location of the LR validation images
  60.  
  61. train : { HR_size: the size of the HR tiles. Leave at 128 if you're getting "out of memory" errors.
  62.  
  63. train : { batch_size: You could lower this number if you're getting "out of memory" errors, but that produces errors on my Windows installation. "n_workers" may be an alternative.
  64.  
  65. path : { root: the location of the BasicSR directory
  66.  
  67. Again, make sure to use double shashes.
  68.  
  69. 7. Use the command line to navigate to the codes folder and run this command: python train.py -opt options/train/train_esrgan.json
  70.  
  71. You could also create a .bat file so you can just double click, though that does make it harder to find errors (as an error will close the command prompt instantly).
  72.  
  73. 8. You can check on the model's progress by going into the "experiments" folder. Your older sessions will have an "archived" in their name, while the latest session will not. Inside each folder is the "models" folder, which is where new models are saved, and the upscaled validation images will appear in "val_images". Once you're satisfied, hit Ctrl-C in the terminal to quit training and copy one of the "G.pth" files to ESRGAN's models folder.
  74.  
  75. If you're feeling brave, you can mess with the GAN weight, feature weight and pixel weight in train_ESRGAN.json or initialize from a different model instead of RRDB_PSNR_x4.pth
  76.  
  77.  
  78.  
  79. .:`
  80. .+dM.
  81. .sssssssso+dM.
  82. ``ys::://///+y+:`
  83. ``oh-. ``ohhhho.`
  84. `-+h:` :h+::::----
  85. -Ms +yyyyyyyy/:
  86. +oo: +ooooooNNoooooo+
  87. Nd +s+/+yMMMo+Md+hMo+s+
  88. Nd :d+- `dmMMMdh:+dmMdh:/d/
  89. Nd +M/ `mNMMMmd :mNMmd :Mo
  90. Nd +M/ `/ddd-` `+d-` :Mo
  91. :/yo :y+/` /: /+y:
  92. .ooooo :oooooooooooooooooo/
  93. `/yMdy :///////: `///mN
  94. `---hhhhhhh.```` hdhhhhhhhhdd/ dN
  95. ```````yhhdN/ mm````````/M+ dN
  96. ```+M/ yy:- /M+ dN
  97. -so+``so++++++oso+ss
  98. :+so .++++++oso+`
  99. :/hhhhhhhhs:.
  100. ........`
  101.  
  102. (Oh christ I probably screwed up something here)
Advertisement
Add Comment
Please, Sign In to add comment