YuvalNirkin / face_swap

End-to-end, automatic face swapping pipeline
GNU General Public License v3.0
825 stars 203 forks source link

Running demo fails #19

Closed chrischen closed 6 years ago

chrischen commented 6 years ago

Running with face_swap_image with the demo images and configuration fails with this:

[libprotobuf WARNING google/protobuf/io/coded_stream.cc:537] Reading dangerously large protocol message.  If the message turns out to be larger than 2147483647 bytes, parsing will be halted for security reasons.  To increase the limit (or to disable these warnings), see CodedInputStream::SetTotalBytesLimit() in google/protobuf/io/coded_stream.h.
[libprotobuf WARNING google/protobuf/io/coded_stream.cc:78] The total number of bytes read was 537966743
I0102 07:25:51.460321 10570 net.cpp:744] Ignoring source layer data
I0102 07:25:51.460350 10570 net.cpp:744] Ignoring source layer data_data_0_split
I0102 07:25:51.562809 10570 net.cpp:744] Ignoring source layer loss
F0102 07:25:54.356940 10570 math_functions.cu:26] Check failed: status == CUBLAS_STATUS_SUCCESS (1 vs. 0)  CUBLAS_STATUS_NOT_INITIALIZED
*** Check failure stack trace: ***
Aborted (core dumped)
YuvalNirkin commented 6 years ago

Try running on the CPU (gpu = 0).

chrischen commented 6 years ago

Here’s what I get on CPU mode:

I0102 18:40:37.848453 45822 net.cpp:242] This network produces output score
I0102 18:40:37.848487 45822 net.cpp:255] Network initialization done.
[libprotobuf WARNING google/protobuf/io/coded_stream.cc:537] Reading dangerously large protocol message.  If the message turns out to be larger than 2147483647 bytes, parsing will be halted for security reasons.  To increase the limit (or to disable these warnings), see CodedInputStream::SetTotalBytesLimit() in google/protobuf/io/coded_stream.h.
[libprotobuf WARNING google/protobuf/io/coded_stream.cc:78] The total number of bytes read was 537966743
I0102 18:41:03.311218 45822 net.cpp:744] Ignoring source layer data
I0102 18:41:03.311244 45822 net.cpp:744] Ignoring source layer data_data_0_split
I0102 18:41:03.410594 45822 net.cpp:744] Ignoring source layer loss
Segmentation fault (core dumped)

Seems to be line 168 in face_swap_image.cpp causing the seg fault so far.

if (!fs.setImages(source_img, target_img, source_seg, target_seg))
                        throw std::runtime_error("Failed to find faces in one of the images!");

Fixed the first seg fault by commenting out if (lmsFrame.faces.empty()) return false; but then another seg fault pops up later. swap_face.cpp

 bool FaceSwap::preprocessImages(const cv::Mat& img, const cv::Mat& seg,
        std::vector<cv::Point>& landmarks, std::vector<cv::Point>& cropped_landmarks,
        cv::Mat& cropped_img, cv::Mat& cropped_seg, cv::Rect& bbox)
    {
        cout << "Calculate landmarks" << endl;
        // Calculate landmarks
        m_sfl->clear();
        const sfl::Frame& lmsFrame = m_sfl->addFrame(img);
        cout << "Calculate landmarks 2" << endl;
        //if (lmsFrame.faces.empty()) return false;
        cout << "Calculate landmarks 3" << endl;