def CreateGraph(self, model, model_width, model_height, dvpp_width, dvpp_height): myGraph = hiai.hiai._global_default_graph_stack.get_default_graph() if myGraph is None: print 'get defaule graph failed' return None cropConfig = hiai.CropConfig(0, 0, dvpp_width, dvpp_height) print 'cropConfig ', cropConfig resizeConfig = hiai.ResizeConfig(model_width, model_height) print 'resizeConfig ', resizeConfig nntensorList = hiai.NNTensorList() print 'nntensorList', nntensorList resultCrop = hiai.crop(nntensorList, cropConfig) print 'resultCrop', resultCrop resultResize = hiai.resize(resultCrop, resizeConfig) print 'resultResize', resultResize resultInference = hiai.inference(resultResize, model, None) print 'resultInference', resultInference if (hiai.HiaiPythonStatust.HIAI_PYTHON_OK == myGraph.create_graph()): print 'create graph ok !!!!' return myGraph else: print 'create graph failed, please check Davinc log.' return None
def CreateGraph(model): # Get default graph, then arrange the pipeline myGraph = hiai.hiai._global_default_graph_stack.get_default_graph() if myGraph is None: print("[ERROR] Fail to get default graph.") return None nnTensorList = hiai.NNTensorList() hiai.inference(nnTensorList, model, None) if hiai.HiaiPythonStatust.HIAI_PYTHON_OK == myGraph.create_graph(): print("[OK] Finish creating graph.") return myGraph else: print("[ERROR] Fail to create graph, please check Davinc log.") return None
def CreateGraph(model): #调用get_default_graph获取默认Graph,再进行流程编排 myGraph = hiai.hiai._global_default_graph_stack.get_default_graph() if myGraph is None: print('get defaule graph failed') return None nntensorList = hiai.NNTensorList() resultInference = hiai.inference(nntensorList, model, None) if (hiai.HiaiPythonStatust.HIAI_PYTHON_OK == myGraph.create_graph()): print('create graph ok !') return myGraph else: print('create graph failed, please check Davinc log.') return None
def CreateGraphWithoutDVPP(self, model): myGraph = hiai.hiai._global_default_graph_stack.get_default_graph() if myGraph is None: print 'get defaule graph failed' return None nntensorList = hiai.NNTensorList() if nntensorList is None: print('nntensor is None') return None resultInference = hiai.inference(nntensorList, model, None) if (hiai.HiaiPythonStatust.HIAI_PYTHON_OK == myGraph.create_graph()): print 'create graph ok !!!!' return myGraph else: print 'create graph failed!' return None
def CreateGraph(model): # 调用get_default_graph获取默认Graph,再进行流程编排 myGraph = hiai.hiai._global_default_graph_stack.get_default_graph() if myGraph is None: print 'Get default graph failed' return None nntensorList = hiai.NNTensorList() # 不实用DVPP缩放图像,使用opencv缩放图片 resultInference = hiai.inference(nntensorList, model, None) # 不确定其功能 if (hiai.HiaiPythonStatust.HIAI_PYTHON_OK == myGraph.create_graph()): print 'create graph ok !' return myGraph else: print 'create graph failed, please check log.' return None
def CreateGraph(self, model): # 获取Graph实例 myGraph = hiai.hiai._global_default_graph_stack.get_default_graph() if myGraph is None: print('get defaule graph failed') return None # 初始化Engine,配置推理算子(加载模型) # API固定调用流程 nntensorList = hiai.NNTensorList() if (None == hiai.inference(nntensorList, model, None)): print('Init Engine failed !!!!') return None else: print('Init Engine ok!') # 创建推理接口 if (hiai.HiaiPythonStatust.HIAI_PYTHON_OK == myGraph.create_graph()): print('create graph ok !!!!') return myGraph else: print('create graph failed!') return None
def CreateGraphWithoutDVPP(model): print model myGraph = hiai.hiai._global_default_graph_stack.get_default_graph() print myGraph if myGraph is None: print 'get defaule graph failed' return None nntensorList = hiai.NNTensorList() print nntensorList resultInference = hiai.inference(nntensorList, model, None) print nntensorList print hiai.HiaiPythonStatust.HIAI_PYTHON_OK #print myGraph.create_graph() if (hiai.HiaiPythonStatust.HIAI_PYTHON_OK == myGraph.create_graph()): print 'create graph ok !!!!' return myGraph else: print 'create graph failed, please check Davinc log.' return None