Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在tensornet中使用yolov3?_Python_Tensorflow_Machine Learning_Deep Learning_Yolo - Fatal编程技术网

Python 如何在tensornet中使用yolov3?

Python 如何在tensornet中使用yolov3?,python,tensorflow,machine-learning,deep-learning,yolo,Python,Tensorflow,Machine Learning,Deep Learning,Yolo,请帮助我解决以下问题,我计划在高层使用yolov3来检测我图像中的物体(车辆、行人)。我偶然发现了tensornets图书馆。因为它直接用于几行代码,所以我想试一试,但由于代码抛出类型错误,所以无法生成输出 行: 我得到的错误是: 我们将非常感谢您为解决此问题提供的任何帮助 下面是我的全部代码 import tensorflow as tf import tensornets as nets import cv2 import numpy as np import time inputs =

请帮助我解决以下问题,我计划在高层使用yolov3来检测我图像中的物体(车辆、行人)。我偶然发现了tensornets图书馆。因为它直接用于几行代码,所以我想试一试,但由于代码抛出类型错误,所以无法生成输出 行:

我得到的错误是:

我们将非常感谢您为解决此问题提供的任何帮助

下面是我的全部代码

import tensorflow as tf
import tensornets as nets
import cv2
import numpy as np
import time

inputs = tf.placeholder(tf.float32, [None, 416, 416, 3]) 
model = nets.YOLOv3COCO(inputs, nets.Darknet19)

classes={'0':'person','1':'bicycle','2':'car','3':'bike','5':'bus','7':'truck'}
list_of_classes=[0,1,2,3,5,7]#to display other detected #objects,change the classes and list of classes to their respective #COCO indices available in their website. Here 0th index is for #people and 1 for bicycle and so on. If you want to detect all the #classes, add the indices to this list

sess = tf.Session()
sess.run(model.pretrained())
#"D://pyworks//yolo//videoplayback.mp4"   
frame = cv2.imread("img.jpg")
img=cv2.resize(frame,(416,416))
imge=np.array(img).reshape(-1,416,416,3)
start_time=time.time()
preds = sess.run(model.preds, {inputs: model.preprocess(imge)})
print("--- %s seconds ---" % (time.time() - start_time)) 
boxes = model.get_boxes(preds, imge.shape[1:3])
cv2.namedWindow('image',cv2.WINDOW_NORMAL)

cv2.resizeWindow('image', 700,700)
#print("--- %s seconds ---" % (time.time() - start_time)) 
boxes1=np.array(boxes)
for j in list_of_classes:
    count =0
    if str(j) in classes:
        lab=classes[str(j)]
    if len(boxes1) !=0:


        for i in range(len(boxes1[j])):
            box=boxes1[j][i] 

            if boxes1[j][i][4]>=.40:


                count += 1    

                cv2.rectangle(img,(box[0],box[1]),(box[2],box[3]),(0,255,0),1)
                cv2.putText(img, lab, (box[0],box[1]), cv2.FONT_HERSHEY_SIMPLEX, .5, (0, 0, 255), lineType=cv2.LINE_AA)
    print(lab,": ",count)


cv2.imshow("image",img)  

我试图在Windows10上的python虚拟环境中运行这段代码,下面是这些版本的库

