mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-02-08 00:49:56 +00:00
revise space logics
This commit is contained in:
@@ -131,6 +131,11 @@ class ForgeSpace:
|
||||
def gradio_worker(self):
|
||||
import spaces
|
||||
spaces.unload_module()
|
||||
original_cwd = os.getcwd()
|
||||
os.chdir(self.hf_path)
|
||||
|
||||
if 'models' in sys.modules:
|
||||
del sys.modules['models']
|
||||
|
||||
memory_management.unload_all_models()
|
||||
sys.path.insert(0, self.hf_path)
|
||||
@@ -155,17 +160,21 @@ class ForgeSpace:
|
||||
server_port=port
|
||||
)
|
||||
|
||||
if module_name in sys.modules:
|
||||
del sys.modules[module_name]
|
||||
|
||||
if 'models' in sys.modules:
|
||||
del sys.modules['models']
|
||||
|
||||
sys.path.remove(self.hf_path)
|
||||
sys.path.remove(self.root_path)
|
||||
os.chdir(original_cwd)
|
||||
|
||||
while self.is_running:
|
||||
time.sleep(0.1)
|
||||
|
||||
demo.close()
|
||||
self.gradio_metas = None
|
||||
|
||||
if module_name in sys.modules:
|
||||
del sys.modules[module_name]
|
||||
|
||||
sys.path.remove(self.hf_path)
|
||||
sys.path.remove(self.root_path)
|
||||
return
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user