Spaces:
Runtime error
Runtime error
Merge branch 'main' of https://huggingface.co/spaces/Reeve/Ohayou_Face
Browse files
1.png
ADDED
2.png
ADDED
3.png
ADDED
4.png
ADDED
5.png
ADDED
app.py
CHANGED
@@ -19,13 +19,13 @@ pretransform = transforms.Compose([
|
|
19 |
def pipeline(img):
|
20 |
img = model_build.img_preprocess(img, pretransform)
|
21 |
with torch.no_grad():
|
22 |
-
|
23 |
img = stylegan2(latent_space, noise_mode='none')
|
24 |
img = Image.fromarray(np.array((img.permute(0, 2, 3, 1) * 127.5 + 128).clamp(0, 255).to(torch.uint8).squeeze(0)[20:-20,:,:]))
|
25 |
img.save('output.png')
|
26 |
return 'output.png'
|
27 |
|
28 |
-
examples=[['
|
29 |
-
description="
|
30 |
gr.Interface(pipeline, [gr.inputs.Image(type="pil")], gr.outputs.Image(type="file"),description=description,allow_flagging=False,examples=examples,allow_screenshot=False,enable_queue=False).launch()
|
31 |
|
|
|
19 |
def pipeline(img):
|
20 |
img = model_build.img_preprocess(img, pretransform)
|
21 |
with torch.no_grad():
|
22 |
+
latent_space = psp(img.float(), randomize_noise=True, resize=False, return_latents=True)
|
23 |
img = stylegan2(latent_space, noise_mode='none')
|
24 |
img = Image.fromarray(np.array((img.permute(0, 2, 3, 1) * 127.5 + 128).clamp(0, 255).to(torch.uint8).squeeze(0)[20:-20,:,:]))
|
25 |
img.save('output.png')
|
26 |
return 'output.png'
|
27 |
|
28 |
+
examples=[['1.png',False], ['2.png', False], ['3.png', False], ['4.png', False], ['5.png', False]]
|
29 |
+
description="이미지 업로드 후 연필모양 아이콘 누르면 정사각형으로 자르기 할 수 있습니다. 디테일은 좀 떨어짐. 얼굴 각도(?)에 따라 잘 안될수도 있음. After uploading the image, you can square crop."
|
30 |
gr.Interface(pipeline, [gr.inputs.Image(type="pil")], gr.outputs.Image(type="file"),description=description,allow_flagging=False,examples=examples,allow_screenshot=False,enable_queue=False).launch()
|
31 |
|
model_build.py
CHANGED
@@ -21,7 +21,7 @@ from models.psp import pSp
|
|
21 |
|
22 |
def build_stylegan2(
|
23 |
increment = 0.01,
|
24 |
-
network_pkl = 'pretrained/
|
25 |
process = 'image', #['image', 'interpolation','truncation','interpolation-truncation']
|
26 |
random_seed = 0,
|
27 |
diameter = 100.0,
|
@@ -54,7 +54,7 @@ def build_stylegan2(
|
|
54 |
def build_psp():
|
55 |
test_opts = easydict.EasyDict({
|
56 |
# arguments for inference script
|
57 |
-
'checkpoint_path' : 'pretrained/
|
58 |
'couple_outputs' : False,
|
59 |
'resize_outputs' : False,
|
60 |
|
|
|
21 |
|
22 |
def build_stylegan2(
|
23 |
increment = 0.01,
|
24 |
+
network_pkl = 'pretrained/ohayou_face.pkl',
|
25 |
process = 'image', #['image', 'interpolation','truncation','interpolation-truncation']
|
26 |
random_seed = 0,
|
27 |
diameter = 100.0,
|
|
|
54 |
def build_psp():
|
55 |
test_opts = easydict.EasyDict({
|
56 |
# arguments for inference script
|
57 |
+
'checkpoint_path' : 'pretrained/ohayou_face.pt',
|
58 |
'couple_outputs' : False,
|
59 |
'resize_outputs' : False,
|
60 |
|