hasibzunair commited on
Commit
dd96563
β€’
1 Parent(s): 608a2d0

update app.py

Browse files
.gitignore CHANGED
@@ -1,6 +1,12 @@
1
  # Custom
2
  .DS_Store
 
 
 
 
 
3
 
 
4
 
5
  # Byte-compiled / optimized / DLL files
6
  __pycache__/
1
  # Custom
2
  .DS_Store
3
+ Data_preprocessing/
4
+ pose/
5
+ inputs/
6
+ results/
7
+ checkpoints/
8
 
9
+ *.pth
10
 
11
  # Byte-compiled / optimized / DLL files
12
  __pycache__/
app.py CHANGED
@@ -2,6 +2,7 @@ import numpy as np
2
  import os
3
  import time
4
  import sys
 
5
  import gradio as gr
6
  import u2net_load
7
  import u2net_run
@@ -20,36 +21,45 @@ print(f"####Using {device}.#####")
20
 
21
 
22
  # Make directories
23
- os.system("mkdir ./Data_preprocessing")
24
- os.system("mkdir ./Data_preprocessing/test_color")
25
- os.system("mkdir ./Data_preprocessing/test_colormask")
26
- os.system("mkdir ./Data_preprocessing/test_edge")
27
- os.system("mkdir ./Data_preprocessing/test_img")
28
- os.system("mkdir ./Data_preprocessing/test_label")
29
- os.system("mkdir ./Data_preprocessing/test_mask")
30
- os.system("mkdir ./Data_preprocessing/test_pose")
31
- os.system("mkdir ./inputs")
32
- os.system("mkdir ./inputs/img")
33
- os.system("mkdir ./inputs/cloth")
34
- os.system("mkdir ./saved_models/u2net")
35
- os.system("mkdir ./saved_models/u2netp")
36
- os.system("mkdir ./pose")
37
- os.system("mkdir ./checkpoints")
 
 
 
38
 
39
  # Get pose model
40
- os.system("wget -O ./pose/pose_deploy_linevec.prototxt https://github.com/hasibzunair/fifa-demo/releases/download/v1.0/pose_deploy_linevec.prototxt")
41
- os.system("wget -O ./pose/pose_iter_440000.caffemodel https://github.com/hasibzunair/fifa-demo/releases/download/v1.0/pose_iter_440000.caffemodel")
 
 
42
 
43
  # For segmentation mask generation
44
- os.system("wget https://github.com/hasibzunair/fifa-demo/releases/download/v1.0/lip_final.pth")
 
45
 
46
  # Get U-2-Net weights
47
- os.system("wget -P saved_models/u2netp/ https://github.com/hasibzunair/fifa-demo/releases/download/v1.0/u2netp.pth")
48
- os.system("wget -P saved_models/u2net/ https://github.com/hasibzunair/fifa-demo/releases/download/v1.0/u2net.pth")
 
 
49
 
50
  # Get model checkpoints
51
- os.system("wget -O ./checkpoints/decavtonfifapretrain.zip https://github.com/hasibzunair/vton-demo/releases/download/v1.0/decavtonfifapretrain.zip")
52
- os.system("unzip ./checkpoints/decavtonfifapretrain.zip -d ./checkpoints/")
 
53
 
54
  print("########################Setup done!########################")
55
 
@@ -95,7 +105,7 @@ def inference(clothing_image, person_image, remove_bg):
95
  print('Resized image in {}s'.format(resize_time-start_time))
96
 
97
  # 2. Get parsed person image (test_label), uses person image
98
- os.system("python3 Self-Correction-Human-Parsing-for-ACGPN/simple_extractor.py --dataset 'lip' --model-restore 'lip_final.pth' --input-dir 'Data_preprocessing/test_img' --output-dir 'Data_preprocessing/test_label'")
99
  parse_time = time.time()
100
  print('Parsing generated in {}s'.format(parse_time-resize_time))
101
 
2
  import os
3
  import time
4
  import sys
5
+ import torch
6
  import gradio as gr
