YYuanAnyVision / mxnet_mtcnn_face_detection

MTCNN face detection
738 stars 314 forks source link

RunTime Error on MacOS with Python 3.9 #58

Closed marinafridman closed 2 years ago

marinafridman commented 2 years ago

I had the same issue as another user, that was closed although it is not resolved.

When I run main.py I get a RunTime error.

        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

Some googling suggested that the freeze_support() should only be necessary on a Windows machine - I am using Mac. However, some other users also had issues where the Pool function would freeze for Python versions 3.8+. They determined that the default behavior for Pool has changed and that simply importing multiprocessing could fix it. I'm not sure if this is relevant to my case since a) their phenotype was freezing, not a RunTime error and b) the other user had this with Python 3.5 (although unspecified OS).

In any case, I have tried import multiprocessing in both main.py and mtcnn_detector.py, as well as adding the requested line

if __name__ == '__main__':
    freeze_support() 

in both scripts (in the class I put it in __init__ class) ... nothing seems to work. I keep getting the error. Help!

marinafridman commented 2 years ago

Solved this by downgrading to Python version 3.7.12.