我想识别视频上的图像,为此我安装了所有软件包,如在本网站https://imageai.readthedocs.io/en/latest/上,然后下载所有必要的文件,如下所示https:// imageai.readthedocs.io /en/latest/video/index.html,将此代码粘贴到我自己并尝试运行
from imageai.Detection import VideoObjectDetection
import os
import cv2
execution_path = os.getcwd()
camera = cv2.VideoCapture(0)
detector= VideoObjectDetection()
.setModelTypeAsYOLOv3()
.setModelPath(os.path.join( execution_path , "yolo.h5"))
detector.loadModel()
video_path = detector.detectObjectsFromVideo( camera_input= camera,
output_file_path= os.path.join( execution_path, "camera_detected_video")
, frames_per_second= 20, log_progress= True, minimum_percentage_probability= 30)
print( video_path)
当我尝试运行它时,它给出了这个:
Using TensorFlow backend.
2020-05-01 18:33:20.415776: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-05-01 18:33:20.415940: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
File "S:/Media/Programming/Python/untitled/test1.py", line 25, in <module>
detector = VideoObjectDetection()
File "C:\Users\uneen\AppData\Local\Programs\Python\Python38\lib\site-packages\imageai\Detection\__init__.py", line 984, in __init__
self.sess = K.get_session()
File "C:\Users\uneen\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\backend\tensorflow_backend.py", line 378, in get_session
raise RuntimeError(
RuntimeError: `get_session` is not available when using TensorFlow 2.0.
据我了解,他不喜欢我有第二个版本的 tensorflow,因为他检查了这个有库存detector= VideoObjectDetection()
所以问题出现了:如何让它工作?谢谢大家!
问题原来是我是个傻瓜,开发者在riddit页面上写的ImageAI库目前不支持TF2(3.05.2020)。