Coral模型返回损坏的数据,直到python释放结果
我们正在使用coral stick和我们创建的自定义网络(基于vgg作为主干)。 我们使用的edge tpu版本是2.11 网络返回2个输出:形状1*12*12*65和1*12*12*256。 我们从python中这样调用网络:Coral模型返回损坏的数据,直到python释放结果,python,tensorflow,tensorflow-lite,google-coral,Python,Tensorflow,Tensorflow Lite,Google Coral,我们正在使用coral stick和我们创建的自定义网络(基于vgg作为主干)。 我们使用的edge tpu版本是2.11 网络返回2个输出:形状1*12*12*65和1*12*12*256。 我们从python中这样调用网络: def _run_net(self, crop : np.ndarray): orig_w = crop.shape[1] orig_h = crop.shape[0] if orig_w != WIDTH or orig_h != HEIG
def _run_net(self, crop : np.ndarray):
orig_w = crop.shape[1]
orig_h = crop.shape[0]
if orig_w != WIDTH or orig_h != HEIGHT:
crop = cv2.resize(crop, (WIDTH, HEIGHT))
image = crop.reshape(1, HEIGHT, WIDTH, 1)
all_data = self.engine.RunInference(image.flatten())[1]
tensor_sizes = self.engine.get_all_output_tensors_sizes()
num_points = int(math.sqrt(tensor_sizes[0] / 65))
raw_points = all_data[:tensor_sizes[0]]
raw_points = raw_points.reshape((1, num_points, num_points, 65))
raw_descriptors = all_data[tensor_sizes[0]:]
raw_descriptors = raw_descriptors.reshape((1, num_points, num_points, 256))
#Imprtant Note! the copy of raw points and desc here is a must, because as long as memory is held the net always return
#the same results!!! this seems to be a bug in coral
return (raw_points, raw_descriptors, orig_w, orig_h) #does not work
#return (np.copy(raw_points), np.copy(raw_descriptors), orig_w, orig_h) #works ok!
直到python对原始点和原始描述符调用gc为止
对同一网络(甚至引擎的新实例)的每次调用
将产生相同的输出。是否使用edgetpu基本引擎?因为它返回一个引用而不是副本,这与这个问题类似:@NamVu,是的,这确实是同一个问题,这就是为什么我们也使用结果的副本。这意味着网络不能在一根棍子上并行运行,对吗?你是对的,你不应该在一根棍子上并行运行任何东西。这里是一个参考演示脚本,其中一个函数将在同一个edgetpu:P.S.中的一个脚本上运行两个模型,还有另一个允许线程的功能,但对于2 tpusAFAIK,linux驱动程序不支持让多个进程同时访问同一个usb设备:/you使用edgetpu基本引擎吗?因为它返回一个引用而不是副本,这与这个问题类似:@NamVu,是的,这确实是同一个问题,这就是为什么我们也使用结果的副本。这意味着网络不能在一根棍子上并行运行,对吗?你是对的,你不应该在一根棍子上并行运行任何东西。这里是一个参考演示脚本,其中一个函数将在同一个edgetpu:P.S.中的一个脚本上运行两个模型,还有另一个允许线程的功能,但对于2 tpusAFAIK,linux驱动程序不支持多个进程同时访问同一个usb设备:/