Draft
Conversation
Contributor
|
Hello @cyrildiagne, Sorry for taking so long but I was trying to implement the Img2Img pipeline of your SD-Turbo but I'm not getting the expected output. The input image that I'm using is the following: This is more or less what I'm getting:
I added the addNoise (originalSamples: Tensor, noise: Tensor, timestep: number) {
const sigma = this.sigmas.data[timestep]
return originalSamples.add(noise.mul(sigma))
}Also added code similar to the img2img pipeline that already exists in the Stable Diffusion pipeline, before the denoising loop like so: if (input.img2imgFlag) {
const inputImage = input.inputImage || new Float32Array()
const strength = input.strength || 0.8
await dispatchProgress(input.progressCallback, {
status: ProgressStatus.EncodingImg2Img,
})
let imageLatent = await this.encodeImage(inputImage, input.width, input.height) // Encode image to latent space
imageLatent = imageLatent.mul(this.scheduler.initNoiseSigma)
// Taken from https://towardsdatascience.com/stable-diffusion-using-hugging-face-variations-of-stable-diffusion-56fd2ab7a265#2d1d
const initTimestep = Math.round(input.numInferenceSteps * strength)
const timestep = initTimestep
latents = this.scheduler.addNoise(imageLatent, latents, timestep)
// Computing the timestep to start the diffusion loop
const tStart = Math.max(input.numInferenceSteps - initTimestep, 0)
timesteps = timesteps.slice(tStart)
}I've kept trying but I'm not completely sure what I'm doing wrong or what's missing to implement the SD-Turbo Img2Img pipeline. Do you have any idea what it could be? I would appreciate any assistance with this. Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Adds the SD Turbo pipeline (as demoed here):
SDTurboPipelineEulerDiscreteSchedulerTensor.sqrt&interptensor utilsTODO:
Note:
This PR doesn't include the usage of TAESD which greatly increases speed for a small quality downgrade (as applied in this demo). But it's not part of the original pipeline so it makes more sense to add it in a separate PR.