Tensorflow目标检测API未检测到任何内容。

12

我正在尝试实现Tensorflow目标检测API示例。我正在关注sentdex的视频以开始。样例代码可以完美运行,还显示用于测试结果的图像,但未显示检测到对象周围的边界。只显示平面图像而没有任何错误。

我正在使用此代码:这个Github链接

这是我运行示例代码后得到的结果。

enter image description here

另一张没有任何检测的图片。

enter image description here

我在这里缺少什么?代码已包含在上面的链接中,且没有错误日志。
依次为盒子、分数、类别和数量的结果。
  [[[ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.20880508  1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.20934391  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.20880508  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]]]
[[ 0.03587547  0.02224986  0.0186467   0.01096812  0.01003207  0.00654409
   0.00633549  0.00534311  0.0049596   0.00410213  0.00362371  0.00339186
   0.00308251  0.00303347  0.00293389  0.00277099  0.00269575  0.00266825
   0.00263925  0.00263331  0.00258657  0.00240822  0.0022581   0.00186967
   0.00184311  0.00180467  0.00177475  0.00173655  0.00172811  0.00171935
   0.00171891  0.00170288  0.00163755  0.00162967  0.00160273  0.00156545
   0.00153615  0.00140941  0.00132407  0.00131524  0.0013105   0.00129431
   0.0012582   0.0012553   0.00122365  0.00119186  0.00115651  0.00115186
   0.00112369  0.00107097  0.00105805  0.00104338  0.00102719  0.00102337
   0.00100349  0.00097762  0.00096851  0.00092741  0.00088506  0.00087696
   0.0008734   0.00084826  0.00084135  0.00083513  0.00083398  0.00082068
   0.00080583  0.00078979  0.00078059  0.00077476  0.00075448  0.00074426
   0.00074421  0.00070195  0.00068741  0.00068138  0.00067262  0.00067125
   0.00067033  0.00066035  0.00064729  0.00064205  0.00061964  0.00061794
   0.00060835  0.00060465  0.00059548  0.00059479  0.00059461  0.00059436
   0.00059426  0.00059411  0.00059406  0.00059392  0.00059365  0.00059351
   0.00059191  0.00058798  0.00058682  0.00058148]]
[[  1.   1.  18.  32.  62.  60.  63.  67.  61.  49.  31.  84.  50.  54.
   15.  44.  44.  49.  31.  56.  88.  28.  88.  52.  17.  32.  38.  75.
    3.  33.  48.  59.  35.  57.  47.  51.  19.  27.  72.   4.  84.   6.
   55.  20.  58.  65.  61.  82.  42.  34.  40.  21.  43.  64.  39.  62.
   36.  22.  79.  46.  16.  40.  41.  77.  16.  48.  78.  77.  89.  86.
   27.   8.  87.   5.  25.  70.  80.  76.  75.  67.  65.  37.   2.   9.
   73.  63.  29.  30.  69.  66.  68.  26.  71.  12.  45.  83.  13.  85.
   74.  23.]]
[ 100.]
[[[ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.00784111  0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]]]
[[ 0.01044297  0.0098214   0.00942165  0.00846471  0.00613666  0.00398615
   0.00357754  0.0030054   0.00255861  0.00236574  0.00232631  0.00220291
   0.00185227  0.0016354   0.0015979   0.00145072  0.00143661  0.00141369
   0.00122685  0.00118978  0.00108457  0.00104251  0.00099215  0.00096401
   0.0008708   0.00084773  0.00080484  0.00078507  0.00078378  0.00076876
   0.00072774  0.00071732  0.00071348  0.00070812  0.00069253  0.0006762
   0.00067269  0.00059905  0.00059367  0.000588    0.00056114  0.0005504
   0.00051472  0.00051057  0.00050973  0.00048486  0.00047297  0.00046204
   0.00044787  0.00043259  0.00042987  0.00042673  0.00041978  0.00040494
   0.00040087  0.00039576  0.00039059  0.00037274  0.00036831  0.00036417
   0.00036119  0.00034645  0.00034479  0.00034078  0.00033771  0.00033605
   0.0003333   0.0003304   0.0003294   0.00032326  0.00031787  0.00031773
   0.00031748  0.00031741  0.00031732  0.00031729  0.00031724  0.00031722
   0.00031717  0.00031708  0.00031702  0.00031579  0.00030416  0.00030222
   0.00029739  0.00029726  0.00028289  0.0002653   0.00026325  0.00024584
   0.00024221  0.00024156  0.00023911  0.00023335  0.00021619  0.0002001
   0.00019127  0.00018342  0.00017273  0.00015509]]
[[ 38.   1.   1.  16.  25.  38.  64.  24.  49.  56.  20.   3.  28.   2.
   48.  19.  21.  62.  50.   6.   8.   7.  67.  18.  35.  53.  39.  55.
   15.  57.  72.  52.  10.   5.  42.  43.  76.  22.  82.   4.  61.  23.
   17.  16.  87.  62.  51.  60.  36.  58.  59.  33.  31.  54.  70.  11.
   40.  79.  31.   9.  41.  77.  80.  34.  90.  89.  73.  13.  84.  32.
   63.  29.  30.  69.  66.  68.  26.  71.  12.  45.  83.  14.  44.  78.
   85.  46.  47.  19.  65.  74.  37.  27.  63.  88.  28.  81.  86.  75.
   27.  18.]]
[ 100.]

根据建议的答案,当我们使用faster_rcnn_resnet101_coco_2017_11_08模型时,它是有效的。但是这个模型更精确,因此速度较慢。我希望这个应用程序具有高速性,因为我将在实时(通过网络摄像头)中使用它进行物体检测。因此,我需要使用更快的模型(ssd_mobilenet_v1_coco_2017_11_08)。

2
你能展示一下 (boxes, scores, classes, num) 的值吗?我想了解是否检测到任何物体。 - Rick
我该如何做?@Zephro - Kaushal28
是的 ;) print(boxes),print(scores),... - Rick
有什么想法吗?@Zephro - Kaushal28
1
我也想加入。我在 Linux 下尝试了完全相同的操作,结果出现了相同的行为。 - amo-ej1
显示剩余7条评论
5个回答

5
问题来自模型:'ssd_mobilenet_v1_coco_2017_11_08' 解决方案:更改为其他版本的'ssd_mobilenet_v1_coco_11_06_2017'。(这种模型类型是最快的,更换其他模型类型会使速度变慢并且不符合您的要求)
只需更改一行代码即可:
# What model to download.
MODEL_NAME = 'ssd_mobilenet_v1_coco_11_06_2017'

当我使用您的代码时,没有显示任何内容,但当我使用之前的实验模型'ssd_mobilenet_v1_coco_11_06_2017'替换它时,它可以正常工作


同样的问题...没有检测到任何对象..我使用了这个模型进行迁移学习: ssdlite_mobilenet_v2_coco_2018_05_09操作系统: Windows 7 Python版本: Python 3.5.2 |Anaconda custom (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32 - Devharsh Trivedi
抱歉,我不明白你的意思。你是指当你应用上述代码时,程序仍然无法检测到任何对象吗? - Tin Luu
是的,我使用了ssdlite_mobilenet_v2_coco_2018_05_09,并成功将损失降至0.9,但仍未检测到任何对象。现在我已经切换到ssd_mobilenet_v1_coca_2017_11_17,看起来它正在工作。 - Devharsh Trivedi
我可以确认,将模型从“2017_11_08”更改为“11_06_2017”是有效的。我能看到带有边界框的图像...感谢@TinLuu! - RVC

2

作为一种解决方法,将 #MODEL_NAME = 'ssd_mobilenet_v1_coco_2017_11_08' 更改为 MODEL_NAME = 'faster_rcnn_resnet101_coco_2017_11_08'。


1

您可以使用旧版本的 'ssd_mobilenet_v1 ...' 并完全运行带有框的程序(我刚刚运行了它,结果正确)。这是链接到旧版本。希望他们尽快修正新版本!


0

我曾经有同样的问题。

但是最近上传了一个新模型'ssd_mobilenet_v1_coco_2017_11_17'

我尝试了一下,效果非常好 :)


-1

函数 visualize_boxes_and_labels_on_image_array 的代码如下:

  for i in range(min(max_boxes_to_draw, boxes.shape[0])):
    if scores is None or scores[i] > min_score_thresh:

所以,得分必须大于min_score_thresh(默认为0.5),您可以检查是否有一些得分大于它。

那么为什么即使它正确检测,得分也不会超过0.5呢? - Kaushal28
那么如果模型'ssd_mobilenet_v1_coco_2017_11_08'存在问题,这是否意味着使用它进行训练也会有问题?我尝试用它进行训练,但是它卡在了第一步:global_step/sec: 0. 已经停滞了将近9个小时。 我的训练是在CPU上执行的。 - Mandroid
@Kaushal28 你可以使用模型“faster_rcnn_resnet101_coco_2017_11_08”代替“ssd_mobilenet_v1_coco_2017_11_08”。 - Jack.Liu
@Jack.Liu:这与阈值无关,而是模型问题,无法可靠地检测。 - Tin Luu

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接