import os from PIL import Image os.system("pip install gdown lpips gradio") os.system("gdown --id 1HKmjg6iXsWr4aFPuU0gBXPGR83wqMzq7 -O align.dat") os.system("wget https://nvlabs-fi-cdn.nvidia.com/stylegan2-ada-pytorch/pretrained/ffhq.pkl") os.system("gdown https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip") os.system("unzip ninja-linux.zip -d /usr/local/bin/") os.system("sudo update-alternatives --install /usr/bin/ninja ninja /usr/local/bin/ninja 1 --force") os.makedirs("embeddings/",exist_ok=True) os.makedirs("checkpoints/",exist_ok=True) os.makedirs("output/", exist_ok=True) os.makedirs("images/",exist_ok=True) import gradio as gr def inference(img): img.save("images/file.png") os.system("python tune.py") return Image.open("output/out.png") title = "Pivotal Tuning for Latent-based editing of Real Images" description = "Gradio Demo for Pivotal Tuning Inversion. To use it, simply upload your image. Ensure the image is 256 x 256 in size." article = "

Github Repo" gr.Interface(inference, [gr.inputs.Image(type="pil")], gr.outputs.Image(type="pil"),title=title,description=description,article=article,allow_flagging='never',allow_screenshot=False).launch(share=True) os.system("rm output/out.png")