joelmoniz / DepthNets

Code for "Unsupervised Depth Estimation, 3D Face Rotation and Replacement", NeurIPS 2018
MIT License
127 stars 31 forks source link

run_facewarp.py error #9

Closed lzxzy closed 5 years ago

lzxzy commented 5 years ago

when I run shell python runfacewarp.py --results_dir=frontalized_faces I got the error Segmentation fault(core dumped) It seemed the FaceWarperServer which was compiled has some problem but I through the build and cmake got nothing

So, what's the problem is this, thank you

christopher-beckham commented 5 years ago

Hi lzxzy,

Thanks for the bug report. Just some questions:

@srajotte I have added you since you'll probably have a better idea of this than I do. Would it help if we had the core dump file? (Not that I dabble in such things...)

srajotte commented 5 years ago

@srajotte I have added you since you'll probably have a better idea of this than I do. Would it help if we had the core dump file? (Not that I dabble in such things...)

For now, having the answer to the three points you mentioned would be more helpful than a core dump.

Assuming FaceWarperServer successfully compiled, a possible source of the problem is if the destination directory doesn't exist or the source files (images, keypoints, etc.) don't exist. FaceWarperServer assumes that all input files are valid and exist. If a file or the destination directory doesn't exist, there is a high probability of a crash.

I suppose the Python script that @lzxzy is using is DepthNets/cyclegan/data/celeba/run_facewarp.py. In this script, if a file doesn't exist, an error message will be printed, but the command will still be sent to FaceWarperServer. @lzxzy do you get a message starting with "PB" on the standard output before FaceWarperServer crashes?

christopher-beckham commented 5 years ago

When I was running this a while ago, the python script would simply hang if a file or directory doesn’t exist, rather than segfault. If the example command in the facewarper works, then this would imply that maybe there’s a bug in my data prep script.

srajotte commented 5 years ago

Indeed, thinking about it again, I don't think a missing file/folder would generate a Segmentation fault. In this situation, FaceWarperServer should either hang or abort, but not segfault.

Knowing if the example works correctly would really help to pinpoint the source of the problem.

lzxzy commented 5 years ago

Hi lzxzy,

Thanks for the bug report. Just some questions:

  • What operating system are you using (if Linux, what distro)?
  • Can you attach the output of cmake / make when you built the server? This might give some useful information.
  • Does the segfault still happen if you run the example as described here?

@srajotte I have added you since you'll probably have a better idea of this than I do. Would it help if we had the core dump file? (Not that I dabble in such things...)

Thanks for your reply first I run the build_linux.sh in FaceWarperServer, and I got this:

 -- The C compiler identification is GNU 5.4.0
 -- The CXX compiler identification is GNU 5.4.0
 -- Check for working C compiler: /usr/bin/cc
 -- Check for working C compiler: /usr/bin/cc -- works
 -- Detecting C compiler ABI info
 -- Detecting C compiler ABI info - done
 -- Detecting C compile features
 -- Detecting C compile features - done
 -- Check for working CXX compiler: /usr/bin/c++
 -- Check for working CXX compiler: /usr/bin/c++ -- works
 -- Detecting CXX compiler ABI info
 -- Detecting CXX compiler ABI info - done
 -- Detecting CXX compile features
 -- Detecting CXX compile features - done
 -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8") 
 -- Found PNG: /usr/lib/x86_64-linux-gnu/libpng.so (found version "1.2.54") 
 -- Found OpenGL: /usr/lib/x86_64-linux-gnu/libGL.so   
 -- Found GLUT: /usr/lib/x86_64-linux-gnu/libglut.so  
 -- Found GLEW: /usr/include  
 -- Configuring done
 -- Generating done
 -- Build files have been written to: 
 /media/liuzongxuan/disk2/workspace/github/DepthNets/FaceWarper/FaceWarperServer/build

It seems pass the build, and When I cd builddictionary , I found there nothing named FaceWarperServer, so I run the make command, finally I got this:

Scanning dependencies of target FaceWarperServer
[ 33%] Building CXX object CMakeFiles/FaceWarperServer.dir/source/FaceWarper.cpp.o
[ 66%] Building CXX object CMakeFiles/FaceWarperServer.dir/source/shader.cpp.o
[100%] Linking CXX executable FaceWarperServer
[100%] Built target FaceWarperServer

Looks make successfully also. But when I run ' python run_facewarp.py --results_dir=frontalized_faces ' I still got the problem:

/media/liuzongxuan/disk2/workspace/github/DepthNets/FaceWarper/FaceWarperServer/build/FaceWarperServer
Segmentation fault (core dumped)
srajotte commented 5 years ago

If you execute FaceWarperServer by itself (run build/FaceWarperServer), does it segfault? If you run the example, does it segfault?

lzxzy commented 5 years ago

If you execute FaceWarperServer by itself (run build/FaceWarperServer), does it segfault? If you run the example, does it segfault?

Yes , when I run FaceWarperServer, It still got segmentation fault (core dumped)

lzxzy commented 5 years ago

If you execute FaceWarperServer by itself (run build/FaceWarperServer), does it segfault? If you run the example, does it segfault?

and when run the example you raised , I got nothing. Nothing output either error imformation

srajotte commented 5 years ago

If FaceWarperServer crashes with a segfault by itself, then there is a problem with the executable.

I don't know what might cause this problem. My first hypothesis would be an incompatibility with one of the shared libraries (zlib/libpng/freeglut/opengl).

lzxzy commented 5 years ago

If FaceWarperServer crashes with a segfault by itself, then there is a problem with the executable.

