1
0
mirror of https://github.com/open-mmlab/mmdeploy.git synced 2025-01-14 08:09:43 +08:00
lvhan028 3be1779e66
Refactor tests ()
* fix sdk model's pipeline.json

* resize INT64 mask

* refactor unit tests

* fix api in model.h

* remove 'customs' from meta info

* fix zip model

* fix clang-format issue

* put tc on each backend into a SECTION

* change SECTION title

* add DYNAMIC_SECTION for capi unit test

* change 'devices' to 'device_names'

* change trt to tensorrt

* remove uncessary check

* add color_type 'color_ignore_orientation' which is used in ocr

* 'min_width', 'max_width' and 'backend' might be null in pipeline config

* fix clang-format issue

* remove useless code
2021-12-17 19:57:37 +08:00

46 lines
1.2 KiB
C++

// Copyright (c) OpenMMLab. All rights reserved.
#include "test_utils.h"
using namespace std;
namespace mmdeploy::test {
unique_ptr<Transform> CreateTransform(const Value& cfg, Device device, Stream stream) {
auto op_type = cfg.value<string>("type", "");
auto op_version = cfg.value<int>("version", 1);
try {
auto creator = Registry<Transform>::Get().GetCreator(op_type, op_version);
if (creator == nullptr) {
return nullptr;
}
auto _cfg = cfg;
_cfg["context"]["device"] = device;
_cfg["context"]["stream"] = stream;
return creator->Create(_cfg);
} catch (std::exception& e) {
cout << "exception: " << e.what() << endl;
return nullptr;
} catch (...) {
cout << "unexpected exception" << endl;
return nullptr;
}
}
vector<int64_t> Shape(const Value& value, const string& shape_key) {
vector<int64_t> shape;
for (auto& v : value[shape_key]) {
shape.push_back(v.get<int>());
}
return shape;
}
vector<float> ImageNormCfg(const Value& value, const std::string& key) {
vector<float> res;
for (auto& v : value["img_norm_cfg"][key]) {
res.push_back(v.get<float>());
}
return res;
}
} // namespace mmdeploy::test