Skip to content

fix(eval/uni_mmmu): add missing import colorsys for >9-category sliding-puzzle palette - #32

Open
Anai-Guo wants to merge 1 commit into
AIFrontierLab:mainfrom
Anai-Guo:fix-eval-ummmu-missing-colorsys-import
Open

fix(eval/uni_mmmu): add missing import colorsys for >9-category sliding-puzzle palette#32
Anai-Guo wants to merge 1 commit into
AIFrontierLab:mainfrom
Anai-Guo:fix-eval-ummmu-missing-colorsys-import

Conversation

@Anai-Guo

@Anai-Guo Anai-Guo commented Sep 8, 2026

Copy link
Copy Markdown

Problem

In eval/generation/uni_mmmu/eval_ummmu.py, parse_sliding_puzzle_image builds a color palette via a local helper:

SET1_9 = ["#e41a1c", "#377eb8", ...]  # 9 colors

def _distinct_palette_k(k: int) -> List[np.ndarray]:
    if k <= 9: return [ _hex_to_rgb01(SET1_9[i % 9]) for i in range(k)]
    return [np.array(colorsys.hsv_to_rgb(i/float(k), 0.85, 0.95), dtype=np.float32) for i in range(k)]

The k > 9 branch calls colorsys.hsv_to_rgb(...), but colorsys is never imported anywhere in the file. So whenever num_categories > 9 — the very case that branch exists to serve, e.g. a 4×4 sliding puzzle (16 tiles) — the parser raises:

NameError: name 'colorsys' is not defined

The default config (num_categories: 9) takes the SET1_9 branch, so the bug stays latent until a larger board / higher category count is configured, at which point the image-evaluation loop (parse_sliding_puzzle_image is called on every GT and candidate image) crashes.

Fix

Add the missing import colorsys to the stdlib import block (one line, placed alphabetically).

Verification

Extracting the helper verbatim:

k=9 (default): OK
k=16 BEFORE: NameError -> name 'colorsys' is not defined
k=16 AFTER import colorsys: OK len=16

🤖 Generated with Claude Code

…ng-puzzle palette

parse_sliding_puzzle_image._distinct_palette_k falls back to
colorsys.hsv_to_rgb when num_categories > 9 (e.g. a 4x4 board with
16 tiles), but colorsys is never imported, so that branch raises
NameError: name 'colorsys' is not defined. The default config uses
num_categories=9 which takes the SET1_9 branch, so this stays latent
until a larger board / higher category count is configured.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant