ipazc / mtcnn

MTCNN face detection implementation for TensorFlow, as a PIP package.
MIT License
2.18k stars 526 forks source link

Prevent mtcnn logging #128

Open freedom9393 opened 5 months ago

freedom9393 commented 5 months ago

When I test mtcnn with huge number of images, it shows long logs:

1/1 [==============================] - 0s 11ms/step
1/1 [==============================] - 0s 12ms/step
1/1 [==============================] - 0s 12ms/step
1/1 [==============================] - 0s 11ms/step
1/1 [==============================] - 0s 11ms/step
1/1 [==============================] - 0s 11ms/step
3/3 [==============================] - 0s 1ms/step
1/1 [==============================] - 0s 11ms/step
1/1 [==============================] - 0s 10ms/step
1/1 [==============================] - 0s 12ms/step
1/1 [==============================] - 0s 12ms/step
1/1 [==============================] - 0s 11ms/step
1/1 [==============================] - 0s 10ms/step
1/1 [==============================] - 0s 10ms/step
1/1 [==============================] - 0s 10ms/step

and I think this process consumes more time. So, is there any way to prevent showing logs and testing faster?

ladyshen commented 5 months ago

您的邮件已接收!

saleweaver commented 1 month ago

Yes please!

ladyshen commented 1 month ago

您的邮件已接收!

saleweaver commented 1 month ago

@freedom9393 the only thing that worked for me is to surpress everything those methods output...

@contextmanager
def suppress_stdout_stderr():
    with open(os.devnull, "w") as devnull:
        old_stdout = sys.stdout
        old_stderr = sys.stderr
        sys.stdout = devnull
        sys.stderr = devnull
        try:
            yield
        finally:
            sys.stdout = old_stdout
            sys.stderr = old_stderr

And use like

with suppress_stdout_stderr():
    results = detector.detect_faces(rgb_frame)
wpritom commented 1 week ago

is it originating from the mtcnn library or any other supporting library? I tried to dig in but didn't find it in the mtcnn library.

ladyshen commented 1 week ago

您的邮件已接收!

saleweaver commented 1 week ago

is it originating from the mtcnn library or any other supporting library? I tried to dig in but didn't find it in the mtcnn library.

I think it's from an underlying library. I found no output whatsoever from this one.

wpritom commented 1 week ago

is it originating from the mtcnn library or any other supporting library? I tried to dig in but didn't find it in the mtcnn library.

I think it's from an underlying library. I found no output whatsoever from this one.

Yes. The issue can be solved manually here. However, verbose flag should be added in the MTCNN library too.

121