Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,12 +5,12 @@ import subprocess
|
|
5 |
import os
|
6 |
import datetime
|
7 |
from PIL import Image
|
8 |
-
|
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 |
-
|
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 |
-
|
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 |
-
|
34 |
-
|
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()
|