mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-12-24 13:28:13 +08:00
[Diffusion] Add StableDiffusionInpaint pipeline (#760)
* Update Inpaint pipeline * Update concat * Add GaussianRandomKernel * Update GaussianRandom * Add vae endoder * Add unet infer * Add vae decoder predict * add PrepareMaskAndMaskedImage * Add imwrite * Add time counter * Fix pipeline * use FDTensor move * Fix scaled_linear dpm solver * Add RGB2BGR
This commit is contained in:
@@ -57,8 +57,8 @@ DPMSolverMultistepScheduler::DPMSolverMultistepScheduler(
|
||||
function::Linspace(beta_start, beta_end, num_train_timesteps, &betas_,
|
||||
FDDataType::FP32);
|
||||
} else if (beta_schedule == "scaled_linear") {
|
||||
function::Linspace(beta_start, beta_end, num_train_timesteps, &betas_,
|
||||
FDDataType::FP32);
|
||||
function::Linspace(std::sqrt(beta_start), std::sqrt(beta_end),
|
||||
num_train_timesteps, &betas_, FDDataType::FP32);
|
||||
betas_ = betas_ * betas_;
|
||||
} else if (beta_schedule == "squaredcos_cap_v2") {
|
||||
BetaForAlphaBar(&betas_, num_train_timesteps);
|
||||
@@ -96,6 +96,8 @@ DPMSolverMultistepScheduler::DPMSolverMultistepScheduler(
|
||||
lower_order_nums_ = 0;
|
||||
}
|
||||
|
||||
float DPMSolverMultistepScheduler::InitNoiseSigma() { return 1.0; }
|
||||
|
||||
void DPMSolverMultistepScheduler::ConvertModelOutput(
|
||||
const FDTensor& model_output, int timestep, const FDTensor& sample,
|
||||
FDTensor* out) {
|
||||
@@ -314,7 +316,6 @@ void DPMSolverMultistepScheduler::Step(const FDTensor& model_output,
|
||||
if (timesteps_iter - timesteps_data < timesteps_.Numel()) {
|
||||
step_index = timesteps_iter - timesteps_data;
|
||||
}
|
||||
|
||||
int64_t prev_timestep = 0;
|
||||
if (step_index != timesteps_.Numel() - 1) {
|
||||
prev_timestep = timesteps_data[step_index + 1];
|
||||
@@ -392,4 +393,6 @@ void DPMSolverMultistepScheduler::AddNoise(const FDTensor& original_samples,
|
||||
*out = sqrt_alpha_prod * original_samples + sqrt_one_minus_alpha_prod * noise;
|
||||
}
|
||||
|
||||
FDTensor DPMSolverMultistepScheduler::GetTimesteps() { return timesteps_; }
|
||||
|
||||
} // namespace fastdeploy
|
||||
|
||||
Reference in New Issue
Block a user