7
  import u2net_load
8
  import u2net_run
21
 
22
 
23
  # Make directories
24
+ if not os.path.exists("./Data_preprocessing"):
25
+ os.system("mkdir ./Data_preprocessing")
26
+ os.system("mkdir ./Data_preprocessing/test_color")
27
+ os.system("mkdir ./Data_preprocessing/test_colormask")
28
+ os.system("mkdir ./Data_preprocessing/test_edge")
29
+ os.system("mkdir ./Data_preprocessing/test_img")
30
+ os.system("mkdir ./Data_preprocessing/test_label")
31
+ os.system("mkdir ./Data_preprocessing/test_mask")
32
+ os.system("mkdir ./Data_preprocessing/test_pose")
33
+ os.system("mkdir ./inputs")
34
+ os.system("mkdir ./inputs/img")
35
+ os.system("mkdir ./inputs/cloth")
36
+ os.system("mkdir ./saved_models/")
37
+ os.system("mkdir ./saved_models/u2net")
38
+ os.system("mkdir ./saved_models/u2netp")
39
+ os.system("mkdir ./pose")
40
+ os.system("mkdir ./checkpoints")
41
+
42
 
43
  # Get pose model
44
+ if not os.path.exists("./pose/pose_deploy_linevec.prototxt"):
45
+ os.system("wget -O ./pose/pose_deploy_linevec.prototxt https://github.com/hasibzunair/fifa-demo/releases/download/v1.0/pose_deploy_linevec.prototxt")
46
+ if not os.path.exists("./pose/pose_iter_440000.caffemodel"):
47
+ os.system("wget -O ./pose/pose_iter_440000.caffemodel https://github.com/hasibzunair/fifa-demo/releases/download/v1.0/pose_iter_440000.caffemodel")
48
 
49
  # For segmentation mask generation
50
+ if not os.path.exists("lip_final.pth"):
51
+ os.system("wget https://github.com/hasibzunair/fifa-demo/releases/download/v1.0/lip_final.pth")
52
 
53
  # Get U-2-Net weights
54
+ if not os.path.exists("saved_models/u2netp/u2netp.pth"):
55
+ os.system("wget -P saved_models/u2netp/ https://github.com/hasibzunair/fifa-demo/releases/download/v1.0/u2netp.pth")
56
+ if not os.path.exists("saved_models/u2net/u2net.pth"):
57
+ os.system("wget -P saved_models/u2net/ https://github.com/hasibzunair/fifa-demo/releases/download/v1.0/u2net.pth")
58
 
59
  # Get model checkpoints
60
+ if not os.path.exists("./checkpoints/"):
61
+ os.system("wget -O ./checkpoints/decavtonfifapretrain.zip https://github.com/hasibzunair/vton-demo/releases/download/v1.0/decavtonfifapretrain.zip")
62
+ os.system("unzip ./checkpoints/decavtonfifapretrain.zip -d ./checkpoints/")
63
 
64
  print("########################Setup done!########################")
65
 
105
  print('Resized image in {}s'.format(resize_time-start_time))
106
 
107
  # 2. Get parsed person image (test_label), uses person image
108
+ os.system("python Self-Correction-Human-Parsing-for-ACGPN/simple_extractor.py --dataset 'lip' --model-restore 'lip_final.pth' --input-dir 'Data_preprocessing/test_img' --output-dir 'Data_preprocessing/test_label'")
109
  parse_time = time.time()
110
  print('Parsing generated in {}s'.format(parse_time-resize_time))
111
 
inputs/cloth/cloth.png DELETED
Binary file (47.2 kB)
inputs/img/person.png DELETED
Binary file (42.8 kB)
results/test/refined_cloth/person.png DELETED
Binary file (26.2 kB)
results/test/try-on/person.png DELETED
Binary file (44.4 kB)
results/test/warped_cloth/person.png DELETED
Binary file (31.2 kB)
saved_models/face_detection_cv2/haarcascade_frontalface_default.xml DELETED
The diff for this file is too large to render. See raw diff