A prompting enhancement library for transformers-type text embedding systems.
Project description
compel
A text prompt weighting and blending library for transformers-type text embedding systems, by @damian0815.
With a flexible and intuitive syntax, you can re-weight different parts of a prompt string and thus re-weight the different parts of the embeddning tensor produced from the string.
Tested and developed against Hugging Face's StableDiffusionPipeline but it should work with any diffsers-based system that uses an Tokenizer and a Text Encoder of some kind.
Adapted from the InvokeAI prompting code (also by @damian0815). For now, the syntax is fully documented here.
Demo
Quickstart
with Hugging Face diffusers >=0.12:
from diffusers import StableDiffusionPipeline
from compel import Compel
pipeline = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
compel = Compel(tokenizer=pipeline.tokenizer, text_encoder=pipeline.text_encoder)
# upweight "ball"
prompt = "a cat playing with a ball++ in the forest"
conditioning = compel.build_conditioning_tensor(prompt)
# generate image
image = pipeline(prompt_embeds=conditioning, num_inference_steps=20).images[0]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file compel-0.1.2.tar.gz.
File metadata
- Download URL: compel-0.1.2.tar.gz
- Upload date:
- Size: 33.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4dc691efaa53ffd862fcf79e8b31bc93896902cff97c698dcdbd501aa0eabcf
|
|
| MD5 |
802733238cba1233efbc1698a311e40d
|
|
| BLAKE2b-256 |
5fd9070c198ec333569dfbb2a29034683b198a95504b895a926af6f569850dd3
|
File details
Details for the file compel-0.1.2-py3-none-any.whl.
File metadata
- Download URL: compel-0.1.2-py3-none-any.whl
- Upload date:
- Size: 28.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68e5830cfd277376dd7e077ad7ae8b6acb3e35f6c5fe4c5d9dd1a61ddf0d98c5
|
|
| MD5 |
2a96072630236951d054941155cf23a1
|
|
| BLAKE2b-256 |
87e1bfd0232402996fae10fb465e56644a4d3927f706679d988dd32c0034c4aa
|