Procházet zdrojové kódy

Fix VAE path resolution logic in model_manager.cpp

- Resolve VAE filename to full path using getModelTypeDirectory(ModelType::VAE)
- Add validation to check if VAE file exists before setting the path
- Use absolute paths in console output for debugging
- Continue without VAE if file doesn't exist (maintains current behavior)

Fixes issue where VAE file was being searched in wrong directory (build directory)
instead of correct VAE directory (/data/SD_MODELS/vae/)
Fszontagh před 3 měsíci
rodič
revize
a449bee1fc
1 změnil soubory, kde provedl 17 přidání a 1 odebrání
  1. 17 1
      src/model_manager.cpp

+ 17 - 1
src/model_manager.cpp

@@ -662,7 +662,23 @@ bool ModelManager::loadModel(const std::string& name, const std::string& path, M
                 // Set additional model paths based on detection
                 // VAE is now optional for SD1x and SDXL models, but we still set it if available
                 if (!detection.recommendedVAE.empty()) {
-                    loadParams.vaePath = detection.recommendedVAE;
+                    // Resolve VAE filename to full path using the VAE directory
+                    std::string vaeDirectory = getModelTypeDirectory(ModelType::VAE);
+                    if (!vaeDirectory.empty()) {
+                        std::string resolvedVAEPath = vaeDirectory + "/" + detection.recommendedVAE;
+                        
+                        // Check if the resolved VAE file exists before setting the path
+                        if (fs::exists(resolvedVAEPath) && fs::is_regular_file(resolvedVAEPath)) {
+                            loadParams.vaePath = resolvedVAEPath;
+                            std::cout << "Using VAE: " << fs::absolute(resolvedVAEPath).string() << std::endl;
+                        } else {
+                            std::cout << "VAE file not found: \"" << fs::absolute(resolvedVAEPath).string()
+                                      << "\" - continuing without VAE" << std::endl;
+                            // Don't set vaePath if file doesn't exist, continue without VAE
+                        }
+                    } else {
+                        std::cerr << "VAE directory not configured - continuing without VAE" << std::endl;
+                    }
                 }
 
                 // Apply other suggested parameters (only for fields that exist in GenerationParams)