Code Monkey home page Code Monkey logo

Comments (4)

rohit901 avatar rohit901 commented on July 20, 2024 5

Okay for those who are curious, I was able to fix it by making this change in the code, I think we were doing step twice in the same loop and it should be done once per loop right? correct me if I'm wrong here @johnowhitaker

Earlier code:

# Get the predicted x0:
latents_x0 = scheduler.step(noise_pred, t, latents).pred_original_sample # Using the scheduler (Diffusers 0.4 and above)

# compute the previous noisy sample x_t -> x_t-1
latents = scheduler.step(noise_pred, t, latents).prev_sample

Modified code (call step only once and use intermediate variable scheduler_output):

scheduler_output = scheduler.step(noise_pred, t, latents)

latents_x0 = scheduler_output.pred_original_sample # Using the scheduler (Diffusers 0.4 and above)

# compute the previous noisy sample x_t -> x_t-1
latents = scheduler_output.prev_sample

from diffusion-nbs.

johnowhitaker avatar johnowhitaker commented on July 20, 2024

Hmm, I can't re-create. If it's failing at the last step you could stop a few steps early (if i == 45: break) and you'll get to see the animation even if it isn't ideal.
Could you confirm that a fresh copy of the notebook fails here when you do 'Run all'?

from diffusion-nbs.

venkyyuvy avatar venkyyuvy commented on July 20, 2024

workaround

        latents = latents.detach() - cond_grad * sigma**2
        scheduler._step_index = scheduler._step_index - 1

or uncomment the manual stepping instead scheduler stepping

# Get the predicted x0:
latents_x0 = latents - sigma * noise_pred
# latents_x0 = scheduler.step(noise_pred, t, latents).pred_original_sample

from diffusion-nbs.

rohit901 avatar rohit901 commented on July 20, 2024

yeah getting the same error with index at UNET and CFG sections in the code to generate the video.. I tried reducing num_inference_steps to 45 but same error happens saying index 46 is out of bounds..

@venkyyuvy could you explain how exactly to use the first part of your workaround? I don't think cond_grad is defined in the code [nvm, found it in CFG section].. regarding the uncommenting part, I feel doing it through API (step) would be better than manually doing it like that right?

from diffusion-nbs.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.