Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeated inpainting leads to saturated pixels #22

Open
matigekunstintelligentie opened this issue Sep 6, 2022 · 0 comments
Open

Repeated inpainting leads to saturated pixels #22

matigekunstintelligentie opened this issue Sep 6, 2022 · 0 comments

Comments

@matigekunstintelligentie
Copy link

matigekunstintelligentie commented Sep 6, 2022

Repeated inpainting leads to saturated pixels. Quick and dirty example:

import subprocess
import os
import numpy as np
from PIL import Image, ImageDraw
import shutil

directory = lambda x: "./Diffusion/Diffusion_{}/".format(x)

for i in range(240):
	if i!=0:
		if os.path.exists(directory(i)):
			shutil.rmtree(directory(i))
for i in range(240):
	im = Image.new('RGB', (512, 512), (0, 0, 0))
	draw = ImageDraw.Draw(im)

	x = np.random.randint(512-128)
	y = np.random.randint(512-128)

	draw.rectangle([(x,y),(x+128,y+128)], fill=(255, 255, 255))
	im.save('{}Diffusion_mask.png'.format(directory(i)))

	os.mkdir(directory(i+1))
	subprocess.run('python scripts/inpaint.py --steps 20 --indir {} --outdir {}'.format(directory(i),directory(i+1)), shell=True)
	
	im = Image.open('{}Diffusion.png'.format(directory(i+1)))
	
	# pixels = 2
	# im = im.crop((pixels, pixels, 512-pixels, 512-pixels))
	# im = im.resize((512,512), resample=Image.BICUBIC, box=None, reducing_gap=None)
	# im.save('{}Diffusion.png'.format(directory(i+1)))
	im.save('./DiffusionOut/{0:06d}.png'.format(i))
	if i!=0:
		shutil.rmtree(directory(i))

Add folders/files:
./Diffusion/Diffusion_0/Diffusion.png
./DiffusionOut/

In scripts/inpainting changing

inpainted = inpainted.cpu().numpy().transpose(0,2,3,1)[0]*255

To

inpainted = np.round(inpainted.cpu().numpy().transpose(0,2,3,1)[0]*255)

Fixes the issue I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant