hylee commited on
Commit
293143b
·
1 Parent(s): 136f0a0
Files changed (2) hide show
  1. APDrawingGAN2/preprocess/get_partmask.py +1 -3
  2. app.py +1 -17
APDrawingGAN2/preprocess/get_partmask.py CHANGED
@@ -7,8 +7,6 @@ from shapely.geometry import Point
7
  from shapely.geometry import Polygon
8
  import sys
9
 
10
- detector = dlib.get_frontal_face_detector()
11
- predictor = dlib.shape_predictor('../checkpoints/shape_predictor_68_face_landmarks.dat')
12
 
13
  def getfeats(featpath):
14
  trans_points = np.empty([68,2],dtype=np.int64)
@@ -53,7 +51,7 @@ def shape_to_np(shape, dtype="int"):
53
  # return the list of (x, y)-coordinates
54
  return coords
55
 
56
- def get_68lm(imgfile,savepath):
57
  image = cv2.imread(imgfile)
58
  rgbImg = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
59
  rects = detector(rgbImg, 1)
 
7
  from shapely.geometry import Polygon
8
  import sys
9
 
 
 
10
 
11
  def getfeats(featpath):
12
  trans_points = np.empty([68,2],dtype=np.int64)
 
51
  # return the list of (x, y)-coordinates
52
  return coords
53
 
54
+ def get_68lm(imgfile,savepath, detector, predictor):
55
  image = cv2.imread(imgfile)
56
  rgbImg = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
57
  rects = detector(rgbImg, 1)
app.py CHANGED
@@ -110,22 +110,6 @@ def compress_UUID():
110
  safe_code = safe_code.replace('-', '')
111
  return safe_code
112
 
113
-
114
-
115
- def get_68lm(imgfile, savepath, detector, predictor):
116
- image = cv2.imread(imgfile)
117
- rgbImg = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
118
- rects = detector(rgbImg, 1)
119
- for (i, rect) in enumerate(rects):
120
- landmarks = predictor(rgbImg, rect)
121
- landmarks = shape_to_np(landmarks)
122
- f = open(savepath, 'w')
123
- for i in range(len(landmarks)):
124
- lm = landmarks[i]
125
- print(lm[0], lm[1], file=f)
126
- f.close()
127
-
128
-
129
  def run(
130
  image,
131
  model,
@@ -152,7 +136,7 @@ def run(
152
  imgfile = os.path.join(opt.dataroot, fullname)
153
  lmfile = os.path.join(opt.lm_dir, name+'.txt')
154
  # 预处理数据
155
- get_68lm(imgfile, lmfile, detector, predictor)
156
 
157
  imgs = []
158
  for part in ['eyel', 'eyer', 'nose', 'mouth']:
 
110
  safe_code = safe_code.replace('-', '')
111
  return safe_code
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  def run(
114
  image,
115
  model,
 
136
  imgfile = os.path.join(opt.dataroot, fullname)
137
  lmfile = os.path.join(opt.lm_dir, name+'.txt')
138
  # 预处理数据
139
+ get_partmask.get_68lm(imgfile, lmfile, detector, predictor)
140
 
141
  imgs = []
142
  for part in ['eyel', 'eyer', 'nose', 'mouth']: