deleted external prebuild stuffs, reload model if vae changed - otherwise the vae model not loading
6 files modified
10 files deleted
| | |
| | | *.out |
| | | *.app |
| | | vcpkg_installed |
| | | build/ |
| | | build/ |
| | | external/stable-diffusion.cpp/** |
| | |
| | | {
|
| | | "files.associations": {
|
| | | "algorithm": "cpp",
|
| | | "array": "cpp",
|
| | | "atomic": "cpp",
|
| | | "bit": "cpp",
|
| | | "bitset": "cpp",
|
| | | "cctype": "cpp",
|
| | | "charconv": "cpp",
|
| | | "chrono": "cpp",
|
| | | "clocale": "cpp",
|
| | | "cmath": "cpp",
|
| | | "compare": "cpp",
|
| | | "concepts": "cpp",
|
| | | "coroutine": "cpp",
|
| | | "cstddef": "cpp",
|
| | | "cstdint": "cpp",
|
| | | "cstdio": "cpp",
|
| | | "cstdlib": "cpp",
|
| | | "cstring": "cpp",
|
| | | "ctime": "cpp",
|
| | | "cwchar": "cpp",
|
| | | "deque": "cpp",
|
| | | "exception": "cpp",
|
| | | "filesystem": "cpp",
|
| | | "format": "cpp",
|
| | | "forward_list": "cpp",
|
| | | "fstream": "cpp",
|
| | | "functional": "cpp",
|
| | | "hash_map": "cpp",
|
| | | "hash_set": "cpp",
|
| | | "initializer_list": "cpp",
|
| | | "iomanip": "cpp",
|
| | | "ios": "cpp",
|
| | | "iosfwd": "cpp",
|
| | | "iostream": "cpp",
|
| | | "istream": "cpp",
|
| | | "iterator": "cpp",
|
| | | "limits": "cpp",
|
| | | "list": "cpp",
|
| | | "locale": "cpp",
|
| | | "map": "cpp",
|
| | | "memory": "cpp",
|
| | | "new": "cpp",
|
| | | "numeric": "cpp",
|
| | | "optional": "cpp",
|
| | | "ostream": "cpp",
|
| | | "queue": "cpp",
|
| | | "ranges": "cpp",
|
| | | "ratio": "cpp",
|
| | | "source_location": "cpp",
|
| | | "span": "cpp",
|
| | | "sstream": "cpp",
|
| | | "stack": "cpp",
|
| | | "stdexcept": "cpp",
|
| | | "stop_token": "cpp",
|
| | | "streambuf": "cpp",
|
| | | "string": "cpp",
|
| | | "system_error": "cpp",
|
| | | "thread": "cpp",
|
| | | "tuple": "cpp",
|
| | | "type_traits": "cpp",
|
| | | "typeinfo": "cpp",
|
| | | "unordered_map": "cpp",
|
| | | "unordered_set": "cpp",
|
| | | "utility": "cpp",
|
| | | "variant": "cpp",
|
| | | "vector": "cpp",
|
| | | "xfacet": "cpp",
|
| | | "xhash": "cpp",
|
| | | "xiosbase": "cpp",
|
| | | "xlocale": "cpp",
|
| | | "xlocbuf": "cpp",
|
| | | "xlocinfo": "cpp",
|
| | | "xlocmes": "cpp",
|
| | | "xlocmon": "cpp",
|
| | | "xlocnum": "cpp",
|
| | | "xloctime": "cpp",
|
| | | "xmemory": "cpp",
|
| | | "xstring": "cpp",
|
| | | "xtr1common": "cpp",
|
| | | "xtree": "cpp",
|
| | | "xutility": "cpp",
|
| | | "__nullptr": "cpp",
|
| | | "cstdarg": "cpp",
|
| | | "cwctype": "cpp",
|
| | | "mutex": "cpp",
|
| | | "__bit_reference": "cpp",
|
| | | "__hash_table": "cpp",
|
| | | "__split_buffer": "cpp",
|
| | | "__tree": "cpp",
|
| | | "string_view": "cpp",
|
| | | "__string": "cpp",
|
| | | "set": "cpp",
|
| | | "any": "cpp",
|
| | | "cinttypes": "cpp",
|
| | | "codecvt": "cpp",
|
| | | "complex": "cpp",
|
| | | "random": "cpp",
|
| | | "regex": "cpp",
|
| | | "typeindex": "cpp",
|
| | | "valarray": "cpp"
|
| | | "cmake.configureSettings": {
|
| | | "VCPKG_ROOT": "Z:/vcpkg"
|
| | | },
|
| | | "debug.terminal.clearBeforeReusing": true,
|
| | | "C_Cpp.loggingLevel": "Information",
|
| | | "remote.WSL.debug": true,
|
| | | "cmake.configureOnOpen": false,
|
| | | "cmake.debugConfig": {
|
| | | "stopAtEntry": false,
|
| | | "console": "newExternalWindow",
|
| | | "logging": {
|
| | | "trace": true
|
| | | }
|
| | | },
|
| | | "breadcrumbs.symbolSortOrder": "name"
|
| | | "cmake.configureOnOpen": true
|
| | | } |
| | |
| | | cmake_minimum_required(VERSION 3.10) |
| | | |
| | | set(PROJECT_NAME "sd.ui") |
| | | |
| | | project(sd.ui) |
| | | project(${PROJECT_NAME}) |
| | | |
| | | set (CMAKE_CXX_STANDARD 20) |
| | | |
| | |
| | | option(SD_CUBLAS "sd: cuda backend" ON) |
| | | option(SD_HIPBLAS "sd: rocm backend" OFF) |
| | | option(SD_METAL "sd: metal backend" OFF) |
| | | set(SD_CUBLAS ON) |
| | | |
| | | |
| | | #enable_language(CUDA) |
| | | message("CUDA ON") |
| | | |
| | | |
| | | |
| | | |
| | | IF(MSVC) |
| | | SET(OPTIONS WIN32) |
| | | ENDIF(MSVC) |
| | | |
| | | if(NOT CMAKE_BUILD_TYPE) |
| | | set(CMAKE_BUILD_TYPE Debug) |
| | | endif() |
| | | |
| | | add_executable(${PROJECT_NAME} ${OPTIONS} main.cpp ui/MainWindow.cpp ui/MainWindowSettings.cpp ui/MainWindowUi.cpp ui/MainWindowImageViewer.cpp ui/QueueManager.cpp) |
| | | |
| | | |
| | | add_executable(sd.ui ${OPTIONS} main.cpp ui/MainWindow.cpp ui/MainWindowSettings.cpp ui/MainWindowUi.cpp ui/MainWindowImageViewer.cpp ui/QueueManager.cpp) |
| | | |
| | | |
| | | include_directories(${CMAKE_SOURCE_DIR}/external/stable-diffusion.cpp/include) |
| | | link_directories(${CMAKE_SOURCE_DIR}/external/stable-diffusion.cpp/lib) |
| | | set(STABLE_DIFFUSION_DIR "${CMAKE_SOURCE_DIR}/external/stable-diffusion.cpp") |
| | | include_directories(${STABLE_DIFFUSION_DIR}/include) |
| | | link_directories(${STABLE_DIFFUSION_DIR}/CUDA/${CMAKE_BUILD_TYPE}) |
| | | |
| | | |
| | | IF(MSVC) |
| | | |
| | | |
| | | set(CUDA_PATH "$ENV{CUDA_PATH}") |
| | | set(CUDA_PATH "$ENV{CUDA_PATH}") |
| | | |
| | | #set(STABLE_DIFFUSION_LIB ${CMAKE_SOURCE_DIR}/external/stable-diffusion.cpp/${CMAKE_BUILD_TYPE}/stable-diffusion.lib) |
| | | #set(GGML_LIB ${CMAKE_SOURCE_DIR}/external/ggml/${CMAKE_BUILD_TYPE}/lib/ggml.lib) |
| | | #set(STABLE_DIFFUSION_DLL ${CMAKE_SOURCE_DIR}/external/stable-diffusion.cpp/${CMAKE_BUILD_TYPE}/stable-diffusion.dll) |
| | | #set(GGML_DLL ${CMAKE_SOURCE_DIR}/external/ggml/${CMAKE_BUILD_TYPE}/ggml.dll) |
| | | |
| | | #add_library(SDLIB SHARED IMPORTED) |
| | | #set_property(TARGET SDLIB PROPERTY IMPORTED_LOCATION "${STABLE_DIFFUSION_DLL}") |
| | | #set_property(TARGET SDLIB PROPERTY IMPORTED_IMPLIB "${STABLE_DIFFUSION_LIB}") |
| | | |
| | | #add_library(GGMLLIB SHARED IMPORTED) |
| | | #set_property(TARGET GGMLLIB PROPERTY IMPORTED_LOCATION "${GGML_DLL}") |
| | | #set_property(TARGET GGMLLIB PROPERTY IMPORTED_IMPLIB "${GGML_LIB}") |
| | | |
| | | add_library(stable-diffusion SHARED IMPORTED) |
| | | add_library(ggml SHARED IMPORTED) |
| | | |
| | | set_target_properties(stable-diffusion PROPERTIES |
| | | IMPORTED_CONFIGURATIONS "DEBUG;RELEASE" |
| | | IMPORTED_LOCATION_DEBUG ${STABLE_DIFFUSION_DIR}/CUDA/Debug/stable-diffusion.dll |
| | | IMPORTED_IMPLIB_DEBUG ${STABLE_DIFFUSION_DIR}/CUDA/Debug/stable-diffusion.lib |
| | | IMPORTED_LOCATION_RELEASE ${STABLE_DIFFUSION_DIR}/CUDA/Release/stable-diffusion.dll |
| | | IMPORTED_IMPLIB_RELEASE ${STABLE_DIFFUSION_DIR}/CUDA/Release/stable-diffusion.lib |
| | | INTERFACE_INCLUDE_DIRECTORIES ${STABLE_DIFFUSION_DIR}/include |
| | | ) |
| | | |
| | | set_target_properties(ggml PROPERTIES |
| | | IMPORTED_CONFIGURATIONS "DEBUG;RELEASE" |
| | | IMPORTED_LOCATION_DEBUG ${STABLE_DIFFUSION_DIR}/CUDA/Debug/ggml.dll |
| | | IMPORTED_IMPLIB_DEBUG ${STABLE_DIFFUSION_DIR}/CUDA/Debug/ggml.lib |
| | | IMPORTED_LOCATION_RELEASE ${STABLE_DIFFUSION_DIR}/CUDA/Release/ggml.dll |
| | | IMPORTED_IMPLIB_RELEASE ${STABLE_DIFFUSION_DIR}/CUDA/Release/ggml.lib |
| | | ) |
| | | |
| | | |
| | | if(NOT CMAKE_BUILD_TYPE) |
| | | set(CMAKE_BUILD_TYPE Debug) |
| | | endif() |
| | | |
| | | set(STABLE_DIFFUSION_LIB ${CMAKE_SOURCE_DIR}/external/stable-diffusion.cpp/${CMAKE_BUILD_TYPE}/lib/stable-diffusion.lib) |
| | | set(GGML_LIB ${CMAKE_SOURCE_DIR}/external/ggml/${CMAKE_BUILD_TYPE}/lib/ggml.lib) |
| | | set(STABLE_DIFFUSION_DLL ${CMAKE_SOURCE_DIR}/external/stable-diffusion.cpp/${CMAKE_BUILD_TYPE}/stable-diffusion.dll) |
| | | set(GGML_DLL ${CMAKE_SOURCE_DIR}/external/ggml/${CMAKE_BUILD_TYPE}/ggml.dll) |
| | | |
| | | add_library(SDLIB SHARED IMPORTED) |
| | | set_property(TARGET SDLIB PROPERTY IMPORTED_LOCATION "${STABLE_DIFFUSION_DLL}") |
| | | set_property(TARGET SDLIB PROPERTY IMPORTED_IMPLIB "${STABLE_DIFFUSION_LIB}") |
| | | |
| | | add_library(GGMLLIB SHARED IMPORTED) |
| | | set_property(TARGET GGMLLIB PROPERTY IMPORTED_LOCATION "${GGML_DLL}") |
| | | set_property(TARGET GGMLLIB PROPERTY IMPORTED_IMPLIB "${GGML_LIB}") |
| | | |
| | | |
| | | message("STABLE_DIFFUSION_LIB=" ${STABLE_DIFFUSION_LIB}) |
| | | message("GGML_LIB=" ${GGML_LIB}) |
| | | message("CUDA_PATH=" ${CUDA_PATH}) |
| | | |
| | | |
| | | add_custom_command(TARGET sd.ui POST_BUILD # Adds a post-build event to MyTest |
| | | add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD # Adds a post-build event to MyTest |
| | | COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..." |
| | | "${STABLE_DIFFUSION_DLL}" # <--this is in-file |
| | | $<TARGET_FILE_DIR:sd.ui>) # <--this is out-file path0 |
| | | |
| | | add_custom_command(TARGET sd.ui POST_BUILD # Adds a post-build event to MyTest |
| | | "${STABLE_DIFFUSION_DIR}/CUDA/${CMAKE_BUILD_TYPE}/stable-diffusion.dll" # <--this is in-file |
| | | $<TARGET_FILE_DIR:${PROJECT_NAME}>) # <--this is out-file path0 |
| | | add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD # Adds a post-build event to MyTest |
| | | COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..." |
| | | "${GGML_DLL}" # <--this is in-file |
| | | $<TARGET_FILE_DIR:sd.ui>) # <--this is out-file path0 |
| | | "${STABLE_DIFFUSION_DIR}/CUDA/${CMAKE_BUILD_TYPE}/ggml.dll" # <--this is in-file |
| | | $<TARGET_FILE_DIR:${PROJECT_NAME}>) # <--this is out-file path0 |
| | | |
| | | set(OpenCV_DIR "${VCPKG_INSTALLED_DIR}/x64-windows/share/opencv4") |
| | | |
| | | ENDIF(MSVC) |
| | | |
| | | set(OpenCV_DIR "${VCPKG_INSTALLED_DIR}/x64-windows/share/opencv4") |
| | | #set(OpenCV_DIR "${VCPKG_INSTALLED_DIR}/x64-windows/share/opencv4") |
| | | |
| | | find_package(OpenCV REQUIRED) |
| | | |
| | |
| | | find_package(nlohmann_json CONFIG REQUIRED) |
| | | find_package(CUDAToolkit REQUIRED) |
| | | |
| | | set(CUDA_LIB_PATH "C:/CUDA/lib/x64") |
| | | message("CUDA_LIB_PATH=" ${CUDA_LIB_PATH}) |
| | | #set(CUDA_LIB_PATH "C:/CUDA/lib/x64") |
| | | |
| | | |
| | | target_compile_definitions(sd.ui PRIVATE ${wxWidgets_DEFINITIONS} "$<$<CONFIG:DEBUG>:${wxWidgets_DEFINITIONS_DEBUG}>") |
| | | target_include_directories(sd.ui PRIVATE ${wxWidgets_INCLUDE_DIRS}) |
| | | target_compile_definitions(${PROJECT_NAME} PRIVATE ${wxWidgets_DEFINITIONS} "$<$<CONFIG:DEBUG>:${wxWidgets_DEFINITIONS_DEBUG}>") |
| | | target_include_directories(${PROJECT_NAME} PRIVATE ${wxWidgets_INCLUDE_DIRS}) |
| | | |
| | | target_link_libraries(sd.ui ${CUDA_LIBRARIES}) |
| | | target_link_libraries(${PROJECT_NAME} ${CUDA_LIBRARIES}) |
| | | |
| | | target_link_libraries(sd.ui PRIVATE restclient-cpp ${OpenCV_LIBS} nlohmann_json::nlohmann_json fmt::fmt wx::core wx::base wx::xrc wx::adv wx::richtext wx::aui SDLIB GGMLLIB CUDA::cudart CUDA::cublas CUDA::cublasLt CUDA::cuda_driver) |
| | | target_link_libraries(${PROJECT_NAME} PRIVATE stable-diffusion ggml restclient-cpp opencv_ml opencv_dnn opencv_core opencv_flann nlohmann_json::nlohmann_json fmt::fmt wx::core wx::base wx::xrc wx::adv wx::richtext wx::aui CUDA::cudart CUDA::cublas CUDA::cublasLt CUDA::cuda_driver) |
| | | |
| | | include_directories(ui) |
| | | |
| | |
| | | |
| | | MainWindowUI::~MainWindowUI() |
| | | { |
| | | // this->Hide(); |
| | | /* for (int i = 0; i < this->threads.size(); i++) |
| | | { |
| | | if (this->threads.at(i).joinable()) |
| | | { |
| | | this->threads.at(i).join(); |
| | | } |
| | | }*/ |
| | | if (this->modelLoaded) |
| | | { |
| | | free_sd_ctx(this->sd_ctx); |
| | | } |
| | | for (auto &t : this->threads) |
| | | { |
| | | t->join(); |
| | |
| | | { |
| | | this->sd_ctx = this->LoadModelv2(eventHandler, myItem); |
| | | this->currentModel = myItem.params.model_path; |
| | | this->currentVaeModel = myItem.params.vae_path; |
| | | } |
| | | else |
| | | { |
| | | if (myItem.params.model_path != this->currentModel) |
| | | if (myItem.params.model_path != this->currentModel || this->currentVaeModel != myItem.params.vae_path) |
| | | { |
| | | free_sd_ctx(this->sd_ctx); |
| | | this->sd_ctx = this->LoadModelv2(eventHandler, myItem); |
| | |
| | | myItem.params.controlnet_path.c_str(), |
| | | myItem.params.lora_model_dir.c_str(), |
| | | myItem.params.embeddings_path.c_str(), |
| | | true, false, false, |
| | | false, myItem.params.vae_tiling, false, |
| | | myItem.params.n_threads, |
| | | myItem.params.wtype, |
| | | myItem.params.rng_type, |
| | |
| | | wxQueueEvent(eventHandler, c); |
| | | this->modelLoaded = true; |
| | | this->currentModel = myItem.params.model_path; |
| | | this->currentVaeModel = myItem.params.vae_path; |
| | | } |
| | | return sd_ctx_; |
| | | } |
| | |
| | | QM::QueueManager *qmanager; |
| | | bool modelLoaded = false; |
| | | std::string currentModel; |
| | | std::string currentVaeModel; |
| | | sd_ctx_t *sd_ctx; |
| | | std::streambuf *buffer; |
| | | std::vector<std::thread*> threads; |
| | |
| | | "wxwidgets", |
| | | "cuda", |
| | | "nlohmann-json", |
| | | "opencv4", |
| | | "opencv", |
| | | "restclient-cpp" |
| | | ] |
| | | } |