update basecode_layer
This commit is contained in:
parent
e9fe02f929
commit
76c26f6f9d
|
|
@ -20,6 +20,7 @@ paths:
|
||||||
|
|
||||||
prompt: red lipstick
|
prompt: red lipstick
|
||||||
resolution: 1024
|
resolution: 1024
|
||||||
|
basecode_spatial_size: 16
|
||||||
# available attributes
|
# available attributes
|
||||||
# ['Blond_Hair', 'Wavy_Hair', 'Young', 'Eyeglasses', 'Heavy_Makeup', 'Rosy_Cheeks',
|
# ['Blond_Hair', 'Wavy_Hair', 'Young', 'Eyeglasses', 'Heavy_Makeup', 'Rosy_Cheeks',
|
||||||
# 'Chubby', 'Mouth_Slightly_Open', 'Bushy_Eyebrows', 'Wearing_Lipstick', 'Smiling',
|
# 'Chubby', 'Mouth_Slightly_Open', 'Bushy_Eyebrows', 'Wearing_Lipstick', 'Smiling',
|
||||||
|
|
|
||||||
7
model.py
7
model.py
|
|
@ -13,7 +13,7 @@ import hydra
|
||||||
from omegaconf import DictConfig, OmegaConf
|
from omegaconf import DictConfig, OmegaConf
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
sys.path.append('./pixel2style2pixel')
|
import numpy as np
|
||||||
|
|
||||||
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
||||||
|
|
||||||
|
|
@ -72,6 +72,8 @@ class GanAttack(nn.Module):
|
||||||
nn.ReLU(inplace=True),
|
nn.ReLU(inplace=True),
|
||||||
nn.Linear(4096, 512)
|
nn.Linear(4096, 512)
|
||||||
)
|
)
|
||||||
|
basecode_layer = int(np.log2(cfg.basecode_spatial_size) - 2) * 2
|
||||||
|
self.basecode_layer=basecode_layer = f'x{basecode_layer-1:02d}'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -82,7 +84,8 @@ class GanAttack(nn.Module):
|
||||||
x_prompt=torch.cat([basecode,prompt],dim=2)
|
x_prompt=torch.cat([basecode,prompt],dim=2)
|
||||||
x_prompt=self.mlp(x_prompt)
|
x_prompt=self.mlp(x_prompt)
|
||||||
x=x_prompt+x
|
x=x_prompt+x
|
||||||
result_images=self.generator.synthesis(detailcode,randomize_noise=False,basecode=x)['image']
|
result_images=self.generator.synthesis(detailcode,randomize_noise=False,
|
||||||
|
basecode_layer=self.basecode_layer,basecode=x)['image']
|
||||||
|
|
||||||
|
|
||||||
return result_images,x
|
return result_images,x
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue