vchoutas / smplify-x

Expressive Body Capture: 3D Hands, Face, and Body from a Single Image
https://smpl-x.is.tue.mpg.de/
Other
1.75k stars 339 forks source link

FileNotFoundError: [Errno 2] No such file or directory: #20

Closed Piero-M closed 5 years ago

Piero-M commented 5 years ago

Hi, I have this problem that I can not solve the file keypoints was created with OpenPose and is present in the directory, I do not understand the reason for this error?

SMPLIFY-X) bash-3.2$ python smplifyx/main.py --config cfg_files/fit_smplx.yaml --data_folder DATA_FOLDER --output_folder OUTPUT_FOLDER --visualize="True" --model_folder models --vposer_ckpt models/vposer_v1_0
Traceback (most recent call last):
  File "smplifyx/main.py", line 272, in <module>
    main(**args)
  File "smplifyx/main.py", line 201, in main
    for idx, data in enumerate(dataset_obj):
  File "/Users/piero/Desktop/SMPLIFY-X/smplify-x/smplifyx/data_parser.py", line 206, in __next__
    return self.next()
  File "/Users/piero/Desktop/SMPLIFY-X/smplify-x/smplifyx/data_parser.py", line 215, in next
    return self.read_item(img_path)
  File "/Users/piero/Desktop/SMPLIFY-X/smplify-x/smplifyx/data_parser.py", line 185, in read_item
    use_face_contour=self.use_face_contour)
  File "/Users/piero/Desktop/SMPLIFY-X/smplify-x/smplifyx/data_parser.py", line 54, in read_keypoints
    with open(keypoint_fn) as keypoint_file:
FileNotFoundError: [Errno 2] No such file or directory: 'DATA_FOLDER/keypoints/COCO_val2014_000000000459_rendered_keypoints.json'
geopavlakos commented 5 years ago

I suspect you save the original images (e.g., image.jpg) and the ones created by OpenPose for visualization (e.g., image_rendered.jpg) in the same folder. This means that the code can find the keypoints file for the first image (image_keypoints.json), but not for the second (image_rendered_keypoints.json).

You can confirm whether the specific file is present or not by doing: ls DATA_FOLDER/keypoints/COCO_val2014_000000000459_rendered_keypoints.json

Piero-M commented 5 years ago

yes, it seems that in the DATA_FOLDER/images folder you have to put the clean image without the points obtained with open pose and put the .json file inside the keyponts folder.

but now I have another error:

(SMPLIFY-X) bash-3.2$ python smplifyx/main.py --config cfg_files/fit_smplx.yaml --data_folder DATA_FOLDER --output_folder OUTPUT_FOLDER --visualize="True" --model_folder models --vposer_ckpt models/vposer_v1_0
Processing: DATA_FOLDER/images/COCO_val2014_000000000459.jpg
Found Trained Model: models/vposer_v1_0/snapshots/TR00_E096.pt
Traceback (most recent call last):
  File "smplifyx/main.py", line 272, in <module>
    main(**args)
  File "smplifyx/main.py", line 262, in main
    **args)
  File "/Users/piero/Desktop/SMPLIFY-X/smplify-x/smplifyx/fit_single_frame.py", line 213, in fit_single_frame
    from mesh_intersection.bvh_search_tree import BVH
ModuleNotFoundError: No module named 'mesh_intersection'
geopavlakos commented 5 years ago

If you haven't been able to install the mesh_intersection package, then I would suggest setting interpenetration=False in the .yaml file. This way the code will not try to import the mesh_intersection package.

Piero-M commented 5 years ago

I still have this mistake:

python smplifyx/main.py --config cfg_files/fit_smplx.yaml --data_folder DATA_FOLDER --output_folder OUTPUT_FOLDER --visualize="True" --model_folder models --vposer_ckpt models/vposer_v1_0
Processing: DATA_FOLDER/images/COCO_val2014_000000000459.jpg
Found Trained Model: models/vposer_v1_0/snapshots/TR00_E096.pt
searching for scad in: /Users/piero/anaconda3/envs/SMPLIFY-X/bin:/Users/piero/anaconda3/condabin:/Users/piero/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Applications/OpenSCAD.app/Contents/MacOS
2019-07-15 15:51:15.855 python[40028:2921600] WARNING: NSWindow drag regions should only be invalidated on the Main Thread! This will throw an exception in the future. Called from (
    0   AppKit                              0x00007fff4f2247eb -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 378
    1   AppKit                              0x00007fff4f221bdb -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1479
    2   AppKit                              0x00007fff4f22160e -[NSWindow initWithContentRect:styleMask:backing:defer:] + 45
    3   libffi.6.dylib                      0x000000010ccd8884 ffi_call_unix64 + 76
    4   ???                                 0x0000700008a36490 0x0 + 123145447236752
)
2019-07-15 15:51:16.092 python[40028:2921600] WARNING: nextEventMatchingMask should only be called from the Main Thread! This will throw an exception in the future.
Camera initialization done after 4.2037
Camera initialization final loss 12954.2676
Orientation:   0%|                                                                                                                                           | 0/1 [00:00<?, ?it/s]
Traceback (most recent call last):                                                                                                                           | 0/5 [00:00<?, ?it/s]
  File "smplifyx/main.py", line 272, in <module>
    main(**args)
  File "smplifyx/main.py", line 262, in main
    **args)
  File "/Users/piero/Desktop/SMPLIFY-X/smplify-x/smplifyx/fit_single_frame.py", line 444, in fit_single_frame
    use_vposer=use_vposer)
  File "/Users/piero/Desktop/SMPLIFY-X/smplify-x/smplifyx/fitting.py", line 175, in run_fitting
    loss = optimizer.step(closure)
  File "/Users/piero/Desktop/SMPLIFY-X/smplify-x/smplifyx/optimizers/lbfgs_ls.py", line 280, in step
    orig_loss = closure()
  File "/Users/piero/Desktop/SMPLIFY-X/smplify-x/smplifyx/fitting.py", line 253, in fitting_func
    **kwargs)
  File "/Users/piero/anaconda3/envs/SMPLIFY-X/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in __call__
    result = self.forward(*input, **kwargs)
  File "/Users/piero/Desktop/SMPLIFY-X/smplify-x/smplifyx/fitting.py", line 372, in forward
    if self.use_joints_conf else
RuntimeError: The size of tensor a (118) must match the size of tensor b (111) at non-singleton dimension 1
geopavlakos commented 5 years ago

Based on a similar error reported here, I would suggest making sure that you extract hand and face keypoints when you use OpenPose (this can be done by activating the flags --hand and --face for the OpenPose command). Also, please make sure you use the latest OpenPose version, which extracts 25 joints for the body (BODY_25 parametrization).

Piero-M commented 5 years ago

This?

/build/examples/openpose/openpose.bin --model_pose BODY_25 --hand --face --image_dir IMAGE --write_images OUTPUT/IMAGE --write_json OUTPUT/KEYPOINT

geopavlakos commented 5 years ago

Yes, this command should generate .json files with the format anticipated by the code.

Piero-M commented 5 years ago

seems to have worked, but the Avatar seems to have different sizes, the chest is different and is always the same for both woman and man!

Schermata 2019-07-15 alle 16 20 47

geopavlakos commented 5 years ago

This is probably the neutral model. You might want to use the female model for this image (you need to set gender: "female" in the .yaml file).

Piero-M commented 5 years ago

Isn't sex automatically detected?

geopavlakos commented 5 years ago

This repo is for fitting the model to keypoints. To estimate the gender of a person you need to run the Gender Classifier.

Piero-M commented 5 years ago

perfect, thank you! You're really helping me out a lot!

One last thing:

I would like to estimate some measures from the model 3d, for example waist circumference, how can I do?

geopavlakos commented 5 years ago

I believe the answer here might be helpful.

Piero-M commented 5 years ago

thank you, but I did not understand which file to use? the .obj file that you create in the output folder OUTPUT_FOLDER/meshes?

in addition the avatar in 3d even with female set would seem slightly different. Schermata 2019-07-15 alle 17 01 09

geopavlakos commented 5 years ago

Yes, this is the final mesh output.

Piero-M commented 5 years ago

having deactivated the mesh_intersection, can I still extract the measurements?

geopavlakos commented 5 years ago

Yes, even without the mesh_intersection activated, you can still extract the measurements you want. The output mesh will probably have some slight differences from the mesh we get when mesh_intersection is active, but you will still get reasonable results.

Piero-M commented 5 years ago

ok, I use blender to extract the measurements, only blender uses .fbx files and in mesh I have files in .obj, how can I do that?

or is there a faster way?

mesh_intersection can't be installed on MAC, can it?

Piero-M commented 5 years ago

can't this be used as a mesh_intersection? Schermata 2019-07-15 alle 17 23 37

geopavlakos commented 5 years ago

This is the code you need for the mesh_intersection module. However, if you have compilation problems, then it's probably not installed successfully, so that's why you get the error you report above.

Piero-M commented 5 years ago

I performed this procedure, I don't understand what might have been wrong?

https://github.com/vchoutas/torch-mesh-isect

