Spaces:
Runtime error
Runtime error
main
Browse files1 unmodified line2345678111 unmodified lines1201211221231241251 unmodified lineimport gradio as grimport torchimport numpy as npimport randomfrom PIL import Imagefrom accelerate import Acceleratorimport os111 unmodified lineswidth, height = img.sizeif width == height:img = img.resize((self.size, self.size), Image.LANCZOS)else:1 unmodified line234567111 unmodified lines1191201211221231241251261271281291301 unmodified lineimport gradio as grimport torchimport numpy as npfrom PIL import Imagefrom accelerate import Acceleratorimport os111 unmodified lineswidth, height = img.size# Convert to RGB to remove transparency, fill with white background if necessaryif img.mode in ('RGBA', 'LA') or (img.mode == 'P' and 'transparency' in img.info):background = Image.new("RGB", img.size, (fill, fill, fill))background.paste(img, mask=img.split()[-1]) # Use alpha channel as maskimg = backgroundif width == height:img = img.resize((self.size, self.size), Image.LANCZOS)else:
gradio_app.py+6-1