mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-11-26 23:29:53 +00:00
Some checks failed
CI / ubuntu-latest-cmake (push) Has been cancelled
CI / ubuntu-latest-cmake-vulkan (push) Has been cancelled
CI / Build and push container images (push) Has been cancelled
CI / macOS-latest-cmake (push) Has been cancelled
CI / windows-latest-cmake (cpu, -DGGML_NATIVE=OFF -DSD_BUILD_SHARED_LIBS=ON -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON) (push) Has been cancelled
CI / windows-latest-cmake (cuda12, -DSD_CUDA=ON -DSD_BUILD_SHARED_LIBS=ON -DCMAKE_CUDA_ARCHITECTURES='61;70;75;80;86;89;90;100;120' -DCMAKE_CUDA_FLAGS='-Xcudafe "--diag_suppress=177" -Xcudafe "--diag_suppress=550"' -DGGML_NATIVE=OFF -DSD_BUILD_SHARED_GGML_L… (push) Has been cancelled
CI / windows-latest-cmake (vulkan, -DSD_VULKAN=ON -DSD_BUILD_SHARED_LIBS=ON -DGGML_NATIVE=OFF -DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON) (push) Has been cancelled
CI / windows-latest-rocm (push) Has been cancelled
CI / ubuntu-latest-rocm (10.1.0, x64, gfx900;gfx906;gfx908;gfx90a;gfx90c;gfx942;gfx950;gfx1010;gfx1011;gfx1012;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151;gfx1152;gfx1153;gfx1200;gfx1201) (push) Has been cancelled
CI / release (push) Has been cancelled
56 lines
1.8 KiB
C++
56 lines
1.8 KiB
C++
#ifndef __SD_EXAMPLES_SERVER_MODEL_CATALOG_H__
|
|
#define __SD_EXAMPLES_SERVER_MODEL_CATALOG_H__
|
|
|
|
#include <chrono>
|
|
#include <map>
|
|
#include <mutex>
|
|
#include <shared_mutex>
|
|
#include <string>
|
|
|
|
#include "runtime.h"
|
|
|
|
struct ModelRoot {
|
|
std::filesystem::path path;
|
|
std::string id;
|
|
std::string label;
|
|
bool primary = false;
|
|
};
|
|
|
|
struct ModelFile {
|
|
std::string category;
|
|
std::string name;
|
|
std::string relative_path;
|
|
ModelRoot root;
|
|
};
|
|
|
|
std::string model_path_key(const std::filesystem::path& path);
|
|
bool model_path_inside(const std::filesystem::path& root, const std::filesystem::path& path);
|
|
ModelRoot make_model_root(const std::filesystem::path& path, bool primary);
|
|
std::vector<ModelRoot> get_model_roots(const SDSvrParams& params);
|
|
std::vector<std::filesystem::path> model_category_directories(const ModelRoot& root, const std::string& category);
|
|
|
|
struct ServerModels {
|
|
std::shared_mutex runtime_mutex;
|
|
std::mutex catalog_mutex;
|
|
std::mutex status_mutex;
|
|
SDCtxPtr context;
|
|
SDContextParams base_context;
|
|
SDGenerationParams base_defaults;
|
|
std::map<std::string, json> recipes;
|
|
std::map<std::string, ModelFile> files;
|
|
std::chrono::steady_clock::time_point load_started_at;
|
|
json active_recipe = nullptr;
|
|
json catalog_errors = json::array();
|
|
json status = {{"state", "empty"}, {"recipe", nullptr}, {"models", json::object()}, {"error", nullptr}, {"load_elapsed_seconds", nullptr}};
|
|
};
|
|
|
|
void refresh_model_catalog(ServerRuntime& runtime);
|
|
json model_status(ServerRuntime& runtime);
|
|
void initialize_server_models(ServerRuntime& runtime);
|
|
|
|
json resolve_recipe_features(const json& recipe);
|
|
json model_generation_features(const ServerRuntime& runtime);
|
|
|
|
void prepare_model_load(ServerRuntime& runtime, const json& body, SDContextParams& context, SDGenerationParams& defaults, json* loaded_recipe = nullptr);
|
|
|
|
#endif
|