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

Better Automodel Design #146

Merged
merged 4 commits into from
Aug 6, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
more tests for automodels
lolipopshock committed Aug 5, 2022
commit 1000513e1da9fa86674b97eae3a818b7ca563bc3
37 changes: 30 additions & 7 deletions tests/test_model.py
Original file line number Diff line number Diff line change
@@ -44,11 +44,6 @@
"lp://MFD/tf_efficientdet_d1/config",
]

AUTOMODEL_CONFIGS = [
"lp://detectron2/PubLayNet/faster_rcnn_R_50_FPN_3x/config",
"lp://paddledetection/PubLayNet/ppyolov2_r50vd_dcn_365e/config",
"lp://efficientdet/PubLayNet/tf_efficientdet_d0/config",
]

def _construct_valid_config_variations(config, backend_name):
dataset_name, arch_name, identifier = config[len("lp://") :].split("/")
@@ -152,8 +147,36 @@ def test_EffDetModel(is_large_scale=False):
EfficientDetLayoutModel, ALL_EFFDET_MODEL_CONFIGS[0]
)


def test_AutoModel():
for config in AUTOMODEL_CONFIGS:

# Full configs
auto_model_config_1 = [
"lp://detectron2/PubLayNet/faster_rcnn_R_50_FPN_3x/config",
"lp://paddledetection/PubLayNet/ppyolov2_r50vd_dcn_365e/config",
"lp://efficientdet/PubLayNet/tf_efficientdet_d0/config",
]
for config in auto_model_config_1:
model = AutoLayoutModel(config)
image = cv2.imread("tests/fixtures/model/test_model_image.jpg")
layout = model.detect(image)
layout = model.detect(image)

# Dataset name only
# It will use the first available model
auto_model_config_2 = [
"lp://PubLayNet",
"lp://MFD",
]
for config in auto_model_config_1:
model = AutoLayoutModel(config)
model.DETECTOR_NAME == "efficientdet"

# Automodel name that doesn't work

# 1. No available backend for the model
with pytest.raises(ValueError):
model = AutoLayoutModel("lp://prima")

# 2. completely Invalid name
with pytest.raises(ValueError):
model = AutoLayoutModel("lp://test")