ACMX 2.139.0
Dual-Backend Real-Time GPU Video Synthesis
Loading...
Searching...
No Matches
deep_dream_model.hpp
Go to the documentation of this file.
1#ifndef ACMXVK_DEEP_DREAM_MODEL_HPP
2#define ACMXVK_DEEP_DREAM_MODEL_HPP
3
4#include <cstddef>
5#include <cstdint>
6#include <iosfwd>
7#include <memory>
8#include <string>
9#include <string_view>
10#include <vector>
11
12#include <opencv2/core/cuda.hpp>
13#include <opencv2/core/mat.hpp>
14
15namespace acmxvk::dream {
16
18 std::string name;
19 std::int64_t source_index = 0;
20 };
21
23 std::string architecture;
24 std::string default_layer;
25 std::vector<LayerMetadata> layers;
26 std::vector<double> input_mean;
27 std::vector<double> input_std;
28 std::int64_t input_channels = 0;
29 std::int64_t minimum_input_size = 0;
30 };
31
33 int iterations = 1;
34 float step_size = 0.05F;
35 float feedback = 0.9F;
36 float zoom = 1.01F;
37 float rotation_degrees = 0.1F;
38 int max_dimension = 512;
40 int octaves = 1;
41 float octave_scale = 1.4F;
42 int jitter = 0;
43 int smoothing = 0;
44 };
45
47 float activation_loss = 0.0F;
48 float mean_gradient = 0.0F;
49 float mean_pixel_change = 0.0F;
53 };
54
55 class Model {
56 public:
57 Model(Model &&) noexcept;
58 Model &operator=(Model &&) noexcept;
60
61 Model(const Model &) = delete;
62 Model &operator=(const Model &) = delete;
63
64 [[nodiscard]] static Model load(std::string_view filename, int cuda_device, std::string_view layer = {}, bool use_half = false);
65 [[nodiscard]] const ModelMetadata &metadata() const;
66 [[nodiscard]] std::size_t selected_layer() const;
67 [[nodiscard]] std::size_t selected_channels() const;
68 [[nodiscard]] GradientAscentResult apply_gradient_ascent(cv::Mat &rgba, const GradientAscentOptions &options = {});
69 [[nodiscard]] GradientAscentResult apply_gradient_ascent_cuda(const cv::cuda::GpuMat &rgba, cv::cuda::GpuMat &output, cv::cuda::Stream &stream, const GradientAscentOptions &options = {});
70 void print(std::ostream &output) const;
71
72 private:
73 struct Impl;
74 explicit Model(std::unique_ptr<Impl> implementation);
75
76 std::unique_ptr<Impl> implementation;
77 };
78
79} // namespace acmxvk::dream
80
81#endif
std::size_t selected_channels() const
GradientAscentResult apply_gradient_ascent(cv::Mat &rgba, const GradientAscentOptions &options={})
static Model load(std::string_view filename, int cuda_device, std::string_view layer={}, bool use_half=false)
const ModelMetadata & metadata() const
std::unique_ptr< Impl > implementation
std::size_t selected_layer() const
void print(std::ostream &output) const
GradientAscentResult apply_gradient_ascent_cuda(const cv::cuda::GpuMat &rgba, cv::cuda::GpuMat &output, cv::cuda::Stream &stream, const GradientAscentOptions &options={})
Model(Model &&) noexcept
std::vector< double > input_std
std::vector< double > input_mean
std::vector< LayerMetadata > layers