Guest User

script.py

a guest
May 16th, 2019
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. import PIL
  2. from PIL import Image
  3. import os
  4. import subprocess as sub
  5.  
  6. coef = 0.45
  7. waifu2xCaffeExe = 'C:\\Programmes\\waifu2x-caffe\\waifu2x-caffe-cui.exe'
  8. picFolder = os.getcwd()
  9. waifuOption = '-m noise_scale -s 4 -n 3 -p cudnn -q 100'
  10.  
  11. fileList = os.listdir()
  12. for file in fileList:
  13.     if( ".jpg" in file):
  14.         print(file)
  15.         img = Image.open(file)
  16.         size = int((float(img.size[0]) * coef)),int((float(img.size[1]) * coef))
  17.         img = img.resize(size, PIL.Image.ANTIALIAS)
  18.         img.save('smaller-'+file,quality=100)
  19.         print("waifu2x-caffe-cui.exe -i "+picFolder+"\\smaller-"+file + " -o "+picFolder+"\\waifu2x-"+file + " " + waifuOption)
  20.         sub.check_call(waifu2xCaffeExe
  21.                        + " -i "+picFolder+"\\smaller-"+file
  22.                        + " -o "+picFolder+"\\waifu2x-"+file
  23.                        + " " + waifuOption
  24.                        , shell=True)
Advertisement
Add Comment
Please, Sign In to add comment