Download utils/logging_setup.py from buildborderless/OpenSight-Deepfake-Detection-Models-Playground: direct link, hf CLI and curl.
- Browser
- Download file 614 Bytes
-
https://huggingface.co/spaces/buildborderless/OpenSight-Deepfake-Detection-Models-Playground/resolve/main/utils/logging_setup.py
- Command line
-
hf download hf://spaces/buildborderless/OpenSight-Deepfake-Detection-Models-Playground/utils/logging_setup.py
-
curl -L -o logging_setup.py https://huggingface.co/spaces/buildborderless/OpenSight-Deepfake-Detection-Models-Playground/resolve/main/utils/logging_setup.py
614 Bytes
| import logging | |
| import collections | |
| class GradioLogHandler(logging.Handler): | |
| def __init__(self, log_queue): | |
| super().__init__() | |
| self.log_queue = log_queue | |
| self.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')) | |
| def emit(self, record): | |
| self.log_queue.append(self.format(record)) | |
| def setup_gradio_logging(): | |
| log_queue = collections.deque(maxlen=1000) | |
| gradio_handler = GradioLogHandler(log_queue) | |
| logging.getLogger().setLevel(logging.INFO) | |
| logging.getLogger().addHandler(gradio_handler) | |
| return log_queue, gradio_handler | |