YunYang1994/tensorflow-yolov3 IndexError: list index out of range 解决办法
YunYang1994/tensorflow-yolov3 IndexError: list index out of range 解決辦法
- 原項(xiàng)目地址:YunYang1994/tensorflow-yolov3
- 報(bào)錯(cuò)描述:
- 詳細(xì)描述:
- 尋找錯(cuò)誤原因:
- 總結(jié):
原項(xiàng)目地址:YunYang1994/tensorflow-yolov3
報(bào)錯(cuò)描述:
運(yùn)行識(shí)別程序 video_demo.py 時(shí),程序報(bào)錯(cuò):
D:\Yolov3_Tensorflow\python\python.exe D:/Yolov3_Tensorflow/tensorflow-yolov3/video_demo.py 2019-10-10 08:26:58.675604: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 2019-10-10 08:26:59.363176: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1411] Found device 0 with properties: name: GeForce MX250 major: 6 minor: 1 memoryClockRate(GHz): 1.582 pciBusID: 0000:01:00.0 totalMemory: 2.00GiB freeMemory: 1.62GiB 2019-10-10 08:26:59.363377: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1490] Adding visible gpu devices: 0 2019-10-10 08:27:00.278345: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] Device interconnect StreamExecutor with strength 1 edge matrix: 2019-10-10 08:27:00.278458: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] 0 2019-10-10 08:27:00.278519: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0: N 2019-10-10 08:27:00.278730: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1103] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1374 MB memory) -> physical GPU (device: 0, name: GeForce MX250, pci bus id: 0000:01:00.0, compute capability: 6.1) 2019-10-10 08:27:18.867149: W tensorflow/core/common_runtime/bfc_allocator.cc:215] Allocator (GPU_0_bfc) ran out of memory trying to allocate 1.13GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available. 2019-10-10 08:27:18.894705: W tensorflow/core/common_runtime/bfc_allocator.cc:215] Allocator (GPU_0_bfc) ran out of memory trying to allocate 1.14GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available. 2019-10-10 08:27:18.898060: W tensorflow/core/common_runtime/bfc_allocator.cc:215] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.13GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available. 2019-10-10 08:27:19.032698: W tensorflow/core/common_runtime/bfc_allocator.cc:215] Allocator (GPU_0_bfc) ran out of memory trying to allocate 1.60GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available. 2019-10-10 08:27:19.109551: W tensorflow/core/common_runtime/bfc_allocator.cc:215] Allocator (GPU_0_bfc) ran out of memory trying to allocate 1.56GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available. 2019-10-10 08:27:19.123356: W tensorflow/core/common_runtime/bfc_allocator.cc:215] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.06GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available. Traceback (most recent call last):File "D:/Yolov3_Tensorflow/tensorflow-yolov3/video_demo.py", line 141, in <module>image = utils.draw_bbox(frame, bboxes)File "D:\Yolov3_Tensorflow\tensorflow-yolov3\core\utils.py", line 83, in draw_bboxbbox_color = colors[class_ind] IndexError: list index out of rangeProcess finished with exit code 1詳細(xì)描述:
程序運(yùn)行成功會(huì)打開識(shí)別或者視頻流進(jìn)行識(shí)別并畫出識(shí)別框,在畫面靜止的狀態(tài)下,運(yùn)行貌似穩(wěn)定并能準(zhǔn)確顯示識(shí)別框,當(dāng)畫面有較大幅度動(dòng)作時(shí),會(huì)立即出現(xiàn)上述報(bào)錯(cuò)。
尋找錯(cuò)誤原因:
1、在檢查的過程中偶然看見程序說 ./data/classes/voc.names 文件不存在,當(dāng)時(shí)沒在意。因?yàn)椴榭次募A,voc.names 文件確實(shí)存在。
2、后來查看 video_demo.py 文件,看到兩個(gè)參數(shù),突然想起什么,input_size = 416 可能是識(shí)別時(shí)識(shí)別框預(yù)設(shè)大小,而num_classes = 80 依稀記得是識(shí)別分類的數(shù)量。
于是打開 voc.names 查看,發(fā)現(xiàn)里面只有20個(gè)類,而打開 coco.names ,發(fā)現(xiàn)有80個(gè)類,這應(yīng)該多少有點(diǎn)問題:
3、于是打開 config.py 文件,將 __C.YOLO.CLASSES 參數(shù)由 "./data/classes/voc.names" 改成了 "./data/classes/coco.names"。
4、運(yùn)行程序,沒有再出現(xiàn)程序報(bào)錯(cuò),識(shí)別也良好!
總結(jié):
識(shí)別使用的權(quán)重文件一定要與我們識(shí)別類的 .names 文件相對(duì)應(yīng)(猜測(cè)權(quán)重文件中記錄的只是類序號(hào),它轉(zhuǎn)換成文字表示需要 .names 文件支持),同時(shí)我們?cè)?video_demo.py 中填寫的 num_classes 參數(shù)也要與 .names 文件中的類數(shù)量一致。
(我本次使用的權(quán)重文件為 yolov3_coco_demo.ckpt )
總結(jié)
以上是生活随笔為你收集整理的YunYang1994/tensorflow-yolov3 IndexError: list index out of range 解决办法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Opencv 深度学习中为什么普遍使用B
- 下一篇: YunYang1994/tensorfl