Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calamari-predict-and-eval args #366

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion calamari_ocr/ocr/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,5 @@ def evaluate(self, *, gt_data: Dict[str, str], pred_data: Dict[str, str]):
)

res = Evaluator.evaluate_single_list(out, True)
res["ids"] = gt_ids
res["ids"] = list(gt_ids)
return res
8 changes: 4 additions & 4 deletions calamari_ocr/scripts/predict_and_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class PredictAndEvalArgs:
default_factory=FileDataParams,
metadata=pai_meta(mode="flat", help="Input data", choices=DATA_GENERATOR_CHOICES),
)
voter: VoterParams = field(default_factory=VoterParams)
predictor: PredictorParams = field(
default_factory=PredictorParams,
metadata=pai_meta(mode="flat", help="Predictor data"),
Expand Down Expand Up @@ -71,10 +72,9 @@ def main(args: PredictAndEvalArgs):

from calamari_ocr.ocr.predict.predictor import MultiPredictor

voter_params = VoterParams()
predictor = MultiPredictor.from_paths(
checkpoints=args.checkpoint,
voter_params=voter_params,
voter_params=args.voter,
predictor_params=args.predictor,
)
do_prediction = predictor.predict(args.data)
Expand All @@ -85,8 +85,8 @@ def main(args: PredictAndEvalArgs):
for s in do_prediction:
(result, prediction) = s.outputs
sentence = prediction.sentence
if prediction.voter_predictions is not None and args.output_individual_voters:
for i, p in enumerate(prediction.voter_predictions):
if args.output_individual_voters:
for i, p in enumerate(result):
if i not in all_prediction_sentences:
all_prediction_sentences[i] = {}
all_prediction_sentences[i][s.meta["id"]] = p.sentence
Expand Down
Loading