Skip to content

zer0int/CLIP-Direct-Ascent-Synthesis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

  • Technically, a heavily modified fork of:

Like CLIP + VQGAN. Except without a VQGAN.

banner2

The original author's code offers:

  1. Text to image generation
  2. "Style" transfer
  3. Image reconstruction from its CLIP embedding

This repo adds:

  1. Gradient Ascent on the Text Embeddings (use CLIP's own opinion about image as text prompt)
  2. Minimize cosine similarity (get an "anti-cat" opinion / antonym for a cat image OR a cat text prompt)
  3. Use 4. and 5. to generate images Direct Ascent Synthesis
  4. For a given input image, visualize the Neuron (MLP Feature) with the highest activation value.
  5. Add one (or all) layer's features / "neurons" to the image stack for processing
  6. Can be, in essence, a self-sustained loop of making EVERYTHING out of CLIP. No human input.
  7. ...And many more options & features!

banner1

Quick start fun, uses human text prompts:

python clip-generate.py --use_neuron --make_anti 

Uses the same default (cat) image as --img0, but gets a CLIP opinion about it (no human text input):

python clip-generate.py --use_neuron --make_anti --use_image images/cat.png 

Adds ALL features ('neurons') as images, changes primary image, changes text prompt 1:

python clip-generate.py --all_neurons --img0 images/eatcat.jpg --txt1 "backyardspaghetti lifestyledissertation" 

Loads a second CLIP model (open_clip), makes plots, CLIP opinion, adds second image --img1:

python clip-generate.py --custom_model2 'ViT-B-32' 'laion2b_s34b_b79k' --make_plots --make_lossplots --img1 dogface.png 

Loads fine-tuned OpenAI/CLIP model as primary, sets deterministic backends. OpenAI models must start with "OpenAI-".

python clip-generate.py --model_name "OpenAI-ViT-L/14" "mymodels/finetune.pt" --batch_size 16 --deterministic 

Please see code in clip-generate.py for more details.

  • There's a lot. But I left you lots of comments, too!
  • python clip-generate.py --help for a quick review.

example-of-all

Releases

No releases published

Packages

No packages published

Languages