| 632 | } |
| 633 | |
| 634 | bool ResourceMgr::load_bundle(const std::filesystem::path& path) |
| 635 | { |
| 636 | LogFunc << VAR(path); |
| 637 | |
| 638 | if (!std::filesystem::exists(path) || !std::filesystem::is_directory(path)) { |
| 639 | LogError << "path not exists or not a directory" << VAR(path); |
| 640 | return false; |
| 641 | } |
| 642 | |
| 643 | check_and_set_inference_device(); |
| 644 | |
| 645 | paths_.emplace_back(path); |
| 646 | |
| 647 | using namespace path_literals; |
| 648 | |
| 649 | bool to_load = false; |
| 650 | bool ret = true; |
| 651 | if (auto jc_path = path / "default_pipeline.jsonc"_path; std::filesystem::exists(jc_path)) { |
| 652 | to_load = true; |
| 653 | ret &= default_pipeline_.load(jc_path); |
| 654 | } |
| 655 | else if (auto j_path = path / "default_pipeline.json"_path; std::filesystem::exists(j_path)) { |
| 656 | to_load = true; |
| 657 | ret &= default_pipeline_.load(j_path); |
| 658 | } |
| 659 | |
| 660 | if (auto p = path / "pipeline"_path; std::filesystem::exists(p)) { |
| 661 | to_load = true; |
| 662 | ret &= pipeline_res_.load(p, default_pipeline_); |
| 663 | } |
| 664 | if (auto p = path / "model"_path / "ocr"_path; std::filesystem::exists(p)) { |
| 665 | to_load = true; |
| 666 | ret &= ocr_res_.lazy_load(p); |
| 667 | } |
| 668 | if (auto p = path / "model"_path / "classify"_path; std::filesystem::exists(p)) { |
| 669 | to_load = true; |
| 670 | ret &= onnx_res_.lazy_load_classifier(p); |
| 671 | } |
| 672 | if (auto p = path / "model"_path / "detect"_path; std::filesystem::exists(p)) { |
| 673 | to_load = true; |
| 674 | ret &= onnx_res_.lazy_load_detector(p); |
| 675 | } |
| 676 | if (auto p = path / "image"_path; std::filesystem::exists(p)) { |
| 677 | to_load = true; |
| 678 | ret &= template_res_.lazy_load(p); |
| 679 | } |
| 680 | |
| 681 | LogInfo << VAR(path) << VAR(ret) << VAR(to_load); |
| 682 | |
| 683 | return to_load && ret; |
| 684 | } |
| 685 | |
| 686 | bool ResourceMgr::load_ocr_model(const std::filesystem::path& path) |
| 687 | { |
nothing calls this directly
no test coverage detected