Load previously completed results from a JSONL progress file.
(jsonl_path)
| 457 | # ============================================================ |
| 458 | |
| 459 | def load_completed_results(jsonl_path): |
| 460 | """Load previously completed results from a JSONL progress file.""" |
| 461 | completed = {} |
| 462 | if not os.path.exists(jsonl_path): |
| 463 | return completed |
| 464 | with open(jsonl_path, "r", encoding="utf-8") as f: |
| 465 | for line in f: |
| 466 | line = line.strip() |
| 467 | if not line: |
| 468 | continue |
| 469 | try: |
| 470 | row = json.loads(line) |
| 471 | completed[row["img_path"]] = row |
| 472 | except (json.JSONDecodeError, KeyError): |
| 473 | continue |
| 474 | return completed |
| 475 | |
| 476 | |
| 477 | # ============================================================ |