Download face_detect/core/stdex.py from GuijiAI/ReHiFace-S: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/GuijiAI/ReHiFace-S/resolve/refs%2Fpr%2F2/face_detect/core/stdex.py
- Command line
-
hf download hf://GuijiAI/ReHiFace-S@refs/pr/2/face_detect/core/stdex.py
-
curl -L -o stdex.py https://huggingface.co/GuijiAI/ReHiFace-S/resolve/refs%2Fpr%2F2/face_detect/core/stdex.py
1.18 kB
| import os | |
| import sys | |
| class suppress_stdout_stderr(object): | |
| def __enter__(self): | |
| self.outnull_file = open(os.devnull, 'w') | |
| self.errnull_file = open(os.devnull, 'w') | |
| self.old_stdout_fileno_undup = sys.stdout.fileno() | |
| self.old_stderr_fileno_undup = sys.stderr.fileno() | |
| self.old_stdout_fileno = os.dup ( sys.stdout.fileno() ) | |
| self.old_stderr_fileno = os.dup ( sys.stderr.fileno() ) | |
| self.old_stdout = sys.stdout | |
| self.old_stderr = sys.stderr | |
| os.dup2 ( self.outnull_file.fileno(), self.old_stdout_fileno_undup ) | |
| os.dup2 ( self.errnull_file.fileno(), self.old_stderr_fileno_undup ) | |
| sys.stdout = self.outnull_file | |
| sys.stderr = self.errnull_file | |
| return self | |
| def __exit__(self, *_): | |
| sys.stdout = self.old_stdout | |
| sys.stderr = self.old_stderr | |
| os.dup2 ( self.old_stdout_fileno, self.old_stdout_fileno_undup ) | |
| os.dup2 ( self.old_stderr_fileno, self.old_stderr_fileno_undup ) | |
| os.close ( self.old_stdout_fileno ) | |
| os.close ( self.old_stderr_fileno ) | |
| self.outnull_file.close() | |
| self.errnull_file.close() | |