|
@ -81,6 +81,10 @@ def peano_curve(n): |
|
|
return curve |
|
|
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"): |
|
|
if KIND in ("lex", "alpha", "abc"): |
|
|
preds = np.array(colors) |
|
|
preds = np.array(colors) |
|
|
|
|
|
|
|
@ -88,7 +92,6 @@ elif KIND == "umap": |
|
|
PDIR = f"scripts/{KIND}-prod" |
|
|
PDIR = f"scripts/{KIND}-prod" |
|
|
Path(PDIR).mkdir(parents=True, exist_ok=True) |
|
|
Path(PDIR).mkdir(parents=True, exist_ok=True) |
|
|
file_path = f"{PDIR}/{SEED:06d}.npy" |
|
|
file_path = f"{PDIR}/{SEED:06d}.npy" |
|
|
|
|
|
|
|
|
if Path(file_path).exists(): |
|
|
if Path(file_path).exists(): |
|
|
print(f"Loading {file_path}") |
|
|
print(f"Loading {file_path}") |
|
|
preds = np.load(file_path) |
|
|
preds = np.load(file_path) |
|
@ -112,9 +115,6 @@ elif KIND == "umap": |
|
|
preds = embedding[:, 0] |
|
|
preds = embedding[:, 0] |
|
|
del reducer, embedding |
|
|
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"): |
|
|
elif KIND in ("cielab", "lab", "ciede2000"): |
|
|
from skimage.color import deltaE_ciede2000, rgb2lab |
|
|
from skimage.color import deltaE_ciede2000, rgb2lab |
|
@ -148,6 +148,9 @@ elif KIND == "hsv": |
|
|
else: |
|
|
else: |
|
|
raise ValueError(f"Unknown kind: {KIND}") |
|
|
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 |
|
|
# Sort colors by the 1D representation |
|
|
sorted_indices = np.argsort(preds) |
|
|
sorted_indices = np.argsort(preds) |
|
|