and I inserted the Cuda directory as from this discussion (https://github.com/vchoutas/smplify-x/issues/9), but I have error when I run setup.py

change the code:

bvh_include_dirs = torch.utils.cpp_extension.include_paths() + [
'include',
osp.expandvars('$CUDA_SAMPLES_INC')]

to

bvh_include_dirs = torch.utils.cpp_extension.include_paths() + [
    'include',
    'usr/local/cuda/samples/common/inc']

but when I'm running setup.py I get this error:

python setup.py 
No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda'
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: no commands supplied

Is something wrong?

geopavlakos commented 5 years ago

One problem is that the repo instructs you to run python setup.py install instead of python setup.py. With that being said, based on the output, CUDA seems to be complaining too. Based on responses from other people, it might be difficult to install torch-mesh-isect on a Mac machine. If this component is necessary for you, I would suggest using a linux machine, which is where we have tested our code too.

Piero-M commented 5 years ago

in command python setup.py install now gives me this mistake:

python setup.py install
No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda'
running install
running bdist_egg
running egg_info
writing mesh_intersection.egg-info/PKG-INFO
writing dependency_links to mesh_intersection.egg-info/dependency_links.txt
writing requirements to mesh_intersection.egg-info/requires.txt
writing top-level names to mesh_intersection.egg-info/top_level.txt
reading manifest file 'mesh_intersection.egg-info/SOURCES.txt'
writing manifest file 'mesh_intersection.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.7-x86_64/egg
running install_lib
running build_py
running build_ext
/Users/piero/anaconda3/envs/SMPLIFY-X/lib/python3.6/site-packages/torch/utils/cpp_extension.py:166: UserWarning: 

                               !! WARNING !!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Your compiler (g++) is not compatible with the compiler Pytorch was
built with for this platform, which is clang++ on darwin. Please
use clang++ to to compile your extension. Alternatively, you may
compile PyTorch from source using g++, and then you can also use
g++ to compile your extension.

See https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md for help
with compiling PyTorch from source.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                              !! WARNING !!

  platform=sys.platform))
building 'bvh_cuda' extension
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/piero/anaconda3/envs/SMPLIFY-X/include -arch x86_64 -I/Users/piero/anaconda3/envs/SMPLIFY-X/include -arch x86_64 -I/Users/piero/anaconda3/envs/SMPLIFY-X/lib/python3.6/site-packages/torch/include -I/Users/piero/anaconda3/envs/SMPLIFY-X/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -I/Users/piero/anaconda3/envs/SMPLIFY-X/lib/python3.6/site-packages/torch/include/TH -I/Users/piero/anaconda3/envs/SMPLIFY-X/lib/python3.6/site-packages/torch/include/THC -Iinclude -Iusr/local/cuda/samples/common/inc -I/Users/piero/anaconda3/envs/SMPLIFY-X/lib/python3.6/site-packages/torch/include -I/Users/piero/anaconda3/envs/SMPLIFY-X/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -I/Users/piero/anaconda3/envs/SMPLIFY-X/lib/python3.6/site-packages/torch/include/TH -I/Users/piero/anaconda3/envs/SMPLIFY-X/lib/python3.6/site-packages/torch/include/THC -I/usr/local/cuda/include -I/Users/piero/anaconda3/envs/SMPLIFY-X/include/python3.6m -c src/bvh.cpp -o build/temp.macosx-10.7-x86_64-3.6/src/bvh.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=bvh_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11
warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on
      the command line to use the libc++ standard library instead
      [-Wstdlibcxx-not-found]
In file included from src/bvh.cpp:18:
In file included from /Users/piero/anaconda3/envs/SMPLIFY-X/lib/python3.6/site-packages/torch/include/torch/extension.h:4:
In file included from /Users/piero/anaconda3/envs/SMPLIFY-X/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/all.h:3:
/Users/piero/anaconda3/envs/SMPLIFY-X/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/cuda.h:5:10: fatal error: 
      'cstddef' file not found
#include <cstddef>
         ^~~~~~~~~
1 warning and 1 error generated.
error: command 'gcc' failed with exit status 1
(SMPLIFY-X) bash-3.2$ 
Piero-M commented 5 years ago

without mesh_intersection the construction of the Avatar seems too approximate and I don't think it can be used to extract measurements. I can't assess if the problem is only related to mesh_intersection and on other computers the Avatar is more reliable? output copia

MichaelJBlack commented 5 years ago

The body shape comes only from the 2D joints and so it is very approximate. SMPLify-X doesn't use the silhouette or the rest of the image pixels to estimate shape. Also the SMPL-X body shape space is probably not rich enough to represent body builders.

ruchi3086 commented 5 years ago

Hi,

I get error

FileNotFoundError: [Errno 2] No such file or directory: './json/documents.json'

Though the file is there.....

piero76 commented 4 years ago

@MichaelJBlack congratulations on the work you're doing! I am trying to extract the measurements for anthropometry, which is your best method that gives more accurate results?