| import json |
| from json import JSONDecodeError |
| import matplotlib.pyplot as plt |
|
|
| jsonl_path = "/workspace/intern/pangkaiyu/Kimi-Audio/Kimi-Audio-Evalkit/lora_-5_to_10__7B/Qwen2.5-Omni-7B/kimi_10k_noise_-5_to_10_linear_val5_abs/Qwen2.5-Omni-7B_kimi_10k_noise_-5_to_10_linear_val5_abs_wer_details.jsonl" |
| out_png = "/workspace/intern/pangkaiyu/Kimi-Audio/Kimi-Audio-Evalkit/pic/-5_to_10_val5.png" |
|
|
| dec = json.JSONDecoder() |
|
|
| def iter_json_from_line(line: str): |
| line = line.strip() |
| if not line: |
| return |
| try: |
| yield json.loads(line) |
| return |
| except JSONDecodeError as e: |
| |
| i, n = 0, len(line) |
| while i < n: |
| while i < n and line[i].isspace(): |
| i += 1 |
| if i >= n: |
| break |
| obj, j = dec.raw_decode(line, i) |
| yield obj |
| i = j |
|
|
| xs, ys = [], [] |
| cnt_obj = 0 |
|
|
| with open(jsonl_path, "r", encoding="utf-8") as f: |
| for ln, line in enumerate(f, 1): |
| try: |
| for obj in iter_json_from_line(line): |
| cnt_obj += 1 |
| x = obj.get("index", cnt_obj) |
|
|
| y = obj.get("utt_wer", None) |
| if y is None: |
| y = (obj.get("wer_details") or {}).get("utt_wer", None) |
| if y is None: |
| continue |
|
|
| y = float(y) |
| |
| if y <= 1.0: |
| y *= 100.0 |
|
|
| xs.append(x) |
| ys.append(y) |
| except Exception as e: |
| |
| print(f"[ERROR] line {ln} parse failed: {repr(e)}") |
| print("line snippet:", repr(line[:200])) |
| raise |
|
|
| print(f"parsed {cnt_obj} json objects, plotted {len(xs)} points") |
|
|
| plt.figure() |
| plt.scatter(xs, ys, s=8) |
| plt.xlabel("index") |
| plt.ylabel("utt_wer (%)") |
| plt.ylim(0, 120) |
| plt.title("Per-utterance WER scatter") |
| plt.savefig(out_png, dpi=300, bbox_inches="tight") |
| plt.close() |
|
|
| print("saved to:", out_png) |
|
|