From edf998b3781651d051e2f4f89c84395d21f12b66 Mon Sep 17 00:00:00 2001 From: ZeroCool940711 Date: Tue, 25 Oct 2022 04:23:33 -0700 Subject: [PATCH] Added small function to make grids layouts using streamlit. --- scripts/sd_utils.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/sd_utils.py b/scripts/sd_utils.py index cb21b5b..f057bdf 100644 --- a/scripts/sd_utils.py +++ b/scripts/sd_utils.py @@ -258,6 +258,17 @@ def set_page_title(title): " /> """) + +def make_grid(n_items=5, n_cols=5): + n_rows = 1 + n_items // int(n_cols) + + rows = [st.container() for _ in range(n_rows)] + + cols_per_row = [r.columns(n_cols) for r in rows] + cols = [column for row in cols_per_row for column in row] + + return cols + def human_readable_size(size, decimal_places=3): """Return a human readable size from bytes.""" for unit in ['B','KB','MB','GB','TB']: @@ -475,7 +486,6 @@ def load_sd_from_config(ckpt, verbose=False): sd = pl_sd["state_dict"] return sd - class MemUsageMonitor(threading.Thread): stop_flag = False max_usage = 0