PTI / app.py
ucalyptus's picture
Update app.py
95f8de4
raw history blame
No virus
1.37 kB
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. Please use a cropped portrait picture for best results similar to the examples below."
article = "<p style='text-align: center'><a href='https://github.com/danielroich/PTI' target='_blank'>Github Repo</a>"
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)