From 9430e0fcd39065891fc9655b6d9d0b3b536245fc Mon Sep 17 00:00:00 2001 From: "Michael Pilosov, PhD" Date: Mon, 4 Mar 2024 17:19:44 +0000 Subject: [PATCH] save sorts for color chart --- scripts/sortcolor.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/sortcolor.py b/scripts/sortcolor.py index 37c4a3b..61a24cf 100644 --- a/scripts/sortcolor.py +++ b/scripts/sortcolor.py @@ -81,6 +81,10 @@ def peano_curve(n): return curve +PDIR = f"scripts" +Path(PDIR).mkdir(parents=True, exist_ok=True) +file_path = f"{PDIR}/{KIND}_sorted_indices.npy" + if KIND in ("lex", "alpha", "abc"): preds = np.array(colors) @@ -88,7 +92,6 @@ elif KIND == "umap": PDIR = f"scripts/{KIND}-prod" Path(PDIR).mkdir(parents=True, exist_ok=True) file_path = f"{PDIR}/{SEED:06d}.npy" - if Path(file_path).exists(): print(f"Loading {file_path}") preds = np.load(file_path) @@ -112,9 +115,6 @@ elif KIND == "umap": preds = embedding[:, 0] del reducer, embedding - # Save the sorted indices to disk - print(f"Saving {file_path}") - np.save(file_path, preds.ravel()) elif KIND in ("cielab", "lab", "ciede2000"): from skimage.color import deltaE_ciede2000, rgb2lab @@ -148,6 +148,9 @@ elif KIND == "hsv": else: raise ValueError(f"Unknown kind: {KIND}") +# Save the sorted indices to disk +print(f"Saving {file_path}") +np.save(file_path, preds.ravel()) # Sort colors by the 1D representation sorted_indices = np.argsort(preds)