mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-11-11 11:26:34 +00:00
refactor: centralize model factories and defaults (#2198)
This commit is contained in:
1 parent
baf45b49e2
commit
cd7f986058
50 files changed
+2233
-943
No files matched your search
@@ -0,0 +1,47 @@
|
||||
#ifndef __SD_MODEL_DEFINITION_H__
|
||||
#define __SD_MODEL_DEFINITION_H__
|
||||
|
||||
#include <limits>
|
||||
#include "model.h"
|
||||
#include "stable-diffusion.h"
|
||||
|
||||
class TokenizerConfig;
|
||||
struct VAE;
|
||||
namespace sd::model_builders {
|
||||
struct Context;
|
||||
struct CoreRunners;
|
||||
struct VAEOptions;
|
||||
}
|
||||
|
||||
struct ModelSamplingPolicy {
|
||||
prediction_t default_prediction = EPS_PRED;
|
||||
float default_flow_shift = std::numeric_limits<float>::infinity();
|
||||
sample_method_t default_sample_method = EULER_A_SAMPLE_METHOD;
|
||||
scheduler_t default_scheduler = DISCRETE_SCHEDULER;
|
||||
|
||||
bool probe_v_prediction = false;
|
||||
|
||||
prediction_t (*prediction_from_weights)(const String2TensorStorage&) = nullptr;
|
||||
float (*flow_shift_from_weights)(const String2TensorStorage&) = nullptr;
|
||||
};
|
||||
|
||||
struct ModelGeometry {
|
||||
int diffusion_down_factor = 8;
|
||||
int latent_channels = 4;
|
||||
int image_channels = 3;
|
||||
};
|
||||
|
||||
struct ModelDefinition {
|
||||
SDVersion version = VERSION_COUNT;
|
||||
const char* name = nullptr;
|
||||
ModelTraits traits;
|
||||
ModelSamplingPolicy sampling;
|
||||
ModelGeometry geometry;
|
||||
const char* ref_image_preset = "default";
|
||||
void (*configure_vae)(const sd::model_builders::Context&, const sd::model_builders::VAEOptions&, VAE&) = nullptr;
|
||||
bool (*build)(const sd::model_builders::Context&, const TokenizerConfig&, sd::model_builders::CoreRunners&) = nullptr;
|
||||
};
|
||||
|
||||
const ModelDefinition* find_model_definition(SDVersion version);
|
||||
|
||||
#endif // __SD_MODEL_DEFINITION_H__
|
||||
Reference in new issue
Block a user