Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -153,10 +153,9 @@ def inference( prompt, negative_prompt, guidance_scale, ddim_steps, seed):
|
|
| 153 |
|
| 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 network
|
| 160 |
global unet
|
| 161 |
global vae
|
| 162 |
global text_encoder
|
|
@@ -250,49 +249,7 @@ def sample_then_run():
|
|
| 250 |
torch.save(network.proj, "model.pt" )
|
| 251 |
return image, "model.pt"
|
| 252 |
|
| 253 |
-
|
| 254 |
-
def start_items():
|
| 255 |
-
print("Starting items")
|
| 256 |
-
global young
|
| 257 |
-
global pointy
|
| 258 |
-
global wavy
|
| 259 |
-
global thick
|
| 260 |
-
young = get_direction(df, "Young", pinverse, 1000, device)
|
| 261 |
-
young = debias(young, "Male", df, pinverse, device)
|
| 262 |
-
young = debias(young, "Pointy_Nose", df, pinverse, device)
|
| 263 |
-
young = debias(young, "Wavy_Hair", df, pinverse, device)
|
| 264 |
-
young = debias(young, "Chubby", df, pinverse, device)
|
| 265 |
-
young = debias(young, "No_Beard", df, pinverse, device)
|
| 266 |
-
young = debias(young, "Mustache", df, pinverse, device)
|
| 267 |
-
|
| 268 |
-
pointy = get_direction(df, "Pointy_Nose", pinverse, 1000, device)
|
| 269 |
-
pointy = debias(pointy, "Young", df, pinverse, device)
|
| 270 |
-
pointy = debias(pointy, "Male", df, pinverse, device)
|
| 271 |
-
pointy = debias(pointy, "Wavy_Hair", df, pinverse, device)
|
| 272 |
-
pointy = debias(pointy, "Chubby", df, pinverse, device)
|
| 273 |
-
pointy = debias(pointy, "Heavy_Makeup", df, pinverse, device)
|
| 274 |
-
|
| 275 |
-
wavy = get_direction(df, "Wavy_Hair", pinverse, 1000, device)
|
| 276 |
-
wavy = debias(wavy, "Young", df, pinverse, device)
|
| 277 |
-
wavy = debias(wavy, "Male", df, pinverse, device)
|
| 278 |
-
wavy = debias(wavy, "Pointy_Nose", df, pinverse, device)
|
| 279 |
-
wavy = debias(wavy, "Chubby", df, pinverse, device)
|
| 280 |
-
wavy = debias(wavy, "Heavy_Makeup", df, pinverse, device)
|
| 281 |
-
|
| 282 |
-
thick = get_direction(df, "Bushy_Eyebrows", pinverse, 1000, device)
|
| 283 |
-
thick = debias(thick, "Male", df, pinverse, device)
|
| 284 |
-
thick = debias(thick, "Young", df, pinverse, device)
|
| 285 |
-
thick = debias(thick, "Pointy_Nose", df, pinverse, device)
|
| 286 |
-
thick = debias(thick, "Wavy_Hair", df, pinverse, device)
|
| 287 |
-
thick = debias(thick, "Mustache", df, pinverse, device)
|
| 288 |
-
thick = debias(thick, "No_Beard", df, pinverse, device)
|
| 289 |
-
thick = debias(thick, "Sideburns", df, pinverse, device)
|
| 290 |
-
thick = debias(thick, "Big_Nose", df, pinverse, device)
|
| 291 |
-
thick = debias(thick, "Big_Lips", df, pinverse, device)
|
| 292 |
-
thick = debias(thick, "Black_Hair", df, pinverse, device)
|
| 293 |
-
thick = debias(thick, "Brown_Hair", df, pinverse, device)
|
| 294 |
-
thick = debias(thick, "Pale_Skin", df, pinverse, device)
|
| 295 |
-
thick = debias(thick, "Heavy_Makeup", df, pinverse, device)
|
| 296 |
|
| 297 |
class CustomImageDataset(Dataset):
|
| 298 |
def __init__(self, images, transform=None):
|
|
@@ -528,7 +485,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
| 528 |
sample.click(fn=sample_then_run, outputs=[input_image, file_output])
|
| 529 |
|
| 530 |
submit.click(
|
| 531 |
-
fn=edit_inference, inputs=[prompt, negative_prompt, cfg, steps, seed, injection_step, a1, a2, a3, a4], outputs=[gallery]
|
| 532 |
)
|
| 533 |
file_input.change(fn=file_upload, inputs=file_input, outputs = gallery)
|
| 534 |
|
|
|
|
| 153 |
|
| 154 |
@torch.no_grad()
|
| 155 |
@spaces.GPU
|
| 156 |
+
def edit_inference(network, prompt, negative_prompt, guidance_scale, ddim_steps, seed, start_noise, a1, a2, a3, a4):
|
| 157 |
global device
|
| 158 |
#global generator
|
|
|
|
| 159 |
global unet
|
| 160 |
global vae
|
| 161 |
global text_encoder
|
|
|
|
| 249 |
torch.save(network.proj, "model.pt" )
|
| 250 |
return image, "model.pt"
|
| 251 |
|
| 252 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
|
| 254 |
class CustomImageDataset(Dataset):
|
| 255 |
def __init__(self, images, transform=None):
|
|
|
|
| 485 |
sample.click(fn=sample_then_run, outputs=[input_image, file_output])
|
| 486 |
|
| 487 |
submit.click(
|
| 488 |
+
fn=edit_inference, inputs=[network, prompt, negative_prompt, cfg, steps, seed, injection_step, a1, a2, a3, a4], outputs=[gallery]
|
| 489 |
)
|
| 490 |
file_input.change(fn=file_upload, inputs=file_input, outputs = gallery)
|
| 491 |
|