Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable progress bars? #121

Open
xeb opened this issue Jun 9, 2022 · 14 comments
Open

Disable progress bars? #121

xeb opened this issue Jun 9, 2022 · 14 comments

Comments

@xeb
Copy link

xeb commented Jun 9, 2022

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?

@ladyshen
Copy link

ladyshen commented Jun 9, 2022 via email

@xeb
Copy link
Author

xeb commented Jun 22, 2022

太感谢了!

@amykweon
Copy link

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

@ladyshen
Copy link

ladyshen commented Jul 25, 2022 via email

@rushatrai
Copy link

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

@nguyenhoan1988
Copy link

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

@ladyshen
Copy link

ladyshen commented Aug 29, 2022 via email

@AlexandreLamb
Copy link

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

@ladyshen
Copy link

ladyshen commented Sep 16, 2022 via email

1 similar comment
@ladyshen
Copy link

ladyshen commented Oct 11, 2022 via email

@chj113
Copy link

chj113 commented Oct 18, 2023

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

@ladyshen
Copy link

ladyshen commented Oct 18, 2023 via email

@colorsolid
Copy link

colorsolid commented Feb 13, 2024

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

@ladyshen
Copy link

ladyshen commented Feb 13, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants