"git@developer.sourcefind.cn:modelzoo/yolov5_migraphx.git" did not exist on "4ec98d75dd01b5b7fdcbc7dc3d4c6315621c3fbc"
Commit c1a342ac authored by mayong's avatar mayong
Browse files

tidy up some redundant files.

parent 2e9d117d
...@@ -13,5 +13,5 @@ class Model { ...@@ -13,5 +13,5 @@ class Model {
virtual std::string rescoring() = 0; virtual std::string rescoring() = 0;
}; };
Model *create_model(const char *path, int mode); Model *create_model(const char *path);
#endif #endif
#include "precomp.h" #include "precomp.h"
Model *create_model(const char *path, int mode) Model *create_model(const char *path)
{ {
Model *mm; Model *mm;
mm = new paraformer::ModelImp(path, mode); mm = new paraformer::ModelImp(path);
return mm; return mm;
} }
...@@ -3,20 +3,12 @@ ...@@ -3,20 +3,12 @@
using namespace std; using namespace std;
using namespace paraformer; using namespace paraformer;
ModelImp::ModelImp(const char* path, int mode,int nNumThread) ModelImp::ModelImp(const char* path,int nNumThread)
{ {
string model_path = pathAppend(path, "model.onnx"); string model_path = pathAppend(path, "model.onnx");
string vocab_path = pathAppend(path, "vocab.txt"); string vocab_path = pathAppend(path, "vocab.txt");
fe = new FeatureExtract(mode); fe = new FeatureExtract(3);
//p_helper = new ModelParamsHelper(wenet_path.c_str(), 500);
//encoder = new Encoder(&p_helper->params.encoder);
//predictor = new Predictor(&p_helper->params.predictor);
//decoder = new Decoder(&p_helper->params.decoder);
//sessionOptions.SetInterOpNumThreads(nNumThread); //sessionOptions.SetInterOpNumThreads(nNumThread);
sessionOptions.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED); sessionOptions.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED);
...@@ -48,18 +40,15 @@ ModelImp::ModelImp(const char* path, int mode,int nNumThread) ...@@ -48,18 +40,15 @@ ModelImp::ModelImp(const char* path, int mode,int nNumThread)
ModelImp::~ModelImp() ModelImp::~ModelImp()
{ {
delete fe; if(fe)
//delete p_helper; delete fe;
//delete encoder;
//delete predictor;
//
//delete decoder;
if (m_session) if (m_session)
{ {
delete m_session; delete m_session;
m_session = nullptr; m_session = nullptr;
} }
delete vocab; if(vocab)
delete vocab;
} }
void ModelImp::reset() void ModelImp::reset()
......
...@@ -39,7 +39,7 @@ namespace paraformer { ...@@ -39,7 +39,7 @@ namespace paraformer {
//string m_strOutputName, m_strOutputNameLen; //string m_strOutputName, m_strOutputNameLen;
public: public:
ModelImp(const char* path, int mode, int nNumThread=4); ModelImp(const char* path, int nNumThread=4);
~ModelImp(); ~ModelImp();
void reset(); void reset();
string forward_chunk(float* din, int len, int flag); string forward_chunk(float* din, int len, int flag);
......
...@@ -18,6 +18,14 @@ int main(int argc, char *argv[]) ...@@ -18,6 +18,14 @@ int main(int argc, char *argv[])
printf("Usage: %s /path/to/model_dir /path/to/wav/file", argv[0]); printf("Usage: %s /path/to/model_dir /path/to/wav/file", argv[0]);
exit(-1); exit(-1);
} }
Model* mm = create_model(argv[1]);
if (!mm)
{
printf("Cannot load ASR Model from: %s, there must be files model.onnx and vocab.txt", argv[1]);
exit(-1);
}
struct timeval start, end; struct timeval start, end;
Audio audio(0); Audio audio(0);
if (!audio.loadwav(argv[2])) if (!audio.loadwav(argv[2]))
...@@ -27,7 +35,7 @@ int main(int argc, char *argv[]) ...@@ -27,7 +35,7 @@ int main(int argc, char *argv[])
} }
audio.disp(); audio.disp();
gettimeofday(&start, NULL); gettimeofday(&start, NULL);
Model *mm = create_model(argv[1], 3);
gettimeofday(&end, NULL); gettimeofday(&end, NULL);
long seconds = (end.tv_sec - start.tv_sec); long seconds = (end.tv_sec - start.tv_sec);
long micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec); long micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment