Comments (2)
可以的,tensorRT可以从文件加载模型
from mtcnn_facedetection_tensorrt.
我按照tensorRT-inference里面的代码将您程序中baseEngine.cpp改成如下形式:
`void baseEngine::caffeToGIEModel(const std::string &deployFile, // name for caffe prototxt
const std::string &modelFile, // name for model
const std::vectorstd::string &outputs, // network outputs
unsigned int maxBatchSize, // batch size - NB must be at least as large as the batch we want to run with)
IHostMemory *&gieModelStream) // output buffer for the GIE model
{
stringstream gieStream;
gieStream.seekg(0, gieStream.beg);
char cache_file[512];
sprintf(cache_file, "%s.engine", modelFile.c_str());
std::ifstream cache(cache_file);
if (!cache) {
// create the builder
IBuilder *builder = createInferBuilder(gLogger);
// parse the caffe model to populate the network, then set the outputs
INetworkDefinition *network = builder->createNetwork();
ICaffeParser *parser = createCaffeParser();
const IBlobNameToTensor *blobNameToTensor = parser->parse(deployFile.c_str(),
modelFile.c_str(),
*network,
nvinfer1::DataType::kHALF);
// specify which tensors are outputs
for (auto &s : outputs)
network->markOutput(*blobNameToTensor->find(s.c_str()));
// Build the engine
builder->setMaxBatchSize(maxBatchSize);
builder->setMaxWorkspaceSize(1 << 25);
builder->setHalf2Mode(true);
// cuda engie
ICudaEngine*engine = builder->buildCudaEngine(*network);
assert(engine);
nvinfer1::IHostMemory* serMem = engine->serialize();
gieStream.write((const char*)serMem->data(), serMem->size());
// we don't need the network any more, and we can destroy the parser
network->destroy();
parser->destroy();
builder->destroy();
std::ofstream outFile;
outFile.open(cache_file);
outFile << gieStream.rdbuf();
outFile.close();
gieStream.seekg(0, gieStream.beg);
} else {
printf("loading network profile from engine cache... %s\n", cache_file);
gieStream << cache.rdbuf();
cache.close();
}
nvinfer1::IRuntime* infer = nvinfer1::createInferRuntime(gLogger);
gieStream.seekg(0, std::ios::end);
const int modelSize = gieStream.tellg();
gieStream.seekg(0, std::ios::beg);
void* modelMem = malloc(modelSize);
gieStream.read((char*)modelMem, modelSize);
nvinfer1::ICudaEngine* engine = infer->deserializeCudaEngine(modelMem, modelSize, NULL);
free(modelMem);
assert(engine);
context = engine->createExecutionContext();
}
`
代码能够编译通过,运行也能产生中间文件,但是没有输出结果,大佬有时间能指导一下怎么改一下吗?
from mtcnn_facedetection_tensorrt.
Related Issues (20)
- could not parse layer type PReLU? HOT 4
- Prelu replacement - "Weights for scale layer" doesn't exists HOT 1
- 请问使用Relu layer, Scale layer 和 ElementWise替换prelu需要重新训练吗? HOT 2
- stack smashing detected HOT 1
- core dump from detect function HOT 2
- MTCNN not worked when continueously pass images?
- 输入640x480的话是重新生成这个size的caffe模型吗
- 输出信息
- why add means? HOT 5
- Problem about model training
- 请问现在这个项目是还没有跑通嘛?只有PNet和RNet HOT 12
- bug the sample with image is not working HOT 1
- 多进程运行报错
- inference speed too slow HOT 1
- Int8Calibrator HOT 2
- few quotations on gpu version HOT 2
- core dumped HOT 7
- Intuition of replacing PReLU HOT 9
- tensorrt speed improvement interms of libtorch with cuda or caffe with cuda?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mtcnn_facedetection_tensorrt.