vt-vl-lab / 3d-photo-inpainting

[CVPR 2020] 3D Photography using Context-aware Layered Depth Inpainting
https://shihmengli.github.io/3D-Photo-Inpainting/
Other
6.91k stars 1.11k forks source link

Infinite while True loop during inpainting edge; And "RuntimeError: dictionary changed size during iteration" #179

Open viridityzhu opened 1 year ago

viridityzhu commented 1 year ago

https://github.com/vt-vl-lab/3d-photo-inpainting/blob/de0446740a3726f3de76c32e78b43bd985d987f9/mesh.py#L1751-L1755

I am processing my own image using the given trained model and the default configurations, but get stuck into an infinite while loop in the above codes.

I printed out the value in node which is always (120, 355, -inf). So the problem is that when the depth value is -inf, the node stops updating. I added

if torch.isinf(node[2]):
    break

and it solved the problem. But I still wonder why the case occurs.


After I solved the above problem, I immediately met another error:

Traceback (most recent call last):
  File "main.py", line 117, in <module>
    depth_feat_model)
  File "3d-photo-inpainting/mesh.py", line 2008, in write_ply
    inpaint_iter=1)
  File "3d-photo-inpainting/mesh.py", line 1825, in DL_inpaint_edge
    for node in mesh.nodes:
RuntimeError: dictionary changed size during iteration

I think this is caused by https://github.com/vt-vl-lab/3d-photo-inpainting/blob/de0446740a3726f3de76c32e78b43bd985d987f9/mesh.py#L1802-L1812

Once mesh.remove_node(node) was executed, mesh.nodes would be changed. So I solved this by modifying Line 1802 as

for node in list(mesh.nodes):