# Render the 23 other numbered-train vs val/test pairs (not form pair 1695/501) side by side. Images only. import importlib.util import json import os import sys from PIL import Image, ImageDraw, ImageFont spec = importlib.util.spec_from_file_location("leak", "/path/to/TURKIC_OCR_CODE/scripts/kohtd_leak_scan.py") leak = importlib.util.module_from_spec(spec) sys.modules["leak"] = leak spec.loader.exec_module(leak) OUT = sys.argv[1] r = json.load(open(os.path.join(OUT, "result_numbered.json"), encoding="utf-8")) rows = [x for x in r["pairs_listed"] if not (x["train_form"] == 1695 and x["vt_form"] == 501)] font = ImageFont.truetype(leak.FONT, 13) panels = [] for x in rows: _, ga = leak.load(os.path.join(leak.IMG, x["train_crop"])) _, gb = leak.load(os.path.join(leak.IMG, x["vt_crop"])) hh = 60 A = Image.fromarray(ga).resize((max(1, int(ga.shape[1] * hh / ga.shape[0])), hh)) B = Image.fromarray(gb).resize((max(1, int(gb.shape[1] * hh / gb.shape[0])), hh)) c = Image.new("L", (A.width + B.width + 50, hh + 20), 255) c.paste(A, (5, 18)) c.paste(B, (A.width + 40, 18)) ImageDraw.Draw(c).text((5, 1), "train %s | %s %s | d %.3f ncc %.3f" % (x["train_crop"], x["vt_split"], x["vt_crop"], x["hash_distance"], x["ncc"]), font=font, fill=0) panels.append(c) for pi in range(2): ch = panels[pi * 12:(pi + 1) * 12] if not ch: continue img = Image.new("L", (max(p.width for p in ch), sum(p.height + 4 for p in ch)), 255) y = 0 for p in ch: img.paste(p, (0, y)) y += p.height + 4 img.save(os.path.join(OUT, "numbered_singles_panel_%d.png" % (pi + 1))) print("done", len(rows))