Generate images with diffusion models.
Project description
diffused
🤗 Generate images with diffusion models:
diffused <model> <prompt>
Quick Start
pipx run diffused segmind/tiny-sd "red apple"
pipx run diffused OFA-Sys/small-stable-diffusion-v0 "cat wizard" --image=https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png
pipx run diffused kandinsky-community/kandinsky-2-2-decoder-inpaint "black cat" --image=https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png --mask-image=https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint_mask.png
Prerequisites
CLI
Install the CLI:
pipx install diffused
model
Required (str): The diffusion model.
diffused segmind/SSD-1B "An astronaut riding a green horse"
See segmind/SSD-1B.
prompt
Required (str): The text prompt.
diffused dreamlike-art/dreamlike-photoreal-2.0 "cinematic photo of Godzilla eating sushi with a cat in a izakaya, 35mm photograph, film, professional, 4k, highly detailed"
--negative-prompt
Optional (str): What to exclude from the output image.
diffused stabilityai/stable-diffusion-2 "photo of an apple" --negative-prompt="blurry, bright photo, red"
With the short option:
diffused stabilityai/stable-diffusion-2 "photo of an apple" -np="blurry, bright photo, red"
--image
Optional (str): The input image path or URL. The initial image is used as a starting point for an image-to-image diffusion process.
diffused stabilityai/stable-diffusion-xl-refiner-1.0 "astronaut in a desert" --image=https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/img2img-init.png
With the short option:
diffused stabilityai/stable-diffusion-xl-refiner-1.0 "astronaut in a desert" -i=./local/image.png
--mask-image
Optional (str): The mask image path or URL. Inpainting replaces or edits specific areas of an image. Create a mask image to inpaint images.
diffused kandinsky-community/kandinsky-2-2-decoder-inpaint "black cat" --image=https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png --mask-image=https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint_mask.png
With the short option:
diffused kandinsky-community/kandinsky-2-2-decoder-inpaint "black cat" -i=inpaint.png -mi=inpaint_mask.png
--output
Optional (str): The output image filename.
diffused dreamlike-art/dreamlike-photoreal-2.0 "cat eating sushi" --output=cat.jpg
With the short option:
diffused dreamlike-art/dreamlike-photoreal-2.0 "cat eating sushi" -o=cat.jpg
--width
Optional (int): The output image width in pixels.
diffused stabilityai/stable-diffusion-xl-base-1.0 "dog in space" --width=1024
With the short option:
diffused stabilityai/stable-diffusion-xl-base-1.0 "dog in space" -W=1024
--height
Optional (int): The output image height in pixels.
diffused stabilityai/stable-diffusion-xl-base-1.0 "dog in space" --height=1024
With the short option:
diffused stabilityai/stable-diffusion-xl-base-1.0 "dog in space" -H=1024
--number
Optional (int): The number of output images. Defaults to 1.
diffused segmind/tiny-sd apple --number=2
With the short option:
diffused segmind/tiny-sd apple -n=2
--guidance-scale
Optional (int): How much the prompt influences the output image. A lower value leads to more deviation and creativity, whereas a higher value follows the prompt to a tee.
diffused stable-diffusion-v1-5/stable-diffusion-v1-5 "astronaut in a jungle" --guidance-scale=7.5
With the short option:
diffused stable-diffusion-v1-5/stable-diffusion-v1-5 "astronaut in a jungle" -gs=7.5
--inference-steps
Optional (int): The number of diffusion steps used during image generation. The more steps you use, the higher the quality, but the generation time will increase.
diffused CompVis/stable-diffusion-v1-4 "astronaut rides horse" --inference-steps=50
With the short option:
diffused CompVis/stable-diffusion-v1-4 "astronaut rides horse" -is=50
--strength
Optional (float): The noise added to the input image, which determines how much the output image deviates from the original image. Strength is used for image-to-image and inpainting tasks and is a multiplier to the number of denoising steps (--inference-steps).
diffused stabilityai/stable-diffusion-xl-refiner-1.0 "astronaut in swamp" --image=https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/img2img-sdxl-init.png --strength=0.5
With the short option:
diffused stabilityai/stable-diffusion-xl-refiner-1.0 "astronaut in swamp" -i=image.png -s=0.5
--seed
Optional (int): The seed for generating random numbers, ensuring reproducibility in image generation pipelines.
diffused stable-diffusion-v1-5/stable-diffusion-v1-5 "Labrador in the style of Vermeer" --seed=0
With the short option:
diffused stable-diffusion-v1-5/stable-diffusion-v1-5 "Labrador in the style of Vermeer" -S=1337
--device
Optional (str): The device to accelerate the computation (cpu, cuda, mps, xpu, xla, or meta).
diffused stable-diffusion-v1-5/stable-diffusion-v1-5 "astronaut on earth, 8k" --device=cuda
With the short option:
diffused stable-diffusion-v1-5/stable-diffusion-v1-5 "astronaut on earth, 8k" -d=cuda
--no-safetensors
Optional (bool): Whether to disable safetensors.
diffused runwayml/stable-diffusion-v1-5 "astronaut on mars" --no-safetensors
--version
Show the program's version number and exit:
diffused --version # diffused -v
--help
Show the help message and exit:
diffused --help # diffused -h
Script
Create a virtual environment:
python3 -m venv .venv
Activate the virtual environment:
source .venv/bin/activate
Install the package:
pip install diffused
Generate an image with a model and a prompt:
# script.py
from diffused import generate
images = generate(model="segmind/tiny-sd", prompt="apple")
images[0].save("apple.png")
Run the script:
python script.py
Open the image:
open apple.png
See the API documentation.
License
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 diffused-1.0.1.tar.gz.
File metadata
- Download URL: diffused-1.0.1.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d769161ac5232bec4e884191ef3af5f2b27986041184572073ee7b5eae7154ce
|
|
| MD5 |
e9da84a72e542640a3094440f566ab8f
|
|
| BLAKE2b-256 |
8b7f0997d84285bdad36dbbed3e6718adfe697454604d4a3409125a509305533
|
Provenance
The following attestation bundles were made for diffused-1.0.1.tar.gz:
Publisher:
release.yml on ai-action/diffused
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
diffused-1.0.1.tar.gz -
Subject digest:
d769161ac5232bec4e884191ef3af5f2b27986041184572073ee7b5eae7154ce - Sigstore transparency entry: 704569071
- Sigstore integration time:
-
Permalink:
ai-action/diffused@a63e8c236629442bff8fb1e3a07091bcd0db5f39 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/ai-action
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a63e8c236629442bff8fb1e3a07091bcd0db5f39 -
Trigger Event:
push
-
Statement type:
File details
Details for the file diffused-1.0.1-py3-none-any.whl.
File metadata
- Download URL: diffused-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b19d57308abc5266316484e0b1143f66f825c7bb02e0a31c6686be30cc9f4b01
|
|
| MD5 |
f17666a32ef87668e36e16c8e1846b0d
|
|
| BLAKE2b-256 |
f8ad6489968bf81b725a2df925fa3588ffdf0b85957e64f5f120235e8d319dfd
|
Provenance
The following attestation bundles were made for diffused-1.0.1-py3-none-any.whl:
Publisher:
release.yml on ai-action/diffused
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
diffused-1.0.1-py3-none-any.whl -
Subject digest:
b19d57308abc5266316484e0b1143f66f825c7bb02e0a31c6686be30cc9f4b01 - Sigstore transparency entry: 704569073
- Sigstore integration time:
-
Permalink:
ai-action/diffused@a63e8c236629442bff8fb1e3a07091bcd0db5f39 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/ai-action
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a63e8c236629442bff8fb1e3a07091bcd0db5f39 -
Trigger Event:
push
-
Statement type: