Hanz Pillerva commited on
Commit Β·
5ee27ce
1
Parent(s): 7a4ffc1
update
Browse files- app.py +0 -6
- template_matcher.py +6 -2
app.py
CHANGED
|
@@ -443,7 +443,6 @@ def _map_confidence_for_form(raw_confidence, form_hint):
|
|
| 443 |
return {
|
| 444 |
'registry_no': p('registry_no'),
|
| 445 |
'city_municipality': p('city_municipality'),
|
| 446 |
-
'date_submitted': p('registration_date'),
|
| 447 |
'child_first': p('name_first'),
|
| 448 |
'child_middle': p('name_middle'),
|
| 449 |
'child_last': p('name_last'),
|
|
@@ -463,11 +462,9 @@ def _map_confidence_for_form(raw_confidence, form_hint):
|
|
| 463 |
if form_hint == '2A':
|
| 464 |
# Keys must match what Form2A Val looks up:
|
| 465 |
# registry β registry_no (via confidenceKeyMap)
|
| 466 |
-
# date_reg β date_submitted (via confidenceKeyMap)
|
| 467 |
# all others are direct display-key lookups
|
| 468 |
return {
|
| 469 |
'registry_no': p('registry_no'),
|
| 470 |
-
'date_submitted': p('registration_date'),
|
| 471 |
'deceased_name': p('deceased_name'),
|
| 472 |
'sex': p('sex'),
|
| 473 |
'age': p('age'),
|
|
@@ -694,7 +691,6 @@ def _map_template_output(raw: dict, form_hint: str) -> dict:
|
|
| 694 |
'registry_no': g('registry_no'),
|
| 695 |
'city_municipality': g('city_municipality'),
|
| 696 |
'province': g('province'),
|
| 697 |
-
'date_submitted': g('registration_date'),
|
| 698 |
'child_first': g('name_first'),
|
| 699 |
'child_middle': g('name_middle'),
|
| 700 |
'child_last': g('name_last'),
|
|
@@ -719,7 +715,6 @@ def _map_template_output(raw: dict, form_hint: str) -> dict:
|
|
| 719 |
'registry_no': g('registry_no'),
|
| 720 |
'city_municipality': g('city_municipality'),
|
| 721 |
'province': g('province'),
|
| 722 |
-
'date_submitted': g('registration_date'),
|
| 723 |
'deceased_first': g('deceased_name'),
|
| 724 |
'sex': g('sex'),
|
| 725 |
'age_years': g('age'),
|
|
@@ -735,7 +730,6 @@ def _map_template_output(raw: dict, form_hint: str) -> dict:
|
|
| 735 |
'registry_no': g('registry_no'),
|
| 736 |
'city_municipality': g('city_municipality'),
|
| 737 |
'province': g('province'),
|
| 738 |
-
'date_submitted': g('registration_date'),
|
| 739 |
'husband_first': g('husband_name_first'),
|
| 740 |
'husband_middle': g('husband_name_middle'),
|
| 741 |
'husband_last': g('husband_name_last'),
|
|
|
|
| 443 |
return {
|
| 444 |
'registry_no': p('registry_no'),
|
| 445 |
'city_municipality': p('city_municipality'),
|
|
|
|
| 446 |
'child_first': p('name_first'),
|
| 447 |
'child_middle': p('name_middle'),
|
| 448 |
'child_last': p('name_last'),
|
|
|
|
| 462 |
if form_hint == '2A':
|
| 463 |
# Keys must match what Form2A Val looks up:
|
| 464 |
# registry β registry_no (via confidenceKeyMap)
|
|
|
|
| 465 |
# all others are direct display-key lookups
|
| 466 |
return {
|
| 467 |
'registry_no': p('registry_no'),
|
|
|
|
| 468 |
'deceased_name': p('deceased_name'),
|
| 469 |
'sex': p('sex'),
|
| 470 |
'age': p('age'),
|
|
|
|
| 691 |
'registry_no': g('registry_no'),
|
| 692 |
'city_municipality': g('city_municipality'),
|
| 693 |
'province': g('province'),
|
|
|
|
| 694 |
'child_first': g('name_first'),
|
| 695 |
'child_middle': g('name_middle'),
|
| 696 |
'child_last': g('name_last'),
|
|
|
|
| 715 |
'registry_no': g('registry_no'),
|
| 716 |
'city_municipality': g('city_municipality'),
|
| 717 |
'province': g('province'),
|
|
|
|
| 718 |
'deceased_first': g('deceased_name'),
|
| 719 |
'sex': g('sex'),
|
| 720 |
'age_years': g('age'),
|
|
|
|
| 730 |
'registry_no': g('registry_no'),
|
| 731 |
'city_municipality': g('city_municipality'),
|
| 732 |
'province': g('province'),
|
|
|
|
| 733 |
'husband_first': g('husband_name_first'),
|
| 734 |
'husband_middle': g('husband_name_middle'),
|
| 735 |
'husband_last': g('husband_name_last'),
|
template_matcher.py
CHANGED
|
@@ -187,8 +187,12 @@ def _crnn_read_batch_with_confidence(crops: list) -> list:
|
|
| 187 |
# Mean confidence over character-bearing frames
|
| 188 |
conf = float(max_probs[:, n][non_blank_mask].mean().item())
|
| 189 |
else:
|
| 190 |
-
|
| 191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
conf = 1.0
|
| 193 |
|
| 194 |
results.append((text, round(conf, 4)))
|
|
|
|
| 187 |
# Mean confidence over character-bearing frames
|
| 188 |
conf = float(max_probs[:, n][non_blank_mask].mean().item())
|
| 189 |
else:
|
| 190 |
+
conf = 1.0
|
| 191 |
+
|
| 192 |
+
# If the final decoded text is empty (line noise, form borders,
|
| 193 |
+
# or unrecognised characters all got decoded away), the extraction
|
| 194 |
+
# is still "correct" β nothing was there β so override to 100%.
|
| 195 |
+
if not text:
|
| 196 |
conf = 1.0
|
| 197 |
|
| 198 |
results.append((text, round(conf, 4)))
|