muelea / shapy

CVPR 2022 - Official code repository for the paper: Accurate 3D Body Shape Regression using Metric and Semantic Attributes.
https://shapy.is.tue.mpg.de/
298 stars 45 forks source link

Working Colab Notebook #2

Closed nicholaslocascio closed 1 year ago

nicholaslocascio commented 2 years ago

Can you provide a colab notebook with a proper setup?

I tried but was unable to get it working.

A few issues:

  1. Running shapy/data/download_data.sh as instructed in INSTALL.md fails b/c there is no data folder, and hence no download_data.sh. I tried using wget directly by running wget --post-data "username=$username&password=$password" 'https://download.is.tue.mpg.de/download.php?domain=shapy&sfile=shapy_data.zip' -O './shapy_data.zip' --no-check-certificate --continue but that did not work either.
  2. Colab uses python 3.7 and shapy uses python 3.8. This leads to pip requirement versions that are impossible to satisfy. ``ERROR: Could not find a version that satisfies the requirement fvcore==0.1.5 (from versions: 0.1.dev191230, ...) ERROR: No matching distribution found for fvcore==0.1.5```

I was able to fix the pip issues by relaxing the versions of Pillow, PyYAML and fvcore, so the pip install succeeded.

But when I run

%cd /content/shapy/regressor
! python demo.py --save-vis true --save-params true --save-mesh true --split test --datasets openpose --output-folder samples/shapy_fit/ --exp-cfg configs/b2a_expose_hrnet_demo.yaml --exp-opts output_folder=../data/trained_models/shapy/SHAPY_A part_key=pose datasets.pose.openpose.data_folder=../samples datasets.pose.openpose.img_folder=images  datasets.pose.openpose.keyp_folder=openpose datasets.batch_size=1 datasets.pose_shape_ratio=1.0

I get the following error.

INFO - 2022-06-17 20:33:28,903 - acceleratesupport - No OpenGL_accelerate module loaded: No module named 'OpenGL_accelerate'
Traceback (most recent call last):
  File "demo.py", line 24, in <module>
    from human_shape.models.build import build_model
  File "/content/shapy/regressor/human_shape/models/__init__.py", line 1, in <module>
    from .build import build_model
  File "/content/shapy/regressor/human_shape/models/build.py", line 10, in <module>
    from .body_heads import build_body_head, BODY_HEAD_REGISTRY
  File "/content/shapy/regressor/human_shape/models/body_heads/__init__.py", line 3, in <module>
    from .body_heads import *
  File "/content/shapy/regressor/human_shape/models/body_heads/body_heads.py", line 13, in <module>
    from ..common.iterative_regressor import HMRLikeRegressor
  File "/content/shapy/regressor/human_shape/models/common/iterative_regressor.py", line 21, in <module>
    from body_measurements import BodyMeasurements
  File "/usr/local/lib/python3.7/dist-packages/mesh_mesh_intersection-0.2.0-py3.7-linux-x86_64.egg/body_measurements/__init__.py", line 1, in <module>
    from .body_measurements import BodyMeasurements
  File "/usr/local/lib/python3.7/dist-packages/mesh_mesh_intersection-0.2.0-py3.7-linux-x86_64.egg/body_measurements/body_measurements.py", line 6, in <module>
    from mesh_mesh_intersection import MeshMeshIntersection
  File "/usr/local/lib/python3.7/dist-packages/mesh_mesh_intersection-0.2.0-py3.7-linux-x86_64.egg/mesh_mesh_intersection/__init__.py", line 18, in <module>
    from .mesh_mesh_intersection import MeshMeshIntersection
  File "/usr/local/lib/python3.7/dist-packages/mesh_mesh_intersection-0.2.0-py3.7-linux-x86_64.egg/mesh_mesh_intersection/mesh_mesh_intersection.py", line 28, in <module>
    import mesh_mesh_intersect_cuda
ImportError: /usr/local/lib/python3.7/dist-packages/mesh_mesh_intersection-0.2.0-py3.7-linux-x86_64.egg/mesh_mesh_intersect_cuda.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZNK2at10TensorBase8data_ptrIdEEPT_v

I think this indicates a cuda mismatch?

Colab cuda version is V11.1.105:

! /usr/local/cuda/bin/nvcc --version 
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Mon_Oct_12_20:09:46_PDT_2020
Cuda compilation tools, release 11.1, V11.1.105
Build cuda_11.1.TC455_06.29190527_0

Here is my notebook: https://colab.research.google.com/drive/15M3KpSCX_pvI5yv40spzvYiLXlDRUXf4?usp=sharing

muelea commented 2 years ago

Hi!

Thanks for pointing that out. Indeed some files were missing. The install instructions and files are updated.

Question 1: Edit: I just figured out that the data folder + script were missing. It's updated now. If the script doesn't work you can manually register and download the data from our website. Install instructions are updated.

Question 2: If don't specify the CUDA version, pip install torch==1.7.1 torchvision==0.8.2 will use CUDA 10.2, see here. Only CUDA 10.2 was tested, but CUDA 11.1 as well with the correct torch versions: pip install torch==1.10.1+cu111 torchvision==0.11.2+cu111 -f https://download.pytorch.org/whl/torch_stable.html torchmetrics==0.2.0 pytorch-lightning==1.3.0rc1

nicholaslocascio commented 2 years ago

Thanks for the making the fixes to the data folder and to the requirements.txt folder. I gave the notebook run another try and here are the results.

Following the instructions, the notebook now fails on the same demo.py run command with:

INFO - 2022-06-24 04:25:00,958 - utils - NumExpr defaulting to 8 threads.
INFO - 2022-06-24 04:25:01,206 - acceleratesupport - OpenGL_accelerate module loaded
INFO - 2022-06-24 04:25:01,211 - arraydatatype - Using accelerated ArrayDatatype
Traceback (most recent call last):
  File "demo.py", line 24, in <module>
    from human_shape.models.build import build_model
  File "/content/shapy/regressor/human_shape/models/__init__.py", line 1, in <module>
    from .build import build_model
  File "/content/shapy/regressor/human_shape/models/build.py", line 10, in <module>
    from .body_heads import build_body_head, BODY_HEAD_REGISTRY
  File "/content/shapy/regressor/human_shape/models/body_heads/__init__.py", line 3, in <module>
    from .body_heads import *
  File "/content/shapy/regressor/human_shape/models/body_heads/body_heads.py", line 13, in <module>
    from ..common.iterative_regressor import HMRLikeRegressor
  File "/content/shapy/regressor/human_shape/models/common/iterative_regressor.py", line 37, in <module>
    from attributes import A2B, B2A
  File "/usr/local/lib/python3.7/dist-packages/shape_attributes-0.2.0-py3.7.egg/attributes/__init__.py", line 1, in <module>
    # -*- coding: utf-8 -*-
ModuleNotFoundError: No module named 'attributes.attributes_betas'

I then modified

from .attributes.attributes_betas.a2b import A2B, A2BProbabilistic

to be

from attributes_betas.a2b import A2B, A2BProbabilistic

and then go the new error:

Traceback (most recent call last):
  File "demo.py", line 8, in <module>
    from attributes.utils.config import parse_args
  File "/content/shapy/attributes/attributes/__init__.py", line 1, in <module>
    from .attributes_betas.a2b import A2B, A2BProbabilistic
  File "/content/shapy/attributes/attributes/attributes_betas/a2b.py", line 16, in <module>
    import pytorch_lightning as pl
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/__init__.py", line 28, in <module>
    from pytorch_lightning import metrics  # noqa: E402
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/__init__.py", line 15, in <module>
    from pytorch_lightning.metrics.classification import (  # noqa: F401
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/classification/__init__.py", line 14, in <module>
    from pytorch_lightning.metrics.classification.accuracy import Accuracy  # noqa: F401
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/classification/accuracy.py", line 18, in <module>
    from pytorch_lightning.metrics.utils import deprecated_metrics
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/utils.py", line 29, in <module>
    from pytorch_lightning.utilities import rank_zero_deprecation
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/__init__.py", line 18, in <module>
    from pytorch_lightning.utilities.apply_func import move_data_to_device  # noqa: F401
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/apply_func.py", line 28, in <module>
    if _compare_version("torchtext", operator.ge, "0.9.0"):
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/imports.py", line 53, in _compare_version
    pkg = importlib.import_module(package)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/local/lib/python3.7/dist-packages/torchtext/__init__.py", line 7, in <module>
    from . import datasets
  File "/usr/local/lib/python3.7/dist-packages/torchtext/datasets/__init__.py", line 3, in <module>
    from .ag_news import AG_NEWS
  File "/usr/local/lib/python3.7/dist-packages/torchtext/datasets/ag_news.py", line 5, in <module>
    from torchtext.data.datasets_utils import (
  File "/usr/local/lib/python3.7/dist-packages/torchtext/data/datasets_utils.py", line 11, in <module>
    from torch.utils.data import functional_datapipe, IterDataPipe
ImportError: cannot import name 'functional_datapipe' from 'torch.utils.data' (/usr/local/lib/python3.7/dist-packages/torch/utils/data/__init__.py)

I checked the torch version and it was

import torch
torch.__version__
>>> 1.7.1

which is the correct version that requirements.txt specifies. Do you have a working docker image to share? Happy to take a look and dive deeper to resolve this issues if so.

muelea commented 2 years ago

I tested the installation on my local machine and it worked perfectly fine. Since in colab, the CUDA and python versions are different from the ones I tested, you might need to change some package versions to resolve the 'functional_datapipe' import error.

Instead of changing the imports manually, better use export PYTHONPATH=$PYTHONPATH:$(pwd)/attributes/.

Can you try it on your local machine with the tested CUDA and python versions? Below is the install command, just replace [YOUR-CUDA-10.2-FOLDER] with your local cuda installation. If that doesn't work I am happy to work on a docker image.

git clone git@github.com:muelea/shapy.git
cd shapy

export PYTHONPATH=$PYTHONPATH:$(pwd)/attributes/
export CUDA_HOME=[YOUR-CUDA-10.2-FOLDER]

python3.8 -m venv .venv/shapy
source .venv/shapy/bin/activate
pip install -r requirements.txt

cd attributes
python setup.py install

cd ../mesh-mesh-intersection
export CUDA_SAMPLES_INC=$(pwd)/include
pip install -r requirements.txt
python setup.py install
Drexregion commented 2 months ago

Hey

Thanks for the making the fixes to the data folder and to the requirements.txt folder. I gave the notebook run another try and here are the results.

Following the instructions, the notebook now fails on the same demo.py run command with:

INFO - 2022-06-24 04:25:00,958 - utils - NumExpr defaulting to 8 threads.
INFO - 2022-06-24 04:25:01,206 - acceleratesupport - OpenGL_accelerate module loaded
INFO - 2022-06-24 04:25:01,211 - arraydatatype - Using accelerated ArrayDatatype
Traceback (most recent call last):
  File "demo.py", line 24, in <module>
    from human_shape.models.build import build_model
  File "/content/shapy/regressor/human_shape/models/__init__.py", line 1, in <module>
    from .build import build_model
  File "/content/shapy/regressor/human_shape/models/build.py", line 10, in <module>
    from .body_heads import build_body_head, BODY_HEAD_REGISTRY
  File "/content/shapy/regressor/human_shape/models/body_heads/__init__.py", line 3, in <module>
    from .body_heads import *
  File "/content/shapy/regressor/human_shape/models/body_heads/body_heads.py", line 13, in <module>
    from ..common.iterative_regressor import HMRLikeRegressor
  File "/content/shapy/regressor/human_shape/models/common/iterative_regressor.py", line 37, in <module>
    from attributes import A2B, B2A
  File "/usr/local/lib/python3.7/dist-packages/shape_attributes-0.2.0-py3.7.egg/attributes/__init__.py", line 1, in <module>
    # -*- coding: utf-8 -*-
ModuleNotFoundError: No module named 'attributes.attributes_betas'

I then modified

from .attributes.attributes_betas.a2b import A2B, A2BProbabilistic

to be

from attributes_betas.a2b import A2B, A2BProbabilistic

and then go the new error:

Traceback (most recent call last):
  File "demo.py", line 8, in <module>
    from attributes.utils.config import parse_args
  File "/content/shapy/attributes/attributes/__init__.py", line 1, in <module>
    from .attributes_betas.a2b import A2B, A2BProbabilistic
  File "/content/shapy/attributes/attributes/attributes_betas/a2b.py", line 16, in <module>
    import pytorch_lightning as pl
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/__init__.py", line 28, in <module>
    from pytorch_lightning import metrics  # noqa: E402
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/__init__.py", line 15, in <module>
    from pytorch_lightning.metrics.classification import (  # noqa: F401
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/classification/__init__.py", line 14, in <module>
    from pytorch_lightning.metrics.classification.accuracy import Accuracy  # noqa: F401
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/classification/accuracy.py", line 18, in <module>
    from pytorch_lightning.metrics.utils import deprecated_metrics
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/utils.py", line 29, in <module>
    from pytorch_lightning.utilities import rank_zero_deprecation
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/__init__.py", line 18, in <module>
    from pytorch_lightning.utilities.apply_func import move_data_to_device  # noqa: F401
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/apply_func.py", line 28, in <module>
    if _compare_version("torchtext", operator.ge, "0.9.0"):
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/imports.py", line 53, in _compare_version
    pkg = importlib.import_module(package)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/local/lib/python3.7/dist-packages/torchtext/__init__.py", line 7, in <module>
    from . import datasets
  File "/usr/local/lib/python3.7/dist-packages/torchtext/datasets/__init__.py", line 3, in <module>
    from .ag_news import AG_NEWS
  File "/usr/local/lib/python3.7/dist-packages/torchtext/datasets/ag_news.py", line 5, in <module>
    from torchtext.data.datasets_utils import (
  File "/usr/local/lib/python3.7/dist-packages/torchtext/data/datasets_utils.py", line 11, in <module>
    from torch.utils.data import functional_datapipe, IterDataPipe
ImportError: cannot import name 'functional_datapipe' from 'torch.utils.data' (/usr/local/lib/python3.7/dist-packages/torch/utils/data/__init__.py)

I checked the torch version and it was

import torch
torch.__version__
>>> 1.7.1

which is the correct version that requirements.txt specifies. Do you have a working docker image to share? Happy to take a look and dive deeper to resolve this issues if so.

Hey Nicholas,

Where you able to successfully run it on google collab?