Sometimes don't use compression artifacts

This commit is contained in:
James Betker 2020-07-10 22:25:53 -06:00
parent 0b7193392f
commit ef9f1307eb

View File

@ -191,7 +191,7 @@ class LQGTDataset(data.Dataset):
# LQ needs to go to a PIL image to perform the compression-artifact transformation.
img_LQ = (img_LQ * 255).astype(np.uint8)
img_LQ = Image.fromarray(img_LQ)
if self.opt['use_compression_artifacts']:
if self.opt['use_compression_artifacts'] and random.random() > .25:
qf = random.randrange(10, 70)
corruption_buffer = BytesIO()
img_LQ.save(corruption_buffer, "JPEG", quality=qf, optimice=True)