xinntao / facexlib

FaceXlib aims at providing ready-to-use face-related functions based on current STOA open-source methods.
MIT License
810 stars 143 forks source link

FaceRestoreHelper seems not thread-safe #42

Open henryruhs opened 1 year ago

henryruhs commented 1 year ago

Using FaceRestoreHelper needs with threading.Semaphore() to work within threads. I experienced this first in GFPGAN and later in our custom implementations.

This limits performance of GFPGAN a lot!

I8Robot commented 1 year ago

this error:

"facexlib\utils\face_restoration_helper.py", line 151, in get_face_landmarks_5
    self.det_faces.append(bbox[0:5])
AttributeError: 'numpy.ndarray' object has no attribute 'append'"?

May I ask where to add with threading.Semaphore()? I also want to work with multithreads.

henryruhs commented 1 year ago

Just before using it, you can create the instance via threading.Lock() before. You can find our code (using gfpgan) here: https://github.com/s0md3v/roop/blob/main/roop/processors/frame/face_enhancer.py

I8Robot commented 1 year ago

Just before using it, you can create the instance via threading.Lock() before. You can find our code (using gfpgan) here: https://github.com/s0md3v/roop/blob/main/roop/processors/frame/face_enhancer.py

OK, roop :smiley: