mtcnn icon indicating copy to clipboard operation
mtcnn copied to clipboard

Prevent mtcnn logging

Open freedom9393 opened this issue 1 year ago • 8 comments

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?

freedom9393 avatar Mar 31 '24 05:03 freedom9393

您的邮件已接收!

ladyshen avatar Mar 31 '24 05:03 ladyshen

Yes please!

saleweaver avatar Jul 20 '24 17:07 saleweaver

您的邮件已接收!

ladyshen avatar Jul 20 '24 17:07 ladyshen

@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)

saleweaver avatar Jul 20 '24 19:07 saleweaver

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.

wpritom avatar Aug 28 '24 10:08 wpritom

您的邮件已接收!

ladyshen avatar Aug 28 '24 10:08 ladyshen

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.

saleweaver avatar Aug 28 '24 11:08 saleweaver

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

wpritom avatar Aug 28 '24 11:08 wpritom