Skip to content

Commit

Permalink
[bugfix] fix uie (#8379)
Browse files Browse the repository at this point in the history
* fix uie

* fix windows bug
  • Loading branch information
w5688414 committed May 9, 2024
1 parent eeafb21 commit c02712e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion model_zoo/uie/finetune.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def custom_evaluate(self, model, data_loader):
num_correct, num_infer, num_label = metric.compute(start_prob, end_prob, start_ids, end_ids)
metric.update(num_correct, num_infer, num_label)
precision, recall, f1 = metric.accumulate()
logger.info("f1: %s, precision: %s, recall: %s" % (f1, precision, f1))
logger.info("f1: %s, precision: %s, recall: %s" % (f1, precision, recall))
model.train()
return f1

Expand Down
11 changes: 6 additions & 5 deletions paddlenlp/utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,13 @@ def _find_segment_in_box(layouts, box, threshold=0.7):
p = img_file.find("-")
img_file = img_file[p + 1 :]

img_path = os.path.join("/".join(self.label_studio_file.split("/")[:-1]), "images", img_file)
# Get file path for adapting to windows
file_dir = os.path.dirname(self.label_studio_file)
# Get image file path
img_path = os.path.join(file_dir, "images", img_file)

if not os.path.exists(img_path):
logger.warning(
"Image file %s not exist in %s"
% (img_file, "/".join(self.label_studio_file.split("/")[:-1]) + "images")
)
logger.warning("Image file %s not exist in %s" % (img_file, os.path.join(file_dir, "images")))
return None
logger.info("Parsing image file %s ..." % (img_file))
doc_parser = DocParser(layout_analysis=self.layout_analysis, ocr_lang=self.ocr_lang)
Expand Down

0 comments on commit c02712e

Please sign in to comment.