DeepFaceLab icon indicating copy to clipboard operation
DeepFaceLab copied to clipboard

Error extracting faces from PNGs

Open BeatHarness opened this issue 7 years ago • 2 comments

Expected behavior

I am extracting faces. My source data is a set of manually copied PNG's. I expect it to create properly aligned faces in the "aligned" folder.

Actual behavior

It crashes on a series of "No Valid JPG info" errors.

Problem

There is a code path that copies the PNG to the "aligned" folder, but then it tries to embed data in the file using DFLJPG.

Which ofcourse won't work - you can't embed data in a PNG file using a JPG reader/writer :-)

If I remove the section that copies the file and instead ALWAYS write the JPG file using cv2_imwrite, it works fine.

                    `if src_dflimg is not None and output_file.suffix:
                        #if extracting from dflimg copy it in order not to lose quality
                        output_file = str(self.final_output_path / filename_path.name)
                        if str(filename_path) != str(output_file):
                            shutil.copy ( str(filename_path), str(output_file) )
                    else:
                        output_file = '{}_{}{}'.format(str(self.final_output_path / filename_path.stem), str(face_idx), '.jpg')
                        cv2_imwrite(output_file, face_image, [int(cv2.IMWRITE_JPEG_QUALITY), 85] )

                    DFLJPG.embed_data(output_file, face_type=FaceType.toString(self.face_type),
                                                   landmarks=face_image_landmarks.tolist(),
                                                   source_filename=filename_path.name,
                                                   source_rect=rect,
                                                   source_landmarks=image_landmarks.tolist(),
                                                   image_to_face_mat=image_to_face_mat,
                                                   pitch_yaw_roll=data.pitch_yaw_roll
                                        )`

BeatHarness avatar May 08 '19 09:05 BeatHarness

upload your some files to reproduce, I will fix

iperov avatar May 11 '19 13:05 iperov

nevermind, check last commit

iperov avatar May 11 '19 13:05 iperov