Esacode

Docs / Blocks / AI

Text to image

Turns a prompt into any number of images with a diffusion model downloaded from Hugging Face onto the worker, from small (Segmind Vega, 0.7B) to large (FLUX.1 schnell, 12B): one image per seed, on an NVIDIA GPU, a Tenstorrent card or the CPU, each shown live as it is made.

Runs on a worker (Python) AI Version 1.3 Code you can open and adapt

How it works

Write a prompt (what the image shows, its light, its style) and how many images to make: each starts from its own seed, the noise the model turns into a picture, so one prompt gives as many different images as asked, and the same seed gives the same image again.

Variations (one per line, such as "at night" or "as a watercolour") are added to the prompt in turn; a table of prompts (a prompt column) or a text file (one per line) can be connected instead of the Prompt. The model is downloaded the first time into the worker's EsaSim cache (only what the pipeline needs, in half precision where there is one: about 3.3 GB for Segmind Vega), then read from there.

Models, from small to large (all at 1024 px, downloaded from Hugging Face): Segmind Vega RT (0.7B, 4 steps, the fastest; runs on a CPU too) and Segmind Vega (0.7B, 25 steps), a distilled SDXL about 70 % smaller, Apache-2.0; Segmind SSD-1B (1.3B, Apache-2.0); Stable Diffusion XL 1.0 (3.5B, CreativeML Open RAIL++-M: use allowed, with its use restrictions); FLUX.1 schnell (12B, 4 steps, Apache-2.0, gated: accept its conditions on Hugging Face and paste a token; about 36 GB of GPU memory, a cloud GPU).

A model larger than the GPU still runs: its parts take turns on the GPU, or come layer by layer (slower); one too large for a CPU stops with a clear message. Or any text-to-image model in the diffusers format on Hugging Face (owner/name) or in a folder of the worker, whose licence the block reads and records.

Where it runs: an NVIDIA GPU (half precision), a Tenstorrent card (TT-XLA: PyTorch/XLA with Tenstorrent's plugin, pip package pjrt-plugin-tt, installed on the worker as TT-Forge's documentation says; the model computes in bfloat16, its denoiser compiled for the chip the first time, which takes minutes), or the CPU. auto takes Vega on a GPU or a Tenstorrent card and Vega RT on a CPU, at 768 px there unless Width and Height say otherwise; under auto, a model that does not run on the Tenstorrent chip yet goes on with the next device and the log says why.

Any number of images, several at once on a large GPU (Images at once).

Every image is sent live (connect the block's live telemetry to an Images view: channel image), and saved with images.csv (seed, prompt, variation, steps, time, model, licence), generation.json, and summary.csv: one row (model, parameters, steps, size, device, seconds per image, loading time, licence) that tables from several models join into a comparison.

The images are not filtered: what they show is the prompt's doing; check the model's licence before using them.

Inputs

InputTakesWhat it is
Prompts
prompts
Table or Files
csv, txt, json
Optional: a table with a prompt column, or a text file with one prompt per line; used in turn instead of the Prompt setting Optional. Takes several connections.

Outputs

OutputGivesWhat it is
Images
images
Files
png, jpg, json
image_01_seed1.png … (more digits past 99 images), generation.json (model, licence, settings, time)
Images table
table
Table
csv
images.csv: n, file, seed, prompt, variation, steps, guidance, width, height, seconds, model, licence, device
Summary
summary
Table
csv
summary.csv, one row: model, repo, parameters_b, steps, size, device, memory, images, at_once, seconds_per_image, first_image_s, load_s, total_s, licence
Live telemetry
telemetry
Live telemetryWhat the block sends while it runs, for views such as Chart or 3D view.

Settings

SettingDefaultWhat it does
Prompt
prompt
A small six-wheeled rover exploring a red canyon on Mars at sunrise, long shadows, fine d… What the images show: subject, place, light, style
Images
count
10 How many images, any number: each with the next seed (the demo flows make 20)
From 1 to 100000
Images at once
batch
1 Images made in one pass of the model: more is faster on a large GPU (a cloud worker), needs more memory. If the GPU runs out of memory the block goes on one at a time
From 1 to 64
Model
model
auto (Vega on an NVIDIA GPU, Vega RT on a CPU) From small to large, all downloaded from Hugging Face the first time: Vega RT and Vega (Segmind, 0.7B, Apache-2.0), SSD-1B (Segmind, 1.3B, Apache-2.0), SDXL 1.0 (Stability AI, 3.5B, CreativeML Open RAIL++-M), FLUX.1 schnell (Black Forest Labs, 12B, Apache-2.0, gated: needs a token; for cloud GPUs). auto: Vega on an NVIDIA GPU, Vega RT on a CPU
One of: auto (Vega on an NVIDIA GPU, Vega RT on a CPU), Vega RT · 0.7B · 4 steps (fastest, any machine), Vega · 0.7B · 25 steps (GPU 8 GB), SSD-1B · 1.3B · 25 steps (GPU 8 GB), SDXL 1.0 · 3.5B · 30 steps (GPU 12 GB), FLUX.1 schnell · 12B · 4 steps (GPU 40 GB, token), Other (Hugging Face id or folder below)
Other model
model_id
empty With Model: Other: a diffusers text-to-image model on Hugging Face (owner/name) or a folder on the worker. Check its licence
Negative prompt
negative
blurry, low quality, distorted, deformed, extra wheels, text, watermark, logo, cartoon What the images should not show (models with guidance; Vega RT ignores it)
Variations
variations
empty Optional, one per line: added to the prompt in turn (at night, as a watercolour, seen from above…)
First seed
seed
1 Image n uses seed + n − 1; the same seed gives the same image. 0: different images every run
From 0 to 2147483647
Steps
steps
0 0: the model's own (Vega 25, Vega RT 4). More: finer, slower
From 0 to 150
Guidance
guidance
0 How closely to follow the prompt. 0: the model's own (Vega 9, Vega RT none)
From 0 to 30
Width (px)
width
0 0: the model's size (1024 on a GPU, 768 on a CPU). Multiples of 64
From 0 to 2048
Height (px)
height
0 0: the model's size. Multiples of 64
From 0 to 2048
Accelerator
accelerator
auto auto: a Tenstorrent card, else an NVIDIA GPU, else the CPU (a model that does not run on the Tenstorrent chip yet goes on with the next one, as the log says); naming one stops the block if it is not there
One of: auto, CPU, NVIDIA GPU, Tenstorrent
Format
format
png
One of: png, jpg
Hugging Face token
token
pasted in the editor, kept encrypted Empty: the Hugging Face token in the profile of whoever runs the flow. Needed for gated models (FLUX.1 schnell); also gives higher download limits

Where it runs

On one of your computers with the EsaSim worker: Any worker, NVIDIA GPU, Tenstorrent. The worker installs the Python packages it needs when they are missing: torch[cuda]</code>, <code>diffusers</code>, <code>transformers</code>, <code>accelerate</code>, <code>safetensors</code>, <code>peft</code>, <code>huggingface_hub</code>, <code>pillow.

In its code, settings are ctx.params["key"], inputs ctx.inputs["id"] and outputs ctx.output("id", "name.ext"); see Custom blocks.

More in AI