Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions unit3/01_stable_diffusion_introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@
],
"source": [
"# Get the final text embeddings using the pipeline's encode_prompt function\n",
"text_embeddings = pipe._encode_prompt(\"A painting of a flooble\", device, 1, False, '')\n",
"text_embeddings.shape"
"text_embeddings = pipe.encode_prompt(\"A painting of a flooble\", device, 1, False, '')\n",
"print(\"Text embedding shape:\", text_embeddings[0].shape)"
]
},
{
Expand Down Expand Up @@ -673,7 +673,14 @@
"negative_prompt = \"zoomed in, blurry, oversaturated, warped\" #@param\n",
"\n",
"# Encode the prompt\n",
"text_embeddings = pipe._encode_prompt(prompt, device, 1, True, negative_prompt)\n",
"text_embeddings = pipe.encode_prompt(\n",
" prompt=prompt,\n",
" device=device,\n",
" num_images_per_prompt=1,\n",
" do_classifier_free_guidance=True,\n",
" negative_prompt=negative_prompt,\n",
" )\n",
"text_embeddings = torch.cat([text_embeddings[1], text_embeddings[0]])\n",
"\n",
"# Create our random starting point\n",
"latents = torch.randn((1, 4, 64, 64), device=device, generator=generator)\n",
Expand Down Expand Up @@ -704,10 +711,13 @@
"\n",
"# Decode the resulting latents into an image\n",
"with torch.no_grad():\n",
" image = pipe.decode_latents(latents.detach())\n",
" image = pipe.vae.decode(latents.detach() / pipe.vae.config.scaling_factor, return_dict=False)[0]\n",
"\n",
" image = pipe.image_processor.postprocess(image, \n",
" output_type=\"pil\",\n",
" do_denormalize=[True])[0]\n",
"# View\n",
"pipe.numpy_to_pil(image)[0]"
"display(image)"
]
},
{
Expand Down Expand Up @@ -857,7 +867,7 @@
"outputs": [],
"source": [
"# Load the inpainting pipeline (requires a suitable inpainting model)\n",
"pipe = StableDiffusionInpaintPipeline.from_pretrained(\"runwayml/stable-diffusion-inpainting\")\n",
"pipe = StableDiffusionInpaintPipeline.from_pretrained(\"stabilityai/stable-diffusion-2-inpainting\")\n",
"pipe = pipe.to(device)"
]
},
Expand Down