Content-Length: 317592 | pFad | http://github.com/opencv/opencv/pull/27449/commits/192280b35c338a9e7470cddfa89733e2e7c31e1f

CD Onnx multifile import by nklskyoy · Pull Request #27449 · opencv/opencv · GitHub
Skip to content

Onnx multifile import #27449

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

Open
wants to merge 14 commits into
base: 5.x
Choose a base branch
from
Prev Previous commit
Next Next commit
check filesystem avalability & fs::join
  • Loading branch information
nklskyoy committed Jun 22, 2025
commit 192280b35c338a9e7470cddfa89733e2e7c31e1f
8 changes: 7 additions & 1 deletion modules/dnn/src/onnx/onnx_graph_simplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#ifdef HAVE_PROTOBUF
#include "../graph_simplifier.hpp"
#include "onnx_graph_simplifier.hpp"
#include <opencv2/core/utils/filesystem.hpp>
#include "opencv2/core/utils/filesystem.private.hpp"

#include <opencv2/core/utils/logger.hpp>
#include <queue>
Expand Down Expand Up @@ -1709,6 +1711,7 @@ void simplifySubgraphs(opencv_onnx::GraphProto& net)


void getExternalTensorData(const opencv_onnx::TensorProto& tensor_proto, std::vector<char>& tensor_data, const std::string& base_path = ""){
#if OPENCV_HAVE_FILESYSTEM_SUPPORT
CV_Assert(tensor_proto.has_data_location() && tensor_proto.data_location() == opencv_onnx::TensorProto::EXTERNAL);
auto it_begin = tensor_proto.external_data().begin();
auto it_end = tensor_proto.external_data().end();
Expand All @@ -1717,7 +1720,7 @@ void getExternalTensorData(const opencv_onnx::TensorProto& tensor_proto, std::ve
CV_Assert(it != it_end);

std::string location_path = it->value();
std::string full_path = base_path.empty() ? location_path : (base_path + "/" + location_path);
std::string full_path = base_path.empty() ? location_path : utils::fs::join(base_path, location_path);

std::ifstream file(full_path, std::ios::binary | std::ios::ate);
CV_Assert(file.is_open());
Expand All @@ -1727,6 +1730,9 @@ void getExternalTensorData(const opencv_onnx::TensorProto& tensor_proto, std::ve
tensor_data.resize(size);

CV_Assert(file.read(tensor_data.data(), size));
#else
CV_Error(Error::StsNotImplemented, "External tensor data is not supported without filesystem support");
#endif
}


Expand Down
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/opencv/opencv/pull/27449/commits/192280b35c338a9e7470cddfa89733e2e7c31e1f

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy