Skip to content

The CPU usage reaches 100% and the program gets stuck in an infinite loop. #56

Description

@samyzhh

After locating the issue through the stack trace, it's found that the following code has fallen into an infinite loop.
Current thread 0x00007fdbd0fe9640 (most recent call first):
File "/home/samy/.local/lib/python3.10/site-packages/facexlib/detection/retinaface_utils.py", line 27 in forward
File "/home/samy/.local/lib/python3.10/site-packages/facexlib/detection/retinaface.py", line 160 in __detect_faces
File "/home/samy/.local/lib/python3.10/site-packages/facexlib/detection/retinaface.py", line 205 in detect_faces
File "/home/samy/.local/lib/python3.10/site-packages/facexlib/utils/face_restoration_helper.py", line 139 in get_face_landmarks_5
File "/home/samy/.local/lib/python3.10/site-packages/gfpgan/utils.py", line 111 in enhance
File "/home/samy/.local/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115 in decorate_context
...

code:

 def forward(self):
    anchors = []
    for k, f in enumerate(self.feature_maps):
        min_sizes = self.min_sizes[k]
        for i, j in product(range(f[0]), range(f[1])):
            for min_size in min_sizes:
                s_kx = min_size / self.image_size[1]
                s_ky = min_size / self.image_size[0]
                dense_cx = [x * self.steps[k] / self.image_size[1] for x in [j + 0.5]]  #This line of code is stuck in an infinite loop.
                dense_cy = [y * self.steps[k] / self.image_size[0] for y in [i + 0.5]]
                for cy, cx in product(dense_cy, dense_cx):
                    anchors += [cx, cy, s_kx, s_ky]

    # back to torch land
    output = torch.Tensor(anchors).view(-1, 4)
    if self.clip:
        output.clamp_(max=1, min=0)
    return output

Environment versions:
Name: gfpgan Version: 1.3.8
Name: facexlib Version: 0.3.0
Name: torch Version: 2.0.1+cu118

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions