Added small function to make grids layouts using streamlit.

This commit is contained in:
ZeroCool940711 2022-10-25 04:23:33 -07:00
parent f61bf666bf
commit edf998b378

View File

@ -258,6 +258,17 @@ def set_page_title(title):
</script>" /> </script>" />
""") """)
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): def human_readable_size(size, decimal_places=3):
"""Return a human readable size from bytes.""" """Return a human readable size from bytes."""
for unit in ['B','KB','MB','GB','TB']: 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"] sd = pl_sd["state_dict"]
return sd return sd
class MemUsageMonitor(threading.Thread): class MemUsageMonitor(threading.Thread):
stop_flag = False stop_flag = False
max_usage = 0 max_usage = 0