Spaces:
Runtime error
Runtime error
Ahsen Khaliq
commited on
Commit
•
8d7ec90
1
Parent(s):
2e5ce3d
Update app.py
Browse files
app.py
CHANGED
@@ -65,21 +65,13 @@ plt.rcParams['figure.dpi'] = 150
|
|
65 |
|
66 |
os.system("gdown https://drive.google.com/uc?id=1-8E0PFT37v5fZs-61oIrFbNpE28Unp2y")
|
67 |
|
|
|
|
|
68 |
def inference(img):
|
69 |
aligned_face = align_face(img)
|
70 |
|
71 |
my_w = e4e_projection(aligned_face, "test.pt", device).unsqueeze(0)
|
72 |
|
73 |
-
|
74 |
-
plt.rcParams['figure.dpi'] = 150
|
75 |
-
pretrained = 'jojo' #@param ['supergirl', 'arcane_jinx', 'arcane_caitlyn', 'jojo_yasuho', 'jojo', 'disney']
|
76 |
-
#@markdown Preserve color tries to preserve color of original image by limiting family of allowable transformations. Otherwise, the stylized image will inherit the colors of the reference images, leading to heavier stylizations.
|
77 |
-
preserve_color = False
|
78 |
-
|
79 |
-
|
80 |
-
ckpt = torch.load('jojo.pt', map_location=lambda storage, loc: storage)
|
81 |
-
generator.load_state_dict(ckpt["g"], strict=False)
|
82 |
-
|
83 |
with torch.no_grad():
|
84 |
generator.eval()
|
85 |
|
@@ -95,4 +87,4 @@ description = "Gradio Demo for JoJoGAN: One Shot Face Stylization. To use it, si
|
|
95 |
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2112.11641' target='_blank'>JoJoGAN: One Shot Face Stylization</a>| <a href='https://github.com/mchong6/JoJoGAN' target='_blank'>Github Repo Pytorch</a></p> <center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_jojogan' alt='visitor badge'></center> <p style='text-align: center'>samples from repo: <img src='https://raw.githubusercontent.com/mchong6/JoJoGAN/main/teaser.jpg' alt='animation'/></p>"
|
96 |
|
97 |
examples=[['iu.jpeg']]
|
98 |
-
gr.Interface(inference, [gr.inputs.Image(type="filepath"
|
|
|
65 |
|
66 |
os.system("gdown https://drive.google.com/uc?id=1-8E0PFT37v5fZs-61oIrFbNpE28Unp2y")
|
67 |
|
68 |
+
ckpt = torch.load('jojo.pt', map_location=lambda storage, loc: storage)
|
69 |
+
generator.load_state_dict(ckpt["g"], strict=False)
|
70 |
def inference(img):
|
71 |
aligned_face = align_face(img)
|
72 |
|
73 |
my_w = e4e_projection(aligned_face, "test.pt", device).unsqueeze(0)
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
with torch.no_grad():
|
76 |
generator.eval()
|
77 |
|
|
|
87 |
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2112.11641' target='_blank'>JoJoGAN: One Shot Face Stylization</a>| <a href='https://github.com/mchong6/JoJoGAN' target='_blank'>Github Repo Pytorch</a></p> <center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_jojogan' alt='visitor badge'></center> <p style='text-align: center'>samples from repo: <img src='https://raw.githubusercontent.com/mchong6/JoJoGAN/main/teaser.jpg' alt='animation'/></p>"
|
88 |
|
89 |
examples=[['iu.jpeg']]
|
90 |
+
gr.Interface(inference, [gr.inputs.Image(type="filepath")], gr.outputs.Image(type="file"),title=title,description=description,article=article,enable_queue=True,allow_flagging=False,examples=examples).launch()
|