cleardusk / 3DDFA_V2

The official PyTorch implementation of Towards Fast, Accurate and Stable 3D Dense Face Alignment, ECCV 2020.
MIT License
2.9k stars 514 forks source link

fix bugs on render without background #92

Closed ngoanpv closed 3 years ago

ngoanpv commented 3 years ago

Hi author,

When I render without background on depth.py and render.py, the NumPy array without contiguous will make an error as bellow

ValueError: ndarray is not C-contiguous

So I change the zeros array to a contiguous array by using np.ascontiguousarray

overlap = np.ascontiguousarray(np.zeros_like(img))

cleardusk commented 3 years ago

Not reproduced. The testing is OK for me. Could you please provide a script for reproducing the error?

ngoanpv commented 3 years ago

I follow the demo on Google Colab link from this repo with my image. Here is the picture I test: https://github.com/ngoanpv/3DDFA_V2/raw/master/docs/images/IMG_0852.JPG I run this code:

# reconstruct vertices and render
ver_lst = tddfa.recon_vers(param_lst, roi_box_lst, dense_flag=dense_flag)
render(img, ver_lst, tddfa.tri, alpha=0.6, show_flag=True, with_bg_flag=False);

the error is as bellow image

cleardusk commented 3 years ago

I use your tested image, and modify with_bg_flag to False in below code, https://github.com/cleardusk/3DDFA_V2/blob/b7558fac95366e91de41cffaa17a10273e35d199/demo.py#L72 then, I run

python3 demo.py -f examples/inputs/IMG_0852.JPG -o depth

The running is without error and the result is below: IMG_0852_depth

ngoanpv commented 3 years ago

I think the problem from the Colab environment, not the bug on this repo. I close this pull request now. Thank you for your time.

cleardusk commented 3 years ago

Anyone, thanks for your warmth on this repo : )