Skip to content

Commit

Permalink
Updated example to fix deprication issues. (triton-inference-server#5117
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tanayvarshney committed Nov 29, 2022
1 parent 48b7063 commit e78ea71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 3 additions & 2 deletions docs/examples/stable_diffusion/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ docker run --gpus=all -it --shm-size=256m --rm -p8000:8000 -p8001:8001 -p8002:80
```
# PyTorch & Transformers Lib
pip install torch torchvision torchaudio
pip install transformers ftfy scipy accelerate diffusers
pip install transformers ftfy scipy accelerate
pip install diffusers==0.9.0
pip install transformers[onnxruntime]
huggingface-cli login
```
Expand All @@ -64,7 +65,7 @@ docker run -it --gpus all -p 8888:8888 -v ${PWD}:/mount nvcr.io/nvidia/pytorch:y
pip install transformers ftfy scipy
pip install transformers[onnxruntime]
pip install diffusers
pip install diffusers==0.9.0
huggingface-cli login
cd /mount
python export.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,20 @@ def execute(self, requests):

for i, t in tqdm(enumerate(self.scheduler.timesteps)):
latent_model_input = torch.cat([latents] * 2)
sigma = self.scheduler.sigmas[i]
latent_model_input = latent_model_input / ((sigma**2 + 1)**0.5)
latent_model_input = self.scheduler.scale_model_input(latent_model_input, t)

with torch.no_grad(), torch.autocast("cuda"):
noise_pred = self.unet(
latent_model_input,
t,
encoder_hidden_states=text_embeddings)["sample"]
encoder_hidden_states=text_embeddings).sample

noise_pred_uncond, noise_pred_text = noise_pred.chunk(2)
noise_pred = noise_pred_uncond + guidance_scale * (
noise_pred_text - noise_pred_uncond)

latents = self.scheduler.step(noise_pred, i,
latents)["prev_sample"]
latents = self.scheduler.step(noise_pred, self.scheduler.timesteps[i],
latents).prev_sample

# VAE decoding
latents = 1 / 0.18215 * latents
Expand Down

0 comments on commit e78ea71

Please sign in to comment.