Skip to content

Commit 70f6662

Browse files
feat(posts): add "AI text-to-image generation with diffused CLI"
Post: 2025-03-30-ai-text-to-image-generation-with-diffused-cli.md
1 parent 5f34d60 commit 70f6662

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
layout: post
3+
title: AI text-to-image generation with diffused CLI
4+
date: 2025-03-30 14:53:29
5+
excerpt: How to perform AI text-to-image generation with diffused CLI.
6+
categories: ai text-to-image cli diffused diffusion huggingface
7+
---
8+
9+
This post goes over how to perform AI text-to-image generation with [diffused](https://github.com/ai-action/diffused) CLI.
10+
11+
## Prerequisites
12+
13+
Install [Python](https://www.python.org/):
14+
15+
```sh
16+
brew install python
17+
```
18+
19+
Install [pipx](https://pipx.pypa.io/):
20+
21+
```sh
22+
brew install pipx
23+
```
24+
25+
## CLI
26+
27+
Install the [CLI](https://pypi.org/project/diffused/):
28+
29+
```sh
30+
pipx install diffused
31+
```
32+
33+
Generate an image with [model](https://huggingface.co/segmind/tiny-sd) and prompt:
34+
35+
```sh
36+
diffused segmind/tiny-sd "portrait of a cat"
37+
```
38+
39+
Generate an image with [model](https://huggingface.co/OFA-Sys/small-stable-diffusion-v0), prompt, and filename:
40+
41+
```sh
42+
diffused OFA-Sys/small-stable-diffusion-v0 "cartoon of a cat" --output cat.jpg
43+
```
44+
45+
See help for more info:
46+
47+
```sh
48+
diffused --help
49+
```
50+
51+
## Script
52+
53+
Create a virtual environment:
54+
55+
```sh
56+
python3 -m venv .venv
57+
```
58+
59+
Activate the virtual environment:
60+
61+
```sh
62+
source .venv/bin/activate
63+
```
64+
65+
Install the [package](https://pypi.org/project/diffused/):
66+
67+
```sh
68+
pip install diffused
69+
```
70+
71+
Generate an image with [model](https://huggingface.co/segmind/tiny-sd) and prompt:
72+
73+
```py
74+
# script.py
75+
from diffused import generate
76+
77+
image = generate(model="segmind/tiny-sd", prompt="apple")
78+
image.save("apple.png")
79+
```
80+
81+
Run the script:
82+
83+
```sh
84+
python script.py
85+
```
86+
87+
## Resources
88+
89+
- For more models, see [Hugging Face](https://huggingface.co/models?pipeline_tag=text-to-image).
90+
- The package is open source and on [GitHub](https://github.com/ai-action/diffused).

0 commit comments

Comments
 (0)