Determines path selection based on directory location
Models in "checkpoints" directory use model_path
Models in "diffusion_models" directory use diffusion_model_path
Includes fallback to architecture-based detection with logging
3. ModelDetectionCache Class
Thread-safe caching system for detection results
Cache validation based on file modification times
Reduces redundant model file parsing
4. Updated StableDiffusionWrapper
Uses folder-based path selection instead of architecture-based detection
Removes redundant model detection call in loadModel()
Preserves fallback mechanism for backward compatibility
5. Enhanced ModelManager
Integrates caching system during model scanning
Uses cached results when available
Implements cache invalidation when files are modified
Benefits:
Faster model loading through folder-based detection
Reduced I/O operations through caching
Better reliability with directory-based path selection
Maintained backward compatibility
Improved debugging with detailed logging
Files Modified:
include/model_manager.h
src/model_manager.cpp
src/stable_diffusion_wrapper.cpp
This implementation introduces a folder-based model detection approach and caching mechanism to improve model loading performance and reliability.
## Key Changes:
### 1. Enhanced ModelInfo Structure
- Added caching-related fields: cacheValid, cacheModifiedAt, cachePathType, useFolderBasedDetection, detectionSource
### 2. ModelPathSelector Class
- Determines path selection based on directory location
- Models in "checkpoints" directory use model_path
- Models in "diffusion_models" directory use diffusion_model_path
- Includes fallback to architecture-based detection with logging
### 3. ModelDetectionCache Class
- Thread-safe caching system for detection results
- Cache validation based on file modification times
- Reduces redundant model file parsing
### 4. Updated StableDiffusionWrapper
- Uses folder-based path selection instead of architecture-based detection
- Removes redundant model detection call in loadModel()
- Preserves fallback mechanism for backward compatibility
### 5. Enhanced ModelManager
- Integrates caching system during model scanning
- Uses cached results when available
- Implements cache invalidation when files are modified
## Benefits:
- Faster model loading through folder-based detection
- Reduced I/O operations through caching
- Better reliability with directory-based path selection
- Maintained backward compatibility
- Improved debugging with detailed logging
## Files Modified:
- include/model_manager.h
- src/model_manager.cpp
- src/stable_diffusion_wrapper.cpp
This implementation introduces a folder-based model detection approach and caching mechanism to improve model loading performance and reliability.
Key Changes:
1. Enhanced ModelInfo Structure
2. ModelPathSelector Class
3. ModelDetectionCache Class
4. Updated StableDiffusionWrapper
5. Enhanced ModelManager
Benefits:
Files Modified: