Skip to content

add ut for build_loss and build_postprocess #144

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

Merged
merged 1 commit into from
Apr 3, 2023
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
22 changes: 22 additions & 0 deletions tests/ut/test_loss.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import sys
sys.path.append('.')
import pytest
import yaml
import numpy as np
import mindspore as ms
from addict import Dict
from mindocr.losses import build_loss


@pytest.mark.parametrize('task', ['det', 'rec'])
def test_build_loss(task):
if task == 'det':
config_fp = 'configs/det/dbnet/db_r50_icdar15.yaml'
elif task=='rec':
config_fp = 'configs/rec/crnn/crnn_icdar15.yaml'

with open(config_fp) as fp:
cfg = yaml.safe_load(fp)
cfg = Dict(cfg)

loss_fn = build_loss(cfg.loss.pop('name'), **cfg['loss'])
21 changes: 21 additions & 0 deletions tests/ut/test_postprocess.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import sys
sys.path.append('.')
import pytest
import numpy as np
import yaml
from addict import Dict
from mindocr.postprocess import build_postprocess


@pytest.mark.parametrize('task', ['det', 'rec'])
def test_build_postprocess(task):
if task == 'det':
config_fp = 'configs/det/dbnet/db_r50_icdar15.yaml'
elif task=='rec':
config_fp = 'configs/rec/crnn/crnn_icdar15.yaml'

with open(config_fp) as fp:
cfg = yaml.safe_load(fp)
cfg = Dict(cfg)

postprocessor = build_postprocess(cfg.postprocess)