π» Restroom
Match maleβfemale restroom icons from the same restroom β embeddings for images.
πThe task, in plain English
Given restroom door icons, match each male icon to the female icon from the same restroom (same design family/style). It's a matching problem: no classes to predict, just "which of these belongs with which".
| Input | Two sets of icon images |
|---|---|
| Output | A maleβfemale pairing |
| Really tests | Image embeddings + similarity matching β the same embed-and-compare pattern as Chameleon, but visual |
π§The baseline you're given
Embed icons with a pretrained vision encoder, match greedily by cosine similarity. Limitations: greedy matching makes locally-good globally-bad pairs; raw embeddings capture "icon-ness" more than "style".
πBaseline vs. solution
- Off-the-shelf embeddings
- Greedy nearest-neighbor pairing
- Duplicate/conflicting matches possible
- Global assignment instead of greedy: build the full similarity matrix, solve with
scipy.optimize.linear_sum_assignment(Hungarian algorithm) β one line, guarantees a consistent 1-to-1 pairing - Try several encoders (CLIP-style vs ResNet features) and layers β style lives at different depths
- Simple preprocessing: crop/binarize icons so backgrounds don't dominate similarity
π§Explain it like I'm brand new
Greedy vs global: greedy matching is speed-dating where the first person picks their favorite and leaves β
by the end, the remaining people get terrible matches. The Hungarian algorithm considers all pairings at once and
maximizes total happiness. In code the upgrade is literally one function:
linear_sum_assignment(-similarity_matrix). Knowing that this function exists is worth real points.
π¬The Gemma 4 playthrough (2000-token limit)
I have sim, a (n,n) numpy array where sim[i,j] = cosine similarity between male icon i and female icon j. Give ONLY code for the optimal 1-to-1 assignment maximizing total similarity, returning list of (i,j) pairs. Max 6 lines.
from scipy.optimize import linear_sum_assignment import numpy as np rows, cols = linear_sum_assignment(-sim) # negate: maximize pairs = list(zip(rows.tolist(), cols.tolist()))
π―Takeaways & what Day 1 might do with this
- Pattern family: embeddings + similarity, plus the matching upgrade (Hungarian algorithm).
- Encoders are interchangeable parts: text encoder for Chameleon, vision encoder here β same downstream code.