Skip to content

Commit

Permalink
Add docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
plutasnyy committed Apr 22, 2024
1 parent fd20378 commit 83e7e22
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions unstructured_inference/models/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,25 @@ def outputs_to_objects(
def apply_thresholds_on_objects(
objects: Sequence[Mapping[str, Any]], thresholds: Mapping[str, float]
) -> Sequence[Mapping[str, Any]]:
"""
Filters predicted objects which the confidence scores below the thresholds
Args:
objects: Sequence of mappings for example:
[
{
"label": "table row",
"score": 0.55,
"bbox": [...],
},
...,
]
thresholds: Mapping from labels to thresholds
Returns:
Filtered list of objects
"""
objects = [obj for obj in objects if obj["score"] >= thresholds[obj["label"]]]
return objects

Expand Down

0 comments on commit 83e7e22

Please sign in to comment.