Я запускаю этот код
import cv2
import cvlib
from cvlib.object_detection import draw_bbox
video = cv2.VideoCapture('./videos/highway-civil.mp4')
fps = video.get(cv2.CAP_PROP_FPS)
frame_width = int(video.get(cv2.CAP_PROP_FRAME_WIDTH))
frame_height = int(video.get(cv2.CAP_PROP_FRAME_HEIGHT))
fourcc = cv2.VideoWriter_fourcc(*'MP4V')
output_video = cv2.VideoWriter(
'output.mp4', fourcc, fps, (frame_width, frame_height))
print('Writting...')
while True:
ret, frame = video.read()
if not ret:
break
bounding_box, label, conf = cvlib.detect_common_objects(
frame, model='yolov3', enable_gpu=True)
frame = draw_bbox(frame, bounding_box, label, conf, write_conf=True)
output_video.write(frame)
print('Done.')
Он запускает это в терминале в течение 6:39 минут
[ WARN:0] global C:\projects\opencv-python\opencv\modules\dnn\src\dnn.cpp (1363) cv::dnn::dnn4_v20191202::Net::Impl::setUpNet DNN module was not built with CUDA backend; switching to CPU
[ WARN:0] global C:\projects\opencv-python\opencv\modules\dnn\src\dnn.cpp (1363) cv::dnn::dnn4_v20191202::Net::Impl::setUpNet DNN module was not built with CUDA backend; switching to CPU
[ WARN:0] global C:\projects\opencv-python\opencv\modules\dnn\src\dnn.cpp (1363) cv::dnn::dnn4_v20191202::Net::Impl::setUpNet DNN module was not built with CUDA backend; switching to CPU
Done.
После завершения , Выходное видео не претерпело никаких изменений (распознавание объекта) , но у меня есть tensorflow-gpu 2.2.0 и CUDA 10.1, я следую этому руководству
[https://towardsdatascience.com/installing-tensorflow-with-cuda-cudnn-and-gpu-support-on-windows-10-60693e46e781 ] [1]
(base) C:\>python
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2020-05-27 14:49:48.931524: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
>>> tf.test.is_built_with_cuda()
True
>>> tf.config.list_physical_devices('GPU')
2020-05-27 14:50:19.447121: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2020-05-27 14:50:20.333866: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1050 computeCapability: 6.1
coreClock: 1.493GHz coreCount: 5 deviceMemorySize: 4.00GiB deviceMemoryBandwidth: 104.43GiB/s
2020-05-27 14:50:20.338557: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2020-05-27 14:50:20.418933: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2020-05-27 14:50:20.466605: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2020-05-27 14:50:20.493854: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2020-05-27 14:50:20.588843: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2020-05-27 14:50:20.633034: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2020-05-27 14:50:20.781559: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2020-05-27 14:50:20.895433: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
>>> from keras.models import Sequential
Using TensorFlow backend.
>>> tf.test.is_gpu_available(cuda_only=False, min_cuda_compute_capability=None)
WARNING:tensorflow:From <stdin>:1: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.config.list_physical_devices('GPU')` instead.
2020-05-27 14:51:36.915066: I tensorflow/core/platform/cpu_feature_guard.cc:143] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2020-05-27 14:51:36.927729: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x1c6cfdbc2f0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-05-27 14:51:36.934287: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
2020-05-27 14:51:37.617288: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1050 computeCapability: 6.1
coreClock: 1.493GHz coreCount: 5 deviceMemorySize: 4.00GiB deviceMemoryBandwidth: 104.43GiB/s
2020-05-27 14:51:37.623086: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2020-05-27 14:51:37.625621: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2020-05-27 14:51:37.629018: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2020-05-27 14:51:37.633469: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2020-05-27 14:51:37.637434: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2020-05-27 14:51:37.642499: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2020-05-27 14:51:37.645661: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2020-05-27 14:51:37.650577: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0
2020-05-27 14:51:38.406155: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-05-27 14:51:38.409649: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1108] 0
2020-05-27 14:51:38.411524: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1121] 0: N
2020-05-27 14:51:38.414265: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1247] Created TensorFlow device (/device:GPU:0 with 2993 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1050, pci bus id: 0000:01:00.0, compute capability: 6.1)
2020-05-27 14:51:38.425346: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x1c6f27c7bf0 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2020-05-27 14:51:38.429201: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): GeForce GTX 1050, Compute Capability 6.1
True
>>> import dlib
>>> import face_recognition
>>> import cmake
>>>
Как я могу решить эту проблему?