在这里,我正在使用mask_rcnn进行对象检测。 该代码正常运行,但现在出现以下错误。
代码:
Testing - 1
# 1 - 200 images testing
# Load a random image from the images folder
file_names = next(os.walk(IMAGE_DIR))[2]
i=0
for fn in file_names:
#image = skimage.io.imread(os.path.join(IMAGE_DIR, random.choice(file_names)))
i = i+1
print(i)
image = skimage.io.imread(os.path.join(IMAGE_DIR, fn))
# Run detection
results = model.detect([image], verbose=1)
# Visualize results
r = results[0]
visualize.display_instances(image, r['rois'], r['masks'], r['class_ids'],
class_names, r['scores'])
错误消息:
1
处理1张图像
图像形状:(1123,1588,3)最小值:13.00000最大值:255.00000 uint8
moulded_images形状:(1、1024、1024、3)最小值:-123.70000最大值:150.10000 float64
image_metas形状:(1,15)最小值:0.00000最大值:1588.00000 float64
锚点形状:(1,261888,4)最小值:-0.35390最大值:1.29134 float32
-------------------------------------------------- -------------------------
UnknownError跟踪(最近一次通话)
在
15
16#运行检测
---> 17个结果= model.detect([image],verbose = 1)
18岁
19#可视化结果
D:\gpu\projects1\Mask_RCNN-Multi-Class-Detection\model.py in detect(self, images, verbose)
2529 # Run object detection
2530 detections, _, _, mrcnn_mask, _, _, _ =\
-> 2531 self.keras_model.predict([molded_images, image_metas, anchors], verbose=0)
2532 # Process detections
2533 results = []
~\Anaconda3\envs\tf-gpu\lib\site-packages\keras\engine\training.py in predict(self, x, batch_size, verbose, steps, callbacks, max_queue_size, workers, use_multiprocessing)
1399 verbose=verbose,
1400 steps=steps,
-> 1401 callbacks=callbacks)
1402
1403 def train_on_batch(self, x, y,
~\Anaconda3\envs\tf-gpu\lib\site-packages\keras\engine\training_arrays.py in predict_loop(model, f, ins, batch_size, verbose, steps, callbacks)
330 batch_logs = {'batch': batch_index, 'size': len(batch_ids)}
331 callbacks._call_batch_hook('predict', 'begin', batch_index, batch_logs)
--> 332 batch_outs = f(ins_batch)
333 batch_outs = to_list(batch_outs)
334 if batch_index == 0:
~\Anaconda3\envs\tf-gpu\lib\site-packages\keras\backend\tensorflow_backend.py in __call__(self, inputs)
2977 return self._legacy_call(inputs)
2978
-> 2979 return self._call(inputs)
2980 else:
2981 if py_any(is_tensor(x) for x in inputs):
~\Anaconda3\envs\tf-gpu\lib\site-packages\keras\backend\tensorflow_backend.py in _call(self, inputs)
2935 fetched = self._callable_fn(*array_vals, run_metadata=self.run_metadata)
2936 else:
-> 2937 fetched = self._callable_fn(*array_vals)
2938 return fetched[:len(self.outputs)]
2939
~\Anaconda3\envs\tf-gpu\lib\site-packages\tensorflow\python\client\session.py in __call__(self, *args, **kwargs)
1456 ret = tf_session.TF_SessionRunCallable(self._session._session,
1457 self._handle, args,
-> 1458 run_metadata_ptr)
1459 if run_metadata:
1460 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)
UnknownError: 2 root error(s) found.
(0) Unknown: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
[[{{node conv1/convolution}}]]
[[mrcnn_detection/map/TensorArrayUnstack/range/_4207]]
(1) Unknown: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
[[{{node conv1/convolution}}]]
0 successful operations.
0 derived errors ignored.
答案 0 :(得分:0)
您必须检查CUDA + CUDNN + TensorFlow的版本是否正确(还要确保已安装所有版本。
下面提供了两个运行配置的示例
例如。 Cuda 10 + CuDNN 7.6.3 + TensorFlow 1.13 / 1.14可以工作。
Eg2 Cuda 9 + CuDNN 7.0.5 + TensorFlow 1.10有效
通常,当您安装了不兼容的TensorFlow / CuDNN版本时,会出现此错误。就我而言,这是当我尝试使用较旧的TensorFlow和较新版本的CuDNN时出现的。