You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dinglehopper/dinglehopper/templates/summary.html.j2

137 lines
3.7 KiB
Django/Jinja

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<style type="text/css">
{% if metrics %}
.gt .diff {
color: green;
}
.ocr .diff {
color: red;
}
{% else %}
.gt .diff, .ocr .diff {
color: blue;
}
{% endif %}
.ellipsis {
opacity: 0.5;
font-style: italic;
}
.diff-highlight {
border: 2px solid;
border-radius: 5px;
}
.row {
margin-bottom: 20px;
}
table {
width: 100%;
}
.cer {
flex-direction: column;
}
tr:hover {
background-color: #f5f5f5;
}
th {
cursor: pointer;
}
th:hover {
background-color: #eee;
}
td {
min-width: 100px;
}
td:hover {
background-color: #eee;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<h1>Summary of all reports</h1>
</div>
<div class="row">
<p>Number of reports: {{ num_reports }}</p>
</div>
{% if cer_avg and wer_avg -%}
<div class="row">
<h2>Metrics</h2>
</div>
<div class="row cer">
<p>Average CER: {{ cer_avg|round(4) }}</p>
<p>Average WER: {{ wer_avg|round(4) }}</p>
</div>
{% endif %}
{%- if diff_c and diff_w %}
{%- set sections = [{'title': 'Found differences (character)', 'data': diff_c}, {'title': 'Found differences (word)', 'data': diff_w}] %}
<div class="row">
{%- for section in sections %}
<div class="col-md-6">
<h2>{{ section['title'] }}</h2>
<table>
<thead>
<tr><th>GT</th><th>OCR</th><th>Occurrences</th></tr>
</thead>
{%- set num_omitted = namespace(value=0) -%}
{% for gt_ocr, occurrences in section['data'].items() -%}
{% if occurrences < occurrences_threshold -%}
{%- set num_omitted.value = num_omitted.value + 1 %}
{%- else -%}
{%- set gt = gt_ocr.split(" :: ")[0] %}
{%- set ocr = gt_ocr.split(" :: ")[1] %}
<tr>
<td title="{{ gt|urlencode }}">{{ gt }}</td>{# display the unicode character #}
<td title="{{ ocr|urlencode }}">{{ ocr }}</td >
<td>{{ occurrences }}</td>
</tr>
{%- endif %}
{%- endfor %}
{% if num_omitted.value > 0 and occurrences_threshold > 1 -%}
<p>Skipped {{ num_omitted.value }} diffs with fewer than {{ occurrences_threshold }} occurrences. The complete list of diffs is available in the accompanying JSON file.</p>
{%- set num_omitted.value = 0 %}
{%- endif %}
</table>
</div>
{%- endfor %}
</div>
{%- endif %}
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script>
{% include 'report.html.js' %}
</script>
</body>
</html>