ACMX 2.139.0
Dual-Backend Real-Time GPU Video Synthesis
Loading...
Searching...
No Matches
stable_diffusion.hpp
Go to the documentation of this file.
1#ifndef ACMXVK_STABLE_DIFFUSION_HPP
2#define ACMXVK_STABLE_DIFFUSION_HPP
3
4#include <opencv2/core.hpp>
5
6#include <cstdint>
7#include <filesystem>
8#include <functional>
9#include <string>
10#include <vector>
11
13 struct Lora {
14 std::filesystem::path path;
15 double multiplier = 1.0;
16 };
17
18 struct Settings {
19 std::filesystem::path server_executable;
20 std::filesystem::path model;
21 std::filesystem::path upscale_model;
22 std::filesystem::path lora_directory;
23 std::vector<Lora> loras;
24 std::vector<std::string> server_arguments;
25 std::string prompt;
26 std::string negative_prompt;
27 std::string sampler;
28 std::string scheduler;
29 int width = 576;
30 int height = 320;
35 int steps = 12;
36 int seed = 1234;
37 int port = 1234;
38 double strength = 0.35;
39 double cfg_scale = 5.0;
40 bool resize_to_input = true;
41 bool upscale_only = false;
42 bool quiet = false;
43 std::function<bool()> cancelled;
44 };
45
46 class Server final {
47 public:
48 explicit Server(Settings settings);
49 ~Server();
50
51 Server(const Server &) = delete;
52 Server &operator=(const Server &) = delete;
53 Server(Server &&) = delete;
54 Server &operator=(Server &&) = delete;
55
56 [[nodiscard]] cv::Mat process(const cv::Mat &rgba) const;
57
58 private:
60 std::int64_t process_id = -1;
61#ifdef _WIN32
62 std::intptr_t process_handle = 0;
63#endif
64 std::string endpoint;
65 std::filesystem::path diagnostic_log_path;
66
67 void start();
68 void stop() noexcept;
69 void waitUntilReady();
70 void resetDiagnosticLog() const noexcept;
71 [[nodiscard]] std::string diagnosticLogDetails() const;
72 };
73} // namespace acmxvk::stable_diffusion
74
75#endif
Server(const Server &)=delete
Server & operator=(const Server &)=delete
cv::Mat process(const cv::Mat &rgba) const
Server & operator=(Server &&)=delete
std::filesystem::path diagnostic_log_path
void resetDiagnosticLog() const noexcept
std::vector< std::string > server_arguments