Commit c535ca5f authored by Your Name's avatar Your Name

Fix image generation to properly handle diffusers vs GGUF models

- Added check in sd.cpp fallback to skip HF model IDs that are likely diffusers models
- Prevents sd.cpp from trying to download non-GGUF files like .gitattributes for diffusers models
- Tongyi-MAI/Z-Image-Turbo and similar diffusers models now handled correctly by diffusers library
- GGUF models still work with sd.cpp as before
parent 5e641ba2
...@@ -671,8 +671,19 @@ async def create_image_generation(request: ImageGenerationRequest, http_request: ...@@ -671,8 +671,19 @@ async def create_image_generation(request: ImageGenerationRequest, http_request:
elif os.path.isfile(model_to_use): elif os.path.isfile(model_to_use):
model_path = model_to_use model_path = model_to_use
else: else:
# Try to resolve as HuggingFace model ID # Check if this is a likely diffusers model (not GGUF)
print(f"Trying to resolve as HuggingFace model ID: {model_to_use}") # If it doesn't contain 'gguf' and we're in image generation context,
# it's probably a diffusers model that should be handled by the diffusers library
is_likely_diffusers = ('gguf' not in model_to_use.lower() and
not model_to_use.endswith('.gguf'))
if is_likely_diffusers:
print(f"Model '{model_to_use}' appears to be a diffusers model (not GGUF), skipping sd.cpp resolution")
print("This model should be handled by the diffusers library above")
model_path = None
else:
# Try to resolve as HuggingFace GGUF model ID
print(f"Trying to resolve as HuggingFace GGUF model ID: {model_to_use}")
try: try:
from huggingface_hub import hf_hub_download, list_repo_files from huggingface_hub import hf_hub_download, list_repo_files
...@@ -719,13 +730,12 @@ async def create_image_generation(request: ImageGenerationRequest, http_request: ...@@ -719,13 +730,12 @@ async def create_image_generation(request: ImageGenerationRequest, http_request:
model_path = hf_hub_download(repo_id=repo_id, filename=gguf_files[0]) model_path = hf_hub_download(repo_id=repo_id, filename=gguf_files[0])
print(f"Downloaded to: {model_path}") print(f"Downloaded to: {model_path}")
else: else:
# No GGUF files found, try to download the first file as fallback # No GGUF files found - this is not a GGUF model
if files: print(f"No GGUF files found in {repo_id} - this is not a GGUF model")
print(f"No GGUF files found, trying to download first file: {files[0]}") model_path = None
model_path = hf_hub_download(repo_id=repo_id, filename=files[0])
print(f"Downloaded to: {model_path}")
except Exception as e: except Exception as e:
print(f"Could not resolve as HuggingFace model: {e}") print(f"Could not resolve as HuggingFace GGUF model: {e}")
model_path = None
if model_path is None: if model_path is None:
print("Warning: Could not resolve sd.cpp model path via HuggingFace GGUF resolution") print("Warning: Could not resolve sd.cpp model path via HuggingFace GGUF resolution")
......
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