Skip to content

Google Colab notebook for using classifier guidance (including OpenAI CLIP guidance) with Stable Diffusion 2. Emad recommended using CLIP guidance "If you want some of the knowledge from the @OpenAI unknown dataset back in your image output [...]". S.D. systems often use classifier-free guidance.

1 / 3
Not downloaded yet
Not downloaded yet
Not downloaded yet

Colab notebook. Emad's tweet. After making a few changes, this notebook worked fine for me with the remote Tesla T4 GPU assigned to me in free-tier Colab. Generation time for this GPU was around 55 seconds for 1 image.

These are the notebook changes to make:

  1. In the first line of code, change "0.4.1" to "0.9".
  2. Change variable model_id from "CompVis/stable-diffusion-v1-4" to "stabilityai/stable-diffusion-2-base" (the 512x512 SD 2 model). Using "stabilityai/stable-diffusion-2" (the 768x768 SD 2 model) gave unusable images.
  3. Change variable clip_model_id to one of the three "openai" list items.

Example for text prompt = "portrait of short black hair woman in forest glade by artgerm, greg rutkowski, alphonse mucha, 8 k" (prompt copied from website Lexica):

https://preview.redd.it/fclce8iyfi2a1.png?width=512&format=png&auto=webp&s=8b0e73ebaf6515075818deab2bd5b15608213620

Example for text prompt = "hyperrealistic portrait of a mysterious cyberpunk woman with flowing hair, by Guy Denning, Russ Mills, beautiful, elusive, glitch art, hacking effects, glitch effects, digital tech effects, cybernetics, detailed lines, intricate detail, holographic, polished, chromatic, clear, color blocking, acrylic on canvas, octane, concept art, abstract, red face, front view, 8k, cgsociety, trending on artstation" (copied from Lexica):

https://preview.redd.it/sq9zfkazhi2a1.png?width=512&format=png&auto=webp&s=898254076ad6998f3dc9415f44ab6376092969fe

Example for text prompt = "photo of a queen's ornate living room":

https://preview.redd.it/iduepdhvii2a1.png?width=512&format=png&auto=webp&s=0589057a5c16e2ce2a36f8d7ab355feedc3432fc

Another Colab notebook for S.D. classifier guidance is Doohickey Diffusion. I wasn't able to get this notebook to work with "stabilityai/stable-diffusion-2-base" even though I followed these instructions.

Somewhat related post from last month: DreamStudio will now use CLIP guidance to enhance the quality and coherency of images.

Edited 27 Nov 2022. We only hold this version.

13 points7 comments
Open on Reddit
About this post
Posted
Archived
Edited
Score
13 · 94% up
Kind
Gallery · 3 files
ID
z647o7

Author

142
posts
939
comments
102
media
View profile
No comments archived yet. Reddit counts 7.

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.