mtcnn
mtcnn copied to clipboard
Disable progress bars?
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?
您的邮件已接收!
太感谢了!
Hello, I'm experiencing the same problem. How did you fix it?
您的邮件已接收!
Have the same issue, let me know if anyone finds a solution!
@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)
您的邮件已接收!
Line 410: out = self._pnet.predict(img_y, verbose=0) is on Line 342
您的邮件已接收!
您的邮件已接收!
I add verbose=0 in lines,but it does not work then I remove tqdm module,it is worked~
您的邮件已接收!
With newer versions of keras, this has worked for me:
import keras
keras.utils.disable_interactive_logging()
not sure exactly which version added this
您的邮件已接收!