choyingw / SynergyNet

3DV 2021: Synergy between 3DMM and 3D Landmarks for Accurate 3D Facial Geometry
MIT License
383 stars 57 forks source link

UnboundLocalError: local variable 'tri' referenced before assignment #16

Closed zhanghm1995 closed 2 years ago

zhanghm1995 commented 2 years ago

Hello, thank your for sharing this amazing work.

When I run the python singleImage.py -f img command, I got the error that:

Process the image:  img/sample_1.jpg
Traceback (most recent call last):
  File "singleImage.py", line 129, in <module>
    main(args)
  File "singleImage.py", line 106, in main
    render(img_ori, vertices_lst, alpha=0.6, wfp=f'inference_output/rendering_overlay/{name}.jpg')
  File "~/SynergyNet/utils/render.py", line 42, in render
    overlap = render_app(ver, tri, overlap, texture=tex)
UnboundLocalError: local variable 'tri' referenced before assignment

I found that it is because the connectivity argument is None by default, but I don't know how to set it to a correct value.

zhanghm1995 commented 2 years ago

I solved this problem.

cuizhanyuan commented 2 years ago

I got the same error that.Can you tell me how to solve this problem?@zhanghm1995

yddr commented 2 years ago

Modify utils/render.py file.

def render(img, ver_lst, alpha=0.6, wfp=None, tex=None, connectivity=None):

save solid mesh rendering and alpha overlaying on images

**global tri**
if not connectivity is None:
    tri = _to_ctype(connectivity.T).astype(np.int32)

I solved this problem using this way.