Spaces:
Runtime error
Runtime error
Commit
·
ea363b1
1
Parent(s):
fd2de02
add example
Browse files- app.py +2 -1
- help_function.py +2 -0
app.py
CHANGED
@@ -15,13 +15,14 @@ title = "FaceOver - edit face with text 🐨 "
|
|
15 |
|
16 |
examples = [
|
17 |
["examples/jennifer lawrence.jpg", "dark hair smiling woman with glasses", 0.58],
|
|
|
18 |
["examples/kim kardashian.jpg", "beautiful asian woman with short haired ", 0.88],
|
19 |
["examples/Arnold Schwarzenegger.jpg", "happy man with long hair and hat", 0.44]
|
20 |
|
21 |
]
|
22 |
|
23 |
iface = gr.Interface(fn=greet,
|
24 |
-
inputs=["image", "text", gr.inputs.Slider(0.0, 1.
|
25 |
outputs="image",
|
26 |
title=title,
|
27 |
description=description,
|
|
|
15 |
|
16 |
examples = [
|
17 |
["examples/jennifer lawrence.jpg", "dark hair smiling woman with glasses", 0.58],
|
18 |
+
["examples/kim kardashian.jpg", "woman with pink wig",1.15],
|
19 |
["examples/kim kardashian.jpg", "beautiful asian woman with short haired ", 0.88],
|
20 |
["examples/Arnold Schwarzenegger.jpg", "happy man with long hair and hat", 0.44]
|
21 |
|
22 |
]
|
23 |
|
24 |
iface = gr.Interface(fn=greet,
|
25 |
+
inputs=["image", "text", gr.inputs.Slider(0.0, 1.5)],
|
26 |
outputs="image",
|
27 |
title=title,
|
28 |
description=description,
|
help_function.py
CHANGED
@@ -28,12 +28,14 @@ class help_function:
|
|
28 |
if not image.shape == torch.Size([3, 224, 224]):
|
29 |
image = image.reshape(1,3,image.shape[1],image.shape[2])
|
30 |
image = F.interpolate(image, [224,224], mode='bilinear', align_corners=True)
|
|
|
31 |
w_inversion = self.encoder(image.reshape(1,3,224,224)).reshape(1,16,512)
|
32 |
return w_inversion + self.mean_person
|
33 |
|
34 |
def get_text_delta(self,text_feachers):
|
35 |
w_delta = self.mapper_clip(text_feachers - self.mean_clip)
|
36 |
return w_delta
|
|
|
37 |
def image_from_text(self,text,image,power = 1.0):
|
38 |
w_inversion = self.get_image_inversion(image)
|
39 |
text_embedding = self.get_text_embedding(text)
|
|
|
28 |
if not image.shape == torch.Size([3, 224, 224]):
|
29 |
image = image.reshape(1,3,image.shape[1],image.shape[2])
|
30 |
image = F.interpolate(image, [224,224], mode='bilinear', align_corners=True)
|
31 |
+
|
32 |
w_inversion = self.encoder(image.reshape(1,3,224,224)).reshape(1,16,512)
|
33 |
return w_inversion + self.mean_person
|
34 |
|
35 |
def get_text_delta(self,text_feachers):
|
36 |
w_delta = self.mapper_clip(text_feachers - self.mean_clip)
|
37 |
return w_delta
|
38 |
+
|
39 |
def image_from_text(self,text,image,power = 1.0):
|
40 |
w_inversion = self.get_image_inversion(image)
|
41 |
text_embedding = self.get_text_embedding(text)
|