Skip to content

Add an image gallery feature - #14

Open
ckuethe wants to merge 2 commits into
lemonade-sdk:mainfrom
ckuethe:wui_gallery
Open

Add an image gallery feature#14
ckuethe wants to merge 2 commits into
lemonade-sdk:mainfrom
ckuethe:wui_gallery

Conversation

@ckuethe

@ckuethe ckuethe commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

run generate with --gallery <dir> to automatically save generated images in the specified directory. This also enables loading of the saved images at startup. Because generation parameters - prompt, sampling, loras, etc - are saved in the PNG metadata, it can also be reloaded into the UI.

This also creates a gallery API to fetch the list of images in the gallery directory.

If gallery is not enabled, images are not saved to or loaded from disk, and no gallery element is present in the UI.

Fixes #12

Example: ./thenoise.sh serve --dit ./models/anima/split_files/diffusion_models/anima-turbo-v1.0.safetensors --vae ./models/anima/split_files/vae/qwen_image_vae.safetensors --text-encoder ./models/anima/split_files/text_encoders/qwen_3_06b_base.safetensors --host 127.0.0.1 --port 19000 --gallery images

image

run generate with `--gallery <dir>` to automatically save generated images
in the specified directory. This also enables loading of the saved images
at startup. Because generation parameters - prompt, sampling, loras, etc -
are saved in the PNG metadata, it can also be reloaded into the UI.

if gallery is not enabled, images are not saved to or loaded from disk,
and no gallery element is present in the UI.

Fixes lemonade-sdk#12
@ckuethe

ckuethe commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

Derp. Forgot to document that in README.

Comment thread thenoise/api.py
_UI_DIR = os.path.join(os.path.dirname(__file__), "ui")


def _parse_gen_data(pnginfo: Any) -> dict | None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

metadata must be handled client-side. This already happens in the current webui so there is no reason to read all images and cache them

Comment thread thenoise/api.py

def __init__(self, gallery_dir: str) -> None:
self.gallery_dir = gallery_dir
self._cache: dict[str, dict] = {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this must also be removed, it is unbound

Comment thread thenoise/api.py
# -- list ------------------------------------------------------------------

def list_images(self) -> list[dict]:
"""Return list of {filename, url, meta} dicts, newest first."""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requires pagination as this can grow to literally any size

Comment thread README.md
| `--host` | `127.0.0.1` | Bind host |
| `--port` | `8000` | Bind port |
| `--upscaler-dir` | — | Directory containing pixel upscaler `.safetensors` files (e.g. Real-ESRGAN); selected per-request via `pixel_upscaler` |
| `--gallery` | — | Directory to use as a persistent image store. If enabled, it also displays previously saved images |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

displays => serves

Comment thread thenoise/api.py
)
else:
fname = (
f"{datetime.now(timezone.utc).timestamp():010.3f}_"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a prefix like "thenoise". The timestamp can be added as a decimal, I don't really think the 4 digit random number is necessary but it doesn't hurt I guess

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thenoise_YYmmdd_HHMMSSsss.png? I don't think too many people will be creating two images at exactly the same milliscone.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that'd work fine, yes

Comment thread thenoise/api.py
if not self.active:
return None
pnginfo = getattr(image, "_pnginfo", None)
meta = _parse_gen_data(pnginfo) if pnginfo else None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, no need to parse this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

persistent storage for image gallery?

2 participants