Spaces:
Running
on
Zero
Running
on
Zero
Upload folder using huggingface_hub
Browse files- core/model_manager.py +7 -2
- ui/layout.py +1 -0
core/model_manager.py
CHANGED
|
@@ -23,6 +23,7 @@ class ModelManager:
|
|
| 23 |
if hasattr(self, 'initialized'):
|
| 24 |
return
|
| 25 |
self.loaded_models: Dict[str, Any] = {}
|
|
|
|
| 26 |
self.initialized = True
|
| 27 |
print("✅ ModelManager initialized.")
|
| 28 |
|
|
@@ -128,7 +129,7 @@ class ModelManager:
|
|
| 128 |
required_set = set(required_models)
|
| 129 |
current_set = set(self.loaded_models.keys())
|
| 130 |
|
| 131 |
-
loras_changed =
|
| 132 |
|
| 133 |
models_to_unload = current_set - required_set
|
| 134 |
if models_to_unload or loras_changed:
|
|
@@ -136,7 +137,10 @@ class ModelManager:
|
|
| 136 |
print(f"--- [ModelManager] Models to unload: {models_to_unload} ---")
|
| 137 |
if loras_changed and not models_to_unload:
|
| 138 |
models_to_unload = current_set.intersection(required_set)
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
model_management.unload_all_models()
|
| 142 |
self.loaded_models.clear()
|
|
@@ -158,6 +162,7 @@ class ModelManager:
|
|
| 158 |
else:
|
| 159 |
print(f"--- [ModelManager] All required models are already loaded. ---")
|
| 160 |
|
|
|
|
| 161 |
return {name: self.loaded_models[name] for name in required_models}
|
| 162 |
|
| 163 |
model_manager = ModelManager()
|
|
|
|
| 23 |
if hasattr(self, 'initialized'):
|
| 24 |
return
|
| 25 |
self.loaded_models: Dict[str, Any] = {}
|
| 26 |
+
self.last_active_loras: List[Dict[str, Any]] = []
|
| 27 |
self.initialized = True
|
| 28 |
print("✅ ModelManager initialized.")
|
| 29 |
|
|
|
|
| 129 |
required_set = set(required_models)
|
| 130 |
current_set = set(self.loaded_models.keys())
|
| 131 |
|
| 132 |
+
loras_changed = active_loras != self.last_active_loras
|
| 133 |
|
| 134 |
models_to_unload = current_set - required_set
|
| 135 |
if models_to_unload or loras_changed:
|
|
|
|
| 137 |
print(f"--- [ModelManager] Models to unload: {models_to_unload} ---")
|
| 138 |
if loras_changed and not models_to_unload:
|
| 139 |
models_to_unload = current_set.intersection(required_set)
|
| 140 |
+
if active_loras:
|
| 141 |
+
print(f"--- [ModelManager] LoRA configuration changed. Reloading base model(s): {models_to_unload} ---")
|
| 142 |
+
else:
|
| 143 |
+
print(f"--- [ModelManager] LoRAs removed. Reloading base model(s) to clear patches: {models_to_unload} ---")
|
| 144 |
|
| 145 |
model_management.unload_all_models()
|
| 146 |
self.loaded_models.clear()
|
|
|
|
| 162 |
else:
|
| 163 |
print(f"--- [ModelManager] All required models are already loaded. ---")
|
| 164 |
|
| 165 |
+
self.last_active_loras = active_loras
|
| 166 |
return {name: self.loaded_models[name] for name in required_models}
|
| 167 |
|
| 168 |
model_manager = ModelManager()
|
ui/layout.py
CHANGED
|
@@ -26,6 +26,7 @@ def build_ui(event_handler_function):
|
|
| 26 |
"This demo is a streamlined version of the [Comfy web UI](https://github.com/RioShiina47/comfy-webui)'s ImgGen functionality. "
|
| 27 |
"Other versions are also available: "
|
| 28 |
"[Qwen-Image](https://huggingface.co/spaces/RioShiina/ImageGen-Qwen-Image), "
|
|
|
|
| 29 |
"[Illstrious](https://huggingface.co/spaces/RioShiina/ImageGen-Illstrious), "
|
| 30 |
"[NoobAI](https://huggingface.co/spaces/RioShiina/ImageGen-NoobAI), "
|
| 31 |
"[Pony](https://huggingface.co/spaces/RioShiina/ImageGen-Pony1), "
|
|
|
|
| 26 |
"This demo is a streamlined version of the [Comfy web UI](https://github.com/RioShiina47/comfy-webui)'s ImgGen functionality. "
|
| 27 |
"Other versions are also available: "
|
| 28 |
"[Qwen-Image](https://huggingface.co/spaces/RioShiina/ImageGen-Qwen-Image), "
|
| 29 |
+
"[NewBie-Image](https://huggingface.co/spaces/RioShiina/ImageGen-NewBie-Image), "
|
| 30 |
"[Illstrious](https://huggingface.co/spaces/RioShiina/ImageGen-Illstrious), "
|
| 31 |
"[NoobAI](https://huggingface.co/spaces/RioShiina/ImageGen-NoobAI), "
|
| 32 |
"[Pony](https://huggingface.co/spaces/RioShiina/ImageGen-Pony1), "
|