Reevee commited on
Commit
2b9a75c
2 Parent(s): f47bc05 0f8fc17

Merge branch 'main' of https://huggingface.co/spaces/Reeve/Ohayou_Face

Browse files
Files changed (7) hide show
  1. 1.png +0 -0
  2. 2.png +0 -0
  3. 3.png +0 -0
  4. 4.png +0 -0
  5. 5.png +0 -0
  6. app.py +3 -3
  7. model_build.py +2 -2
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
- _, 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=[['momoi_out.png',False], ['churuki_out.png', False], ['fgfgfggf.png', False], ['dsfd.png', False]]
29
- description="The male image doesn't work well. 1:1 ratio image recommended (square cropable after uploading). If the background is not monochromatic, it can be mixed with hair color. It takes an average of 5 seconds, but it can take longer if there is a lot of traffic. 남성 이미지에는 잘 작동하지 않음. 1:1비율 권장(업로드 후 정사각형 자르기 가능), 배경이 단색이 아니면 머리색과 섞일 수 있음. 트래픽이 많으면 5초 이상 걸릴 있음. Email:krkmfn@gmail.com"
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/furry.pkl',
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/psp.pt',
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