radames commited on
Commit
eab2fda
1 Parent(s): 04a4626

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -9
app.py CHANGED
@@ -5,12 +5,12 @@ import subprocess
5
  import os
6
  import datetime
7
  from PIL import Image
8
- # from remove_bg import RemoveBackground
9
 
10
  net_C = hf_hub_download("radames/PIFu-upright-standing", filename="net_C")
11
  net_G = hf_hub_download("radames/PIFu-upright-standing", filename="net_G")
12
 
13
- # remove_bg = RemoveBackground()
14
 
15
  env = {
16
  **os.environ,
@@ -24,15 +24,11 @@ def process(img_path):
24
  base = os.path.basename(img_path)
25
  img_name = os.path.splitext(base)[0]
26
  print("image name", img_name)
27
- #img = Image.open(img_path)
28
  # remove background
29
- #print("remove background")
30
- #foreground = Image.fromarray(remove_bg.inference(img), 'RGBA')
31
- #foreground.save("./PIFu/inputs/" + img_name + ".png")
32
  print("remove background")
33
- subprocess.Popen(["backgroundremover", "-i", img_path, "-o", f'./PIFu/inputs/{img_name}.png']).communicate()
34
- print("remove background Done")
35
-
36
  print("align mask with input training image")
37
  subprocess.Popen(["python", "./apps/crop_img.py", "--input_image",
38
  f'./inputs/{img_name}.png', "--out_path", "./inputs"], cwd="PIFu").communicate()
 
5
  import os
6
  import datetime
7
  from PIL import Image
8
+ from remove_bg import RemoveBackground
9
 
10
  net_C = hf_hub_download("radames/PIFu-upright-standing", filename="net_C")
11
  net_G = hf_hub_download("radames/PIFu-upright-standing", filename="net_G")
12
 
13
+ remove_bg = RemoveBackground()
14
 
15
  env = {
16
  **os.environ,
 
24
  base = os.path.basename(img_path)
25
  img_name = os.path.splitext(base)[0]
26
  print("image name", img_name)
27
+ img = Image.open(img_path)
28
  # remove background
 
 
 
29
  print("remove background")
30
+ foreground = Image.fromarray(remove_bg.inference(img), 'RGBA')
31
+ foreground.save("./PIFu/inputs/" + img_name + ".png")
 
32
  print("align mask with input training image")
33
  subprocess.Popen(["python", "./apps/crop_img.py", "--input_image",
34
  f'./inputs/{img_name}.png', "--out_path", "./inputs"], cwd="PIFu").communicate()