mtcnn icon indicating copy to clipboard operation
mtcnn copied to clipboard

Disable progress bars?

Open xeb opened this issue 3 years ago • 14 comments
trafficstars

Apologies if this is a Keras or TF issue, but how do I disable the stdout and stderr logging with mtcnn?

Example Class:

#!/usr/bin/env python
""" Face Detection Filter for Progeny """ 
from __future__ import absolute_import
from filter_base import Filter
from mtcnn import MTCNN
import os
import cv2 
import logging

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' 

class FaceDetectFilter(Filter):
    pass

    def __init__(self, threshold=0.70):
        super().__init__()
        self.threshold = threshold
        self.detector = MTCNN()
        return

    def get_faces(self, path):
        img = cv2.cvtColor(cv2.imread(path), cv2.COLOR_BGR2RGB)
        faces = self.detector.detect_faces(img)
        return faces

    def determine_class(self, imgrow):
        faces = self.get_faces(imgrow['thumb_path'])
        if faces is not None and len(faces) > 0:
            for face in faces:
                if face['confidence'] >= self.threshold:
                    return 'face'

        return 'noface'

Results in:

1/1 [==============================] - 0s 15ms/step
1/1 [==============================] - 0s 18ms/step
1/1 [==============================] - 0s 15ms/step
1/1 [==============================] - 0s 15ms/step
1/1 [==============================] - 0s 15ms/step
1/1 [==============================] - 0s 14ms/step
2/2 [==============================] - 0s 2ms/step
1/1 [==============================] - 0s 26ms/step

Logging is disabled but the (tqdm?) progress bars remain. This prevents my own tqdm progress bars from working.

Any ideas?

xeb avatar Jun 09 '22 15:06 xeb

您的邮件已接收!

ladyshen avatar Jun 09 '22 15:06 ladyshen

太感谢了!

xeb avatar Jun 22 '22 20:06 xeb

Hello, I'm experiencing the same problem. How did you fix it?

sykweon avatar Jul 25 '22 20:07 sykweon

您的邮件已接收!

ladyshen avatar Jul 25 '22 20:07 ladyshen

Have the same issue, let me know if anyone finds a solution!

adhoc-researcher avatar Aug 01 '22 16:08 adhoc-researcher

@amykweon @xeb @equ1 Those loggings are from mtcnn package. You can suppress the logging by editting the mtcnn.py file in ~/miniconda3/envs/<env_name>/lib/<python3.x>/site-packages/mtcnn/mtcnn.py (depends on your package management) or fork this repo: https://github.com/ipazc/mtcnn

Then add verbose=0 to these linse:

Line 410: out = self._pnet.predict(img_y, verbose=0)
Line 410: out = self._rnet.predict(tempimg1, verbose=0)
Line 466: out = self._onet.predict(tempimg1, verbose=0)

nguyenhoan1988 avatar Aug 29 '22 15:08 nguyenhoan1988

您的邮件已接收!

ladyshen avatar Aug 29 '22 15:08 ladyshen

Line 410: out = self._pnet.predict(img_y, verbose=0) is on Line 342

AlexandreLamb avatar Sep 16 '22 13:09 AlexandreLamb

您的邮件已接收!

ladyshen avatar Sep 16 '22 13:09 ladyshen

您的邮件已接收!

ladyshen avatar Oct 11 '22 07:10 ladyshen

I add verbose=0 in lines,but it does not work then I remove tqdm module,it is worked~

chj113 avatar Oct 18 '23 03:10 chj113

您的邮件已接收!

ladyshen avatar Oct 18 '23 03:10 ladyshen

With newer versions of keras, this has worked for me: import keras keras.utils.disable_interactive_logging() not sure exactly which version added this

colorsolid avatar Feb 13 '24 21:02 colorsolid

您的邮件已接收!

ladyshen avatar Feb 13 '24 21:02 ladyshen