Yolo 9000:OSError: libdarknet.so: cannot open shared object file: No such file or directory

最近需要使用yolo 9000的预训练模型,我用的是python接口,我这里分享一下我使用预训练模型的经验。我用的模型的官网地址为https://github.com/philipperemy/yolo-9000

我用的是其自带的detector.py,在yolo-9000/darknet/examples目录中,需要把它放在yolo-9000/darknet目录下,我修改的detector.py的代码为:

# Stupid python path shit.
# Instead just add darknet.py to somewhere in your python path
# OK actually that might not be a great idea, idk, work in progress
# Use at your own risk. or don't, i don't care

import sys, os
sys.path.append(os.path.join(os.getcwd(),'python/'))

import darknet as dn

net = dn.load_net("cfg/yolo9000.cfg", "../yolo9000-weights/yolo9000.weights", 0)
meta = dn.load_meta("cfg/combine9k.data")
# r = dn.detect(net, meta, "data/dog.jpg")
# print r
# print(r[0][0])

image_files = os.listdir(image_path)
with open("image_objects.txt","w") as file:
    num=0
    for image_file in image_files:
        file_path=os.path.join(image_base_path,image_file)
        predict = dn.detect(net, meta,file_path)
        file.write(image_file)
        for predict_object in predict:
# print r
# print(r[0][0])

image_files = os.listdir(image_path)
with open("image_objects.txt","w") as file:
    num=0
    for image_file in image_files:
        file_path=os.path.join(image_base_path,image_file)
        predict = dn.detect(net, meta,file_path)
        file.write(image_file)
        for predict_object in predict:
            file.write(" "+predict_object[0])
        file.write("\n")
        num+=1
        if(num%100==0):
            print(num)

但是在运行detector.py的时候出现了如下的错误:

OSError: libdarknet.so: cannot open shared object file: No such file or directory
我使用的是gpu版本,最后发现只要在命令行输入:

export PATH=/usr/local/cuda-8.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH

就行了。如果要使用gpu版本进行预测,参照官网的教程就行了

参考文献

[1].Yolo 9000.https://github.com/philipperemy/yolo-9000

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

农民小飞侠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值