Commit 2dfbce90 authored by Your Name's avatar Your Name

Fix: Download image model on-demand if not cached

When loading image models dynamically (in ondemand mode), the code now:
1. Checks if model URL is cached
2. If not cached, downloads the model before loading

This fixes the 'Could not resolve sd.cpp model path' error when using
image models without --loadall or --loadswap flags.
parent 0a3fd1ff
...@@ -3802,8 +3802,13 @@ async def create_image_generation(request: ImageGenerationRequest, http_request: ...@@ -3802,8 +3802,13 @@ async def create_image_generation(request: ImageGenerationRequest, http_request:
if cached_path: if cached_path:
model_path = cached_path model_path = cached_path
print(f"Using cached model: {model_path}") print(f"Using cached model: {model_path}")
else:
if model_path is None and os.path.isfile(model_to_use): # Not cached - download it
print(f"Downloading model: {model_to_use}")
cache_dir = get_model_cache_dir()
model_path = download_model(model_to_use, cache_dir)
print(f"Downloaded to: {model_path}")
elif os.path.isfile(model_to_use):
model_path = model_to_use model_path = model_to_use
if model_path is None: if model_path is None:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment