Guest User

ESRGAN training

a guest
Jan 14th, 2019
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.87 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
  6.  
  7. needed to train it. https://kingdomakrillic.tumblr.com/post/178254875891/i-figured-out-how-to-get-esrgan-and-
  8.  
  9. sftgan
  10.  
  11. If you've already done all that, go to Step 1.
  12.  
  13. 1. Download BasicSR and the ESRGAN pretrained models.
  14.  
  15. https://github.com/xinntao/BasicSR
  16. https://github.com/xinntao/BasicSR#pretrained-models
  17.  
  18. Place the models in (BasicSR directory)/experiments/pretrained_models
  19.  
  20. 2. Download a dataset. The BasicSR creator uploaded several datasets to use here.
  21.  
  22. https://github.com/xinntao/BasicSR#datasets
  23.  
  24. 2a. Make absolutely sure that none of the images are greyscale or indexed colores. RGB only. You can use
  25.  
  26. InfranView or BIMP (see below) to convert the images to RGB.
  27.  
  28. 3. You will need to split your "training" and "validation" images. Take about 5-10% of your images and put them
  29.  
  30. in a separate folder; these will be your validation images.
  31.  
  32. 4. You will need to convert your dataset into fixed tiles. Open to codes/scripts/extract_subimgs_single.py.
  33.  
  34. Change crop_sz to 192 or 128, input_folder to the full path name of your image folder, and save_folder to where
  35.  
  36. you want to save the tiles to. If you're using Windows, replace all the slashes "\" with double slashes.
  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. Repeat this process for the validation images.
  46.  
  47. 5. You will need to batch convert these larger images to 4x downscaled versions. Download and open InfranView,
  48.  
  49. press B to open the batch convert dialog, check "Use advanced options" and then click "Advanced" button to
  50.  
  51. access the resize settings. You may want to check "Change Color Depth" if you're specifically training it for
  52.  
  53. images with few colors. Make sure that both the LR and HR images have the same format and filename.
  54.  
  55. If you have GIMP installed, you can also download a batch manipulation plugin called BIMP and process the image
  56.  
  57. that way
  58.  
  59. 6. Go to codes/options/train/train_ESRGAN.json and make the following changes:
  60.  
  61. train : { dataroot_HR: location of the training HR images
  62.  
  63. train : { dataroot_LR: location of the training LR images
  64.  
  65. val : { dataroot_HR: location of the HR validation images
  66.  
  67. val : { dataroot_LR: location of the LR validation images
  68.  
  69. train : { HR_size: the size of the HR tiles. Leave at 128 if you're getting "out of memory" errors.
  70.  
  71. train : { batch_size: You could lower this number if you're getting "out of memory" errors, but that produces
  72.  
  73. errors on my Windows installation. "n_workers" may be an alternative.
  74.  
  75. path : { root: the location of the BasicSR directory
  76.  
  77. Again, make sure to use double shashes.
  78.  
  79. 7. Use the command line to navigate to the codes folder and run this command: python train.py -opt
  80.  
  81. options/train/train_esrgan.json
  82.  
  83. You could also create a .bat file so you can just double click, though that does make it harder to find errors
  84.  
  85. (as an error will close the command prompt instantly).
  86.  
  87. 8. You can check on the model's progress by going into the "experiments" folder. Older sessions will have an
  88.  
  89. "archived" in their name, while the latest session will not. Inside each folder is the "models" folder, which is
  90.  
  91. where new models are saved, and the upscaled validation images will appear in "val_images". Once you're
  92.  
  93. satisfied, hit Ctrl-C in the terminal to quit training.
  94.  
  95. 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
  96.  
  97.  
  98.  
  99. .:`
  100. .+dM.
  101. .sssssssso+dM.
  102. ``ys::://///+y+:`
  103. ``oh-. ``ohhhho.`
  104. `-+h:` :h+::::----
  105. -Ms +yyyyyyyy/:
  106. +oo: +ooooooNNoooooo+
  107. Nd +s+/+yMMMo+Md+hMo+s+
  108. Nd :d+- `dmMMMdh:+dmMdh:/d/
  109. Nd +M/ `mNMMMmd :mNMmd :Mo
  110. Nd +M/ `/ddd-` `+d-` :Mo
  111. :/yo :y+/` /: /+y:
  112. .ooooo :oooooooooooooooooo/
  113. `/yMdy :///////: `///mN
  114. `---hhhhhhh.```` hdhhhhhhhhdd/ dN
  115. ```````yhhdN/ mm````````/M+ dN
  116. ```+M/ yy:- /M+ dN
  117. -so+``so++++++oso+ss
  118. :+so .++++++oso+`
  119. :/hhhhhhhhs:.
  120. ........`
  121.  
  122. (Oh christ I probably screwed up something here)
Advertisement
Add Comment
Please, Sign In to add comment