From db435c1fddf4d451e4946e8fe21ede751eda1d62 Mon Sep 17 00:00:00 2001 From: Jaikinator Date: Sat, 25 Nov 2023 15:18:09 +0100 Subject: [PATCH] removed file --- scraibe/app/activity_tracker.py | 37 --------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 scraibe/app/activity_tracker.py diff --git a/scraibe/app/activity_tracker.py b/scraibe/app/activity_tracker.py deleted file mode 100644 index 5cced3b..0000000 --- a/scraibe/app/activity_tracker.py +++ /dev/null @@ -1,37 +0,0 @@ -""" -This file contains the functions which are related to monitoring the actual app usage. -Therefore, the app is to be more efficient in the usage of the resources. -By for example, unloading or reloading the model. -""" -import time -import threading -import torch -import gc -import gradio as gr - - -timeout = 30 #seconds -USER_ACTIVE = True -user_active_lock = threading.Lock() # dummy for now - -# Create a thread to monitor user activity -def monitor_activity(model, pipe, timeout=timeout): - global USER_ACTIVE - - while True: - time.sleep(timeout) # Check user activity every second - with user_active_lock: - - if not USER_ACTIVE: - del model - del pipe - - gc.collect() - torch.cuda.empty_cache() - - - - print("Model deleted empty memory") - gr.Warning("Model unloaded due to inactivity. Please reload the model to continue.") - break - USER_ACTIVE = False \ No newline at end of file