Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,4 @@
|
|
1 |
import os
|
2 |
-
#os.system("pip uninstall -y gradio")
|
3 |
-
#os.system('pip install gradio==3.43.1')
|
4 |
import torch
|
5 |
import torchvision
|
6 |
import torchvision.transforms as transforms
|
@@ -44,6 +42,53 @@ pinverse = torch.load(f"{models_path}/files/pinverse_1000pc.pt", map_location=to
|
|
44 |
|
45 |
unet, vae, text_encoder, tokenizer, noise_scheduler = load_models(device)
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
def sample_model():
|
48 |
global unet
|
49 |
del unet
|
@@ -109,7 +154,6 @@ def inference( prompt, negative_prompt, guidance_scale, ddim_steps, seed):
|
|
109 |
@torch.no_grad()
|
110 |
@spaces.GPU
|
111 |
def edit_inference(prompt, negative_prompt, guidance_scale, ddim_steps, seed, start_noise, a1, a2, a3, a4):
|
112 |
-
start_items()
|
113 |
global device
|
114 |
#global generator
|
115 |
global unet
|
|
|
1 |
import os
|
|
|
|
|
2 |
import torch
|
3 |
import torchvision
|
4 |
import torchvision.transforms as transforms
|
|
|
42 |
|
43 |
unet, vae, text_encoder, tokenizer, noise_scheduler = load_models(device)
|
44 |
|
45 |
+
|
46 |
+
global young
|
47 |
+
global pointy
|
48 |
+
global wavy
|
49 |
+
global thick
|
50 |
+
|
51 |
+
young = get_direction(df, "Young", pinverse, 1000, device)
|
52 |
+
young = debias(young, "Male", df, pinverse, device)
|
53 |
+
young = debias(young, "Pointy_Nose", df, pinverse, device)
|
54 |
+
young = debias(young, "Wavy_Hair", df, pinverse, device)
|
55 |
+
young = debias(young, "Chubby", df, pinverse, device)
|
56 |
+
young = debias(young, "No_Beard", df, pinverse, device)
|
57 |
+
young = debias(young, "Mustache", df, pinverse, device)
|
58 |
+
|
59 |
+
|
60 |
+
pointy = get_direction(df, "Pointy_Nose", pinverse, 1000, device)
|
61 |
+
pointy = debias(pointy, "Young", df, pinverse, device)
|
62 |
+
pointy = debias(pointy, "Male", df, pinverse, device)
|
63 |
+
pointy = debias(pointy, "Wavy_Hair", df, pinverse, device)
|
64 |
+
pointy = debias(pointy, "Chubby", df, pinverse, device)
|
65 |
+
pointy = debias(pointy, "Heavy_Makeup", df, pinverse, device)
|
66 |
+
|
67 |
+
|
68 |
+
|
69 |
+
wavy = get_direction(df, "Wavy_Hair", pinverse, 1000, device)
|
70 |
+
wavy = debias(wavy, "Young", df, pinverse, device)
|
71 |
+
wavy = debias(wavy, "Male", df, pinverse, device)
|
72 |
+
wavy = debias(wavy, "Pointy_Nose", df, pinverse, device)
|
73 |
+
wavy = debias(wavy, "Chubby", df, pinverse, device)
|
74 |
+
wavy = debias(wavy, "Heavy_Makeup", df, pinverse, device)
|
75 |
+
|
76 |
+
|
77 |
+
thick = get_direction(df, "Bushy_Eyebrows", pinverse, 1000, device)
|
78 |
+
thick = debias(thick, "Male", df, pinverse, device)
|
79 |
+
thick = debias(thick, "Young", df, pinverse, device)
|
80 |
+
thick = debias(thick, "Pointy_Nose", df, pinverse, device)
|
81 |
+
thick = debias(thick, "Wavy_Hair", df, pinverse, device)
|
82 |
+
thick = debias(thick, "Mustache", df, pinverse, device)
|
83 |
+
thick = debias(thick, "No_Beard", df, pinverse, device)
|
84 |
+
thick = debias(thick, "Sideburns", df, pinverse, device)
|
85 |
+
thick = debias(thick, "Big_Nose", df, pinverse, device)
|
86 |
+
thick = debias(thick, "Big_Lips", df, pinverse, device)
|
87 |
+
thick = debias(thick, "Black_Hair", df, pinverse, device)
|
88 |
+
thick = debias(thick, "Brown_Hair", df, pinverse, device)
|
89 |
+
thick = debias(thick, "Pale_Skin", df, pinverse, device)
|
90 |
+
thick = debias(thick, "Heavy_Makeup", df, pinverse, device)
|
91 |
+
|
92 |
def sample_model():
|
93 |
global unet
|
94 |
del unet
|
|
|
154 |
@torch.no_grad()
|
155 |
@spaces.GPU
|
156 |
def edit_inference(prompt, negative_prompt, guidance_scale, ddim_steps, seed, start_noise, a1, a2, a3, a4):
|
|
|
157 |
global device
|
158 |
#global generator
|
159 |
global unet
|