feat(training): track and display CER per training run

After each training run, the Character Error Rate (CER = 1 - accuracy),
loss, accuracy, and epoch count are now stored on the OcrTrainingRun
record and shown in the training history table.

Also adds the missing POST /api/ocr/segtrain endpoint and the
triggerSegTraining service method so the segmentation training card
can actually trigger training.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-13 19:01:10 +02:00
parent a99afef319
commit 22954f348a
12 changed files with 118 additions and 14 deletions

View File

@@ -11,6 +11,7 @@ interface Run {
triggeredBy?: string;
createdAt: string;
completedAt?: string;
cer?: number;
}
interface Props {
@@ -28,6 +29,11 @@ const dateFormatter = new Intl.DateTimeFormat('de-DE', {
function formatDate(iso: string): string {
return dateFormatter.format(new Date(iso));
}
function formatCer(cer: number | undefined | null): string {
if (cer == null) return '—';
return (cer * 100).toFixed(1) + ' %';
}
</script>
<table class="w-full text-sm">
@@ -37,12 +43,13 @@ function formatDate(iso: string): string {
<th class="pb-2 text-left">{m.training_history_col_status()}</th>
<th class="pb-2 text-right">{m.training_history_col_blocks()}</th>
<th class="hidden pb-2 text-right md:table-cell">{m.training_history_col_docs()}</th>
<th class="hidden pb-2 text-right md:table-cell">{m.training_history_col_cer()}</th>
</tr>
</thead>
<tbody>
{#if runs.length === 0}
<tr>
<td colspan="4" class="py-4 text-center text-sm text-ink-2">
<td colspan="5" class="py-4 text-center text-sm text-ink-2">
{m.training_history_empty()}
</td>
</tr>
@@ -71,6 +78,9 @@ function formatDate(iso: string): string {
</td>
<td class="py-2 text-right text-ink-2">{run.blockCount}</td>
<td class="hidden py-2 text-right text-ink-2 md:table-cell">{run.documentCount}</td>
<td class="hidden py-2 text-right md:table-cell"
>{run.status === 'DONE' && run.cer != null ? formatCer(run.cer) : '—'}</td
>
</tr>
{/each}
{/if}