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

V0.3 fixes #75

Merged
merged 2 commits into from
Sep 14, 2021
Merged
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
11 changes: 9 additions & 2 deletions src/layoutparser/models/detectron2/layoutmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ def __init__(
)
config_path = PathManager.get_local_path(config_path)

if label_map is None:
if config_path.startswith("lp://"):
dataset_name = config_path.lstrip("lp://").split("/")[1]
label_map = LABEL_MAP_CATALOG[dataset_name]
else:
label_map = {}

cfg = detectron2.config.get_cfg()
cfg.merge_from_file(config_path)
cfg.merge_from_list(extra_config)
Expand Down Expand Up @@ -126,8 +133,8 @@ def gather_output(self, outputs):
for score, box, label in zip(scores, boxes, labels):
x_1, y_1, x_2, y_2 = box

if self.label_map is not None:
label = self.label_map.get(label, label)

label = self.label_map.get(label, label)

cur_block = TextBlock(
Rectangle(x_1, y_1, x_2, y_2), type=label, score=score
Expand Down
1 change: 0 additions & 1 deletion src/layoutparser/models/model_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
- Brief format: lp://<dataset-name>/<config, weight>
"""

from typing import List, OrderedDict, Union, Dict, Any, Tuple, Optional, NamedTuple
from dataclasses import dataclass

LAYOUT_PARSER_MODEL_PREFIX = "lp://"
Expand Down