Logical Error: Image display (.show()) placed inside loop, causing multiple windows for multi-face images

Author: sid090704Created Nov 25, 2025Updated Nov 25, 2025

Bug Report: Logical and Efficiency Errors in Feature Drawing Script

Summary

The provided script for drawing facial features onto an image contains two primary issues: a logical error that causes multiple image viewer windows to open when processing multi-face images, and a minor efficiency issue related to object creation inside the processing loop.


1. Major Logical Error: Repeated Image Display

The function calls pil_image.show() inside the main processing loop (for face_landmarks in face_landmarks_list:).

Problem: If the input image contains $N$ faces, the pil_image.show() line executes $N$ times. This results in $N$ separate image viewer windows being opened, which is unnecessary and poor user experience.

Code Context:

for face_landmarks in face_landmarks_list:
    # ... (Drawing commands)
    pil_image.show()  # <--- PROBLEM LINE

Suggested Fix: The image should only be shown once after all facial features across all faces have been drawn and the loop is complete. Move pil_image.show() to the end of the script, outside the for loop.

Source: ageitgey/face_recognition