in understanding_rl_vision/rl_clarity/interface.py [0:0]
def get_html_colors(n, grayscale=False, mix_with=None, mix_weight=0.5, **kwargs):
if grayscale:
colors = np.linspace(0, 1, n)[..., None].repeat(3, axis=1)
else:
colors = channels_to_rgb(np.eye(n), **kwargs)
colors = colors / colors.max(axis=-1, keepdims=True)
if mix_with is not None:
colors = colors * (1 - mix_weight) + mix_with[None] * mix_weight
colors = np.round(colors * 255)
colors = np.vectorize(lambda x: hex(x)[2:].zfill(2))(colors.astype(int))
return ["#" + "".join(color) for color in colors]