I don't know what might cause this problem. My first hypothesis would be an incompatibility with one of the shared libraries (zlib/libpng/freeglut/opengl).

Ok, thanks for your reply I'll try to re-install opengllib and see what happen Thanks again

christopher-beckham commented 5 years ago

What is the operating system you're using?

Hmm so maybe ldconfig would be useful to use to figure out what versions the libraries are??

lzxzy commented 5 years ago

What is the operating system you're using?

Hmm so maybe ldconfig would be useful to use to figure out what versions the libraries are??

ubuntu 16.04 my opengl lib installed is normal but I still got the problem

lzxzy commented 5 years ago

What is the operating system you're using?

Hmm so maybe ldconfig would be useful to use to figure out what versions the libraries are??

when I use dmesg to show the error info I got this FaceWarperServe[31903]: segfault at 0 ip 0000000000000000 sp 00007ffe39459e68 error 14 in FaceWarperServer[400000+19000]

christopher-beckham commented 5 years ago

@srajotte is there an easy way for him to figure out the versions of all the libraries which the server is dependent on?

I know this doesn't help much, but if you have Ubuntu 18.04 (rather than 16.04) it should work. We've both compiled and run it successfully on this version.

srajotte commented 5 years ago

You can use ldd to know the dependencies and where the linker finds them. For example, when I run ldd -v FaceWarperServer on Ubuntu 18.04, I get the output in this file.

@lzxzy you might want to try to run this command and copy the output to see if something seems strange. Since you are using a different distribution version, the version of all the libraries will probably be different. It isn't a bad thing, but it makes spotting a problem very difficult.

Another thing that would help is run FaceWarperServer within gdb and get a backtrace.

lzxzy commented 5 years ago

You can use ldd to know the dependencies and where the linker finds them. For example, when I run ldd -v FaceWarperServer on Ubuntu 18.04, I get the output in this file.

@lzxzy you might want to try to run this command and copy the output to see if something seems strange. Since you are using a different distribution version, the version of all the libraries will probably be different. It isn't a bad thing, but it makes spotting a problem very difficult.

Another thing that would help is run FaceWarperServer within gdb and get a backtrace.

Thanks for reply, I had tried use gdb to found where the problem is , but it even can't going to the fist line in the main function, I set the break point at the first line in main function, and I run the gdb command r, it send out the same error immediately. I don't know what the problem is that can lead this. I'll use the ldd method to try to found is there any different between 16.04 and 18.04 version, tomorrow

christopher-beckham commented 5 years ago

Thanks!!! We would love to know what’s different between the two Ubuntu versions. It would really help out others in the future who may get stuck as well.

lzxzy commented 5 years ago

Thanks!!! We would love to know what’s different between the two Ubuntu versions. It would really help out others in the future who may get stuck as well.

Hi, I have tried the ldd and there are really many differents. But I can't local wihch different could lead the problem, and this is my file

srajotte commented 5 years ago

Your problem looks similar to this problem on StackOverflow. For some reason, your executable doesn't link to libpthread. If you try this command : LD_PRELOAD=/lib/x86_64-linux-gnu/libpthread.so.0 ./FaceWarperServer does FaceWarperServer execute without crashing?

lzxzy commented 5 years ago

Your problem looks similar to this problem on StackOverflow. For some reason, your executable doesn't link to libpthread. If you try this command : LD_PRELOAD=/lib/x86_64-linux-gnu/libpthread.so.0 ./FaceWarperServer does FaceWarperServer execute without crashing?

Yeah I think it's the same error as me, but I run the command nothing change. I think it maybe Nvidia driver with OpenGL occur some error or something else.

lzxzy commented 5 years ago

Your problem looks similar to this problem on StackOverflow. For some reason, your executable doesn't link to libpthread. If you try this command : LD_PRELOAD=/lib/x86_64-linux-gnu/libpthread.so.0 ./FaceWarperServer does FaceWarperServer execute without crashing?

Hi guys , tanks for your suggestions. I'm happy to tell you I solved the problem. It seems that you are right @srajotte . but ues LD_PRELOAD=/lib/x86_64-linux-gnu/libpthread.so.0 ./FaceWarperServer doesn't useful. Instead I insert a line in CMakeLists.txt: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread") and it works. Thank you guys again, I'm so excited HAHA.

srajotte commented 5 years ago

Good news! Thanks for taking the time to try to solve this problem. For future reference, this Ubuntu bug report seems to be related to the problem you experienced : https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics-drivers-319/+bug/1248642

srajotte commented 5 years ago

I have edited the CMakeLists.txt to force the compiler to use the "-pthread" flag on Linux systems.

@lzxzy could you try the fix to make sure it works on your system.

lzxzy commented 5 years ago

I have edited the CMakeLists.txt to force the compiler to use the "-pthread" flag on Linux systems.

@lzxzy could you try the fix to make sure it works on your system.

yes it works. and I have the another question. which section can I achieve face rotation in this work.

christopher-beckham commented 5 years ago

Cool if it's fixed we can close the issue.

With regard to to the face rotation, see this section of the readme in the depthnet-pytorch folder:

https://github.com/joelmoniz/DepthNets/blob/master/depthnet-pytorch/README.md#warping-a-source-face-to-a-rotating-target-face

With the export_anim_to_facewarper.py script, you can either rotate the source face directly, or warp the source face to rotations of a target face. In short, once you have the depth of the source face, you can compute the affine matrix needed to perform the rotation (there are some helper functions for that, like these here).

If you have any more questions regarding this, you can open up a new issue and we'll discuss it there.