FFWM icon indicating copy to clipboard operation
FFWM copied to clipboard

How to use your model to frontalize the pics in mutipie?

Open Masterzhuior opened this issue 2 years ago • 6 comments

I want to frontalize all the faces of mutipie without testing. How should I use your model? 我想使用你的模型把mutipie的人脸做frontalize,我应该怎么使用你的代码?

Masterzhuior avatar Mar 22 '22 03:03 Masterzhuior

Hi,

If you just want to get the frontalized faces without calculate the metrics, you can first modify the code of line 50-72 of test.py as follow:

 if opt.datamode == 'multipie':
     for i, data in enumerate(dataset_val):
          files = data['input_path']
          model.set_input(data)
          model.test(return_fea=False)
          for idx, name in enumerate(files):
              prefix = os.path.splitext(name)[0]
              visualizer.display_test_results(model.get_current_visuals(), 0, True, prefix, idx=idx)

and meanwhile comment the line 138 of face_dataset.py:

if self.isval:
    self.base_path = join(dataroot, 'test')
    self.files = os.listdir(join(self.base_path, 'images'))
    # self.gallery_dict = self.get_gallery()
else:
    self.base_path = join(dataroot, 'train')
    self.lm_dicts = np.load(join(self.base_path, 'landmarks.npy'), allow_pickle=True).item()
    self.files = os.listdir(join(self.base_path, 'images'))
pairs = [(file, s2f(file)) for file in self.files]

After downloading the pretrained models and preparing the multipie dataset following the README, you can run

bash test_ffwm.sh

to frontalize the multipie faces.

csyxwei avatar Mar 22 '22 03:03 csyxwei

Hi,

If you just want to get the frontalized faces without calculate the metrics, you can first modify the code of of as follow:line 50-72``test.py

 if opt.datamode == 'multipie':
     for i, data in enumerate(dataset_val):
          files = data['input_path']
          model.set_input(data)
          model.test(return_fea=False)
          for idx, name in enumerate(files):
              prefix = os.path.splitext(name)[0]
              visualizer.display_test_results(model.get_current_visuals(), 0, True, prefix, idx=idx)

and meanwhile comment the of :line 138``face_dataset.py

if self.isval:
    self.base_path = join(dataroot, 'test')
    self.files = os.listdir(join(self.base_path, 'images'))
    # self.gallery_dict = self.get_gallery()
else:
    self.base_path = join(dataroot, 'train')
    self.lm_dicts = np.load(join(self.base_path, 'landmarks.npy'), allow_pickle=True).item()
    self.files = os.listdir(join(self.base_path, 'images'))
pairs = [(file, s2f(file)) for file in self.files]

After downloading the pretrained models and preparing the multipie dataset following the README, you can run

bash test_ffwm.sh

to frontalize the multipie faces.

Where do I need to modify or add the path to save the face image after frontalization?

Masterzhuior avatar Mar 22 '22 06:03 Masterzhuior

The frontalized images are saved by the visualizer.display_test_results(). You can modify the test_dir attribute in line 76 in Visualizer.py to specific the save path. If default, it will be saved in ./checkpoints/ffwm/test/multipie.

csyxwei avatar Mar 22 '22 07:03 csyxwei

The frontalized images are saved by the visualizer.display_test_results(). You can modify the test_dir attribute in line 76 in Visualizer.py to specific the save path. If default, it will be saved in ./checkpoints/ffwm/test/multipie.

OK, thank you!

Masterzhuior avatar Mar 22 '22 07:03 Masterzhuior

The frontalized images are saved by the visualizer.display_test_results(). You can modify the test_dir attribute in line 76 in Visualizer.py to specific the save path. If default, it will be saved in ./checkpoints/ffwm/test/multipie.

By the way ,Could I use your model to convert a front face into a frontal face at any angle I set(such as 60° or 90°)?

Masterzhuior avatar Mar 23 '22 10:03 Masterzhuior

FFWM can not convert a front face into a face at given angle.

csyxwei avatar Mar 23 '22 11:03 csyxwei