Skip to main content

diffused

PyPI version codecov lint

🤗 Generate images with diffusion models:

diffused <model> <prompt>

Quick Start

Text-to-image:

uv run --with diffused diffused segmind/tiny-sd "red apple"

Or with pipx:

pipx run diffused segmind/tiny-sd "red apple"

Image-to-image:

uv run --with diffused diffused OFA-Sys/small-stable-diffusion-v0 "cat wizard" --image=https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png

Inpainting:

uv run --with diffused 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 with uv:

uv tool install diffused

Or with pipx:

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 and install the package with uv:

uv add 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:

uv run python script.py

Open the image:

open apple.png

See the API documentation.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diffused-1.0.2.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

diffused-1.0.2-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file diffused-1.0.2.tar.gz.

File metadata

  • Download URL: diffused-1.0.2.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for diffused-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c74f218348cef5747943ae0a7f0447ab356b31c1f684fdadf5aa56e909f67993
MD5 5e47c28f4fb820671b1d99fcf33daba8
BLAKE2b-256 3bf8ebdc363c1df097dd12dcffae8dc519b857b0bbfc414b689c51d972d788a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffused-1.0.2.tar.gz:

Publisher: release.yml on ai-action/diffused

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffused-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: diffused-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for diffused-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c72654e48e76eddf65c8ba986161415c3ffab2ea6b5cbdc781eb559654a27478
MD5 e2544baf49259192ec4305a58de50454
BLAKE2b-256 da927100e220177c0a344c2361dedfe586a97d1f1a912914d258c756c4ed99f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffused-1.0.2-py3-none-any.whl:

Publisher: release.yml on ai-action/diffused

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 files

1.0.1

2 files

1.0.0

2 files

0.10.1

2 files

0.10.0

2 files

0.9.0

2 files

0.8.1

2 files

0.8.0

2 files

0.7.0

2 files

0.6.1

2 files

0.6.0

2 files

0.5.1

2 files

0.5.0

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.16

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page