From 0cd6e00155505d8f6ebbcc17c136dba26d299966 Mon Sep 17 00:00:00 2001 From: Alexandre Zanni Date: Thu, 4 Jan 2024 17:08:32 +0100 Subject: [PATCH 1/5] fix(utils.py): update tensorflow method --- utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils.py b/utils.py index 4083363..8f6fda6 100644 --- a/utils.py +++ b/utils.py @@ -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 \ No newline at end of file + return graph_def From 5fab52669a7d84286daaff115c1e141ae95f677c Mon Sep 17 00:00:00 2001 From: Alexandre Zanni Date: Thu, 4 Jan 2024 17:09:59 +0100 Subject: [PATCH 2/5] fix(preprocess_img.py): avoid numpy array error --- preprocess_img.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/preprocess_img.py b/preprocess_img.py index efbbe05..f6ab2c8 100644 --- a/preprocess_img.py +++ b/preprocess_img.py @@ -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 @@ -148,4 +150,4 @@ def preprocessing(): lm_bin.tofile(os.path.join(save_path,'lm_bin',name+'.bin')) if __name__ == '__main__': - preprocessing() \ No newline at end of file + preprocessing() From 8244c22e932fea9de174ff66f4e0fd2103a683e8 Mon Sep 17 00:00:00 2001 From: Alexandre Zanni Date: Thu, 4 Jan 2024 17:11:09 +0100 Subject: [PATCH 3/5] fix(options.py): update tensorflow method --- options.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/options.py b/options.py index 6a551fc..43aca50 100644 --- a/options.py +++ b/options.py @@ -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 #--------------------------------------------------------------------------------------- @@ -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 From 0aed31b1ad5ec4d63fa1013873cefd4c12c1b15b Mon Sep 17 00:00:00 2001 From: Alexandre Zanni Date: Thu, 4 Jan 2024 17:12:15 +0100 Subject: [PATCH 4/5] Update face_decoder.py --- face_decoder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/face_decoder.py b/face_decoder.py index 77ce28b..f03c0ef 100644 --- a/face_decoder.py +++ b/face_decoder.py @@ -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) From ba92088ce0efae747f0e2c4ba6c40a789e7f48d8 Mon Sep 17 00:00:00 2001 From: Alexandre Zanni Date: Thu, 4 Jan 2024 17:14:31 +0100 Subject: [PATCH 5/5] fix(demo.py): update tensorflow method --- demo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demo.py b/demo.py index 8431ac7..92783cf 100644 --- a/demo.py +++ b/demo.py @@ -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.') @@ -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)