The min_diffusion library
This library was put together for a series of experiments on Classifier-free Guidance.
Install
pip install min_diffusion
How to use min_diffusion
The library has a single main class
MinimalDiffusion.
This class takes three arguments:
model_namedevicedtype
model_name is the string model name on the HuggingFace hub.
device sets the hardware to run on.
dtype is the torch.dtype precision for the torch modules.
# import the library
from min_diffusion.core import MinimalDiffusion
Loading a sample model
Below is an example to load the openjourney model from PromptHero.
The model will be loaded in torch.float16 precision and placed on the
GPU.
# set the model to load and its options
model_name = 'prompthero/openjourney'
device = 'cuda'
dtype = torch.float32
revision = "fp32"
Creating a
MinimalDiffusion
with these arguments:
# create the minimal diffusion pipeline
pipeline = MinimalDiffusion(model_name, device, dtype, revision)
Loading the pipeline:
# load the pipeline
pipeline.load();
Enabling default unet attention slicing.
Generating an image
Below is an example text prompt for image generation.
Note the keyword
"mdjrny-v4 style"at the start of the prompt. This is how theopenjourneymodel creates images in the style of Midjourney v4.
# text prompt for image generations
prompt = "mdjrny-v4 style a photograph of an astronaut riding a horse"
Calling MinimalDiffusion on the input text prompt
# generate the image
img = pipeline.generate(prompt);
Using the default Classifier-free Guidance.
0%| | 0/50 [00:00<?, ?it/s]
Here is the generated image:
# view the output image
img
Notes:
The pipeline assumes you have logged in to the HuggingFace hub.
Metadata
Release files for min-diffusion 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| min_diffusion-0.0.3.tar.gz | 16.3 kB | Without provenance | Details for min_diffusion-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| min_diffusion-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for min_diffusion-0.0.3-py3-none-any.whl |
Total release size: 32.2 kB
Release files / min_diffusion-0.0.3.tar.gz
| Download URL | min_diffusion-0.0.3.tar.gz |
|---|---|
| Size | 16.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a05ead6610b178ea0d1da1e4661808e9c311c2d7424a80da4e77662203e9994d
|
|
BLAKE2b-256 checksum How to use checksums |
a4f10a9d767f37ba525c3a956bb178b34d6cd0609a9619758b3b7403c576b710
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.8
|
Release files / min_diffusion-0.0.3-py3-none-any.whl
| Download URL | min_diffusion-0.0.3-py3-none-any.whl |
|---|---|
| Size | 15.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8e463c0db7b193a0c77bab3754ab4b30fec8e88b81df773e5a8a6db776a5eb5b
|
|
BLAKE2b-256 checksum How to use checksums |
2db0c3a43c05896d1be7b729f0ef0d14da5877b3db8c30f00130d3aea1baee70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.8
|
Security for min-diffusion 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.