absl-py (0.10.0)
argon2-cffi (20.1.0)
astor (0.8.1)
async-generator (1.10)
attrs (20.2.0)
backcall (0.2.0)
bleach (3.1.5)
cffi (1.14.2)
colorama (0.4.3)
Cython (0.29.21)
decorator (4.4.2)
defusedxml (0.6.0)
entrypoints (0.3)
gast (0.4.0)
google-pasta (0.2.0)
grpcio (1.32.0)
h5py (2.10.0)
importlib-metadata (1.7.0)
ipykernel (5.3.4)
ipython (7.16.1)
ipython-genutils (0.2.0)
jedi (0.17.2)
Jinja2 (2.11.2)
jsonschema (3.2.0)
jupyter-client (6.1.7)
jupyter-core (4.6.3)
jupyterlab-pygments (0.1.1)
Keras-Applications (1.0.8)
Keras-Preprocessing (1.1.2)
Markdown (3.2.2)
MarkupSafe (1.1.1)
mistune (0.8.4)
nbclient (0.5.0)
nbconvert (6.0.1)
nbformat (5.0.7)
nest-asyncio (1.4.0)
notebook (6.1.4)
numpy (1.19.2)
opencv-python (4.4.0.42)
packaging (20.4)
pandocfilters (1.4.2)
parso (0.7.1)
pickleshare (0.7.5)
pip (9.0.3)
prometheus-client (0.8.0)
prompt-toolkit (3.0.7)
protobuf (3.13.0)
pycparser (2.20)
Pygments (2.6.1)
pyparsing (2.4.7)
pyrsistent (0.17.2)
python-dateutil (2.8.1)
pywin32 (228)
pywinpty (0.5.7)
pyzmq (19.0.2)
Send2Trash (1.5.0)
setuptools (39.0.1)
six (1.15.0)
tensorboard (1.14.0)
tensorflow (1.14.0)
tensorflow-estimator (1.14.0)
termcolor (1.1.0)
terminado (0.8.3)
testpath (0.4.4)
tornado (6.0.4)
traitlets (4.3.3)
wcwidth (0.2.5)
webencodings (0.5.1)
Werkzeug (1.0.1)
wheel (0.35.1)
wrapt (1.12.1)
zipp (3.1.0)

absl-py (0.10.0)
argon2-cffi (20.1.0)
astor (0.8.1)
async-generator (1.10)
attrs (20.2.0)
backcall (0.2.0)
bleach (3.1.5)
cffi (1.14.2)
colorama (0.4.3)
Cython (0.29.21)
decorator (4.4.2)
defusedxml (0.6.0)
entrypoints (0.3)
gast (0.4.0)
google-pasta (0.2.0)
grpcio (1.32.0)
h5py (2.10.0)
importlib-metadata (1.7.0)
ipykernel (5.3.4)
ipython (7.16.1)
ipython-genutils (0.2.0)
jedi (0.17.2)
Jinja2 (2.11.2)
jsonschema (3.2.0)
jupyter-client (6.1.7)
jupyter-core (4.6.3)
jupyterlab-pygments (0.1.1)
Keras-Applications (1.0.8)
Keras-Preprocessing (1.1.2)
Markdown (3.2.2)
MarkupSafe (1.1.1)
mistune (0.8.4)
nbclient (0.5.0)
nbconvert (6.0.1)
nbformat (5.0.7)
nest-asyncio (1.4.0)
notebook (6.1.4)
numpy (1.19.2)
opencv-python (4.4.0.42)
packaging (20.4)
pandocfilters (1.4.2)
parso (0.7.1)
pickleshare (0.7.5)
pip (9.0.3)
prometheus-client (0.8.0)
prompt-toolkit (3.0.7)
protobuf (3.13.0)
pycparser (2.20)
Pygments (2.6.1)
pyparsing (2.4.7)
pyrsistent (0.17.2)
python-dateutil (2.8.1)
pywin32 (228)
pywinpty (0.5.7)
pyzmq (19.0.2)
Send2Trash (1.5.0)
setuptools (39.0.1)
six (1.15.0)
tensorboard (1.14.0)
tensorflow (1.14.0)
tensorflow-estimator (1.14.0)
termcolor (1.1.0)
terminado (0.8.3)
testpath (0.4.4)
tornado (6.0.4)
traitlets (4.3.3)
wcwidth (0.2.5)
webencodings (0.5.1)
Werkzeug (1.0.1)
wheel (0.35.1)
wrapt (1.12.1)
zipp (3.1.0)