mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-04-29 18:51:31 +00:00
revise space logics
This commit is contained in:
@@ -131,6 +131,11 @@ class ForgeSpace:
|
|||||||
def gradio_worker(self):
|
def gradio_worker(self):
|
||||||
import spaces
|
import spaces
|
||||||
spaces.unload_module()
|
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()
|
memory_management.unload_all_models()
|
||||||
sys.path.insert(0, self.hf_path)
|
sys.path.insert(0, self.hf_path)
|
||||||
@@ -155,17 +160,21 @@ class ForgeSpace:
|
|||||||
server_port=port
|
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:
|
while self.is_running:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
demo.close()
|
demo.close()
|
||||||
self.gradio_metas = None
|
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
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user