Skip to content
Snippets Groups Projects

Expose element confidence on CreateElementTranscriptions helper

Merged Yoann Schneider requested to merge expose-element-confidence into master
2 files
+ 36
0
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -227,6 +227,8 @@ class TranscriptionMixin(object):
Required. Confidence score between 0 and 1.
orientation ([TextOrientation][arkindex_worker.worker.transcription.TextOrientation])
Optional. Orientation of the transcription's text.
element_confidence (float)
Optional. Confidence score of the element between 0 and 1.
:returns: A list of dicts as returned by the ``CreateElementTranscriptions`` API endpoint.
"""
@@ -278,6 +280,12 @@ class TranscriptionMixin(object):
assert all(
isinstance(coord, (int, float)) for point in polygon for coord in point
), f"Transcription at index {index} in transcriptions: polygon points should be lists of two numbers"
element_confidence = transcription.get("element_confidence")
assert element_confidence is None or (
isinstance(element_confidence, float) and 0 <= element_confidence <= 1
), f"Transcription at index {index} in transcriptions: element_confidence should be either null or a float in [0..1] range"
if self.is_read_only:
logger.warning(
"Cannot create transcriptions as this worker is in read-only mode"
@@ -327,6 +335,7 @@ class TranscriptionMixin(object):
"image_id": element.image_id,
"polygon": transcription["polygon"],
"worker_run_id": self.worker_run_id,
"confidence": transcription.get("element_confidence"),
}
)
Loading