Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def demo():
opt.batch_size = 1
opt.pretrain_weights = args.pretrain_weights
FaceReconstructor = Face3D()
images = tf.placeholder(name = 'input_imgs', shape = [opt.batch_size,224,224,3], dtype = tf.float32)
images = tf.compat.v1.placeholder(name = 'input_imgs', shape = [opt.batch_size,224,224,3], dtype = tf.float32)

if args.use_pb and os.path.isfile('network/FaceReconModel.pb'):
print('Using pre-trained .pb file.')
Expand All @@ -88,7 +88,7 @@ def demo():
tri = FaceReconstructor.facemodel.face_buf


with tf.Session() as sess:
with tf.compat.v1.Session() as sess:
if not args.use_pb :
restore_weights(sess,opt)

Expand Down
2 changes: 1 addition & 1 deletion face_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def Compute_norm(self,face_shape,facemodel):
v3 = tf.gather(shape,face_id[:,2], axis = 1)
e1 = v1 - v2
e2 = v2 - v3
face_norm = tf.cross(e1,e2)
face_norm = tf.compat.v1.cross(e1,e2)

face_norm = tf.nn.l2_normalize(face_norm, dim = 2) # normalized face_norm first
face_norm = tf.concat([face_norm,tf.zeros([tf.shape(face_shape)[0],1,3])], axis = 1)
Expand Down
4 changes: 2 additions & 2 deletions options.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self,model_name=None,is_train=True):
self.val_summary_path = os.path.join(self.summary_dir, 'val')
#---------------------------------------------------------------------------------------
# visible gpu settings
self.config = tf.ConfigProto()
self.config = tf.compat.v1.ConfigProto()
self.config.gpu_options.visible_device_list = '0'
self.use_pb = True
#---------------------------------------------------------------------------------------
Expand All @@ -49,7 +49,7 @@ def __init__(self,model_name=None,is_train=True):
self.boundaries = [100000]
lr = [1e-4,2e-5]
self.global_step = tf.Variable(0,name='global_step',trainable = False)
self.lr = tf.train.piecewise_constant(self.global_step,self.boundaries,lr)
self.lr = tf.compat.v1.train.piecewise_constant(self.global_step,self.boundaries,lr)
self.augment = True
self.train_maxiter = 200000
self.train_summary_iter = 50
Expand Down
6 changes: 4 additions & 2 deletions preprocess_img.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def align_img(img,lm,lm3D):
# processing the image
img_new,lm_new = resize_n_crop_img(img,lm,t,s)
lm_new = np.stack([lm_new[:,0],223 - lm_new[:,1]], axis = 1)
trans_params = np.array([w0,h0,102.0/s,t[0],t[1]])
trans_params = np.array([w0,h0,102.0/s])
trans_params = np.append(trans_params, t[0])
trans_params = np.append(trans_params, t[1])

return img_new,lm_new,trans_params

Expand Down Expand Up @@ -148,4 +150,4 @@ def preprocessing():
lm_bin.tofile(os.path.join(save_path,'lm_bin',name+'.bin'))

if __name__ == '__main__':
preprocessing()
preprocessing()
6 changes: 3 additions & 3 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ def save_obj(path,v,f,c):

# load .pb file into tensorflow graph
def load_graph(graph_filename):
with tf.gfile.GFile(graph_filename,'rb') as f:
graph_def = tf.GraphDef()
with tf.compat.v1.gfile.GFile(graph_filename,'rb') as f:
graph_def = tf.compat.v1.GraphDef()
graph_def.ParseFromString(f.read())

return graph_def
return graph_def