From db0b87597d322696780a1364fe529ed343f786ff Mon Sep 17 00:00:00 2001 From: k4yt3x Date: Sun, 4 Sep 2022 21:41:57 +0000 Subject: [PATCH] added rich console patch for Google Colab --- video2x/video2x.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/video2x/video2x.py b/video2x/video2x.py index e67abb4..7e8d30b 100755 --- a/video2x/video2x.py +++ b/video2x/video2x.py @@ -27,7 +27,7 @@ __ __ _ _ ___ __ __ Name: Video2X Creator: K4YT3X Date Created: February 24, 2018 -Last Modified: August 28, 2022 +Last Modified: September 4, 2022 Editor: BrianPetkovsek Last Modified: June 17, 2019 @@ -41,6 +41,7 @@ Last Modified: March 23, 2020 import ctypes import math +import os import signal import sys import time @@ -164,8 +165,14 @@ class Video2X: original_stdout = sys.stdout original_stderr = sys.stderr + # detect if the program is running in Google Colab + # COLAB_GPU should be set in Colab runtime environments + in_colab = os.environ.get("COLAB_GPU") is not None + # create console for rich's Live display - console = Console() + # force_jupyter must be True if the script is running in Colab + # other wise the console will not print properly + console = Console(force_jupyter=True if in_colab is True else None) # redirect STDOUT and STDERR to console sys.stdout = FileProxy(console, sys.stdout) @@ -433,4 +440,4 @@ class Video2X: ProcessingMode.INTERPOLATE, processes, (threshold, algorithm), - ) \ No newline at end of file + )