Browse Source

nice set of params

new-sep-loss
Michael Pilosov, PhD 10 months ago
parent
commit
13dd754ba6
  1. 2
      makefile
  2. BIN
      scripts/lex_sorted_indices.npy
  3. 18
      scripts/sortcolor.py

2
makefile

@ -59,7 +59,7 @@ sort_umap:
python scripts/sortcolor.py -s umap --dpi 300 --seed 21 python scripts/sortcolor.py -s umap --dpi 300 --seed 21
parallel_umap: parallel_umap:
parallel -j 8 python scripts/sortcolor.py -s umap --dpi 300 --seed ::: {1..8} parallel -j 12 python scripts/sortcolor.py -s umap --dpi 300 --seed ::: $$(seq 101 112)
sort_lex: sort_lex:
python scripts/sortcolor.py -s lex --dpi 300 python scripts/sortcolor.py -s lex --dpi 300

BIN
scripts/lex_sorted_indices.npy

Binary file not shown.

18
scripts/sortcolor.py

@ -86,14 +86,16 @@ elif KIND == "umap":
reducer = UMAP( reducer = UMAP(
n_components=1, n_components=1,
n_neighbors=250, n_neighbors=250,
min_dist=0.005, min_dist=1e-2,
metric="euclidean", metric="euclidean",
random_state=SEED, random_state=SEED,
negative_sample_rate=2,
) )
embedding = reducer.fit_transform(np.array(rgb_values)) embedding = reducer.fit_transform(np.array(rgb_values))
# Sort colors by the 1D representation # Sort colors by the 1D representation
preds = embedding[:, 0] preds = embedding[:, 0]
del reducer, embedding
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
@ -130,10 +132,11 @@ else:
sorted_indices = np.argsort(preds) sorted_indices = np.argsort(preds)
# Save the sorted indices to disk # Save the sorted indices to disk
if (KIND == "umap" and SEED == 21) or (KIND != "umap"): # if (KIND == "umap") or (KIND != "umap"):
file_path = f"scripts/{KIND}_sorted_indices.npy" Path(f"scripts/{KIND}").mkdir(parents=True, exist_ok=True)
np.save(file_path, sorted_indices) file_path = f"scripts/{KIND}/preds_{SEED:06d}.npy"
print(f"Sorted indices saved to {file_path}") np.save(file_path, preds)
print(f"Predictions saved to {file_path}")
# Sort colors by the 1D representation # Sort colors by the 1D representation
sorted_colors = [colors[i] for i in sorted_indices] sorted_colors = [colors[i] for i in sorted_indices]
@ -280,18 +283,19 @@ def plot_preds(
prefix = "" prefix = ""
if KIND == "umap": if KIND == "umap":
prefix = f"{SEED:02d}" prefix = f"{SEED:04d}"
fname = f"{DIR}/{prefix}{KIND}_sorted_colors_circle.png" fname = f"{DIR}/{prefix}{KIND}_sorted_colors_circle.png"
plot_preds( plot_preds(
preds, preds,
np.array(rgb_values), np.array(rgb_values),
fname, fname,
roll=True, roll=False,
dpi=DPI, dpi=DPI,
inner_radius=INNER_RADIUS, inner_radius=INNER_RADIUS,
figsize=(SIZE, SIZE), figsize=(SIZE, SIZE),
) )
print(f"saved {fname}")
HILBERT = False HILBERT = False

Loading…
Cancel
Save