Issue
currently i am learning deep learning
last week i try to run my program and its work fine but now nothing show up when the log are same
it doesnt show up after i reinstall my nvidia driver
i already install cuda and cuddn for tensorflow just like what at tensorflow documentation said
here are the code that i have
# import miscellaneous modules
import matplotlib.pyplot as plt
import cv2
import os
import numpy as np
import time
import pandas as pd
import tensorflow.keras.backend as K
# import keras_retinanet
from tensorflow.keras import models
import sys
model_path = 'Model/CCTV_10Frame_SGD_Model_1e4_b16_l21e2_224_Terbaru.h5'
model = models.load_model(model_path)
vid = cv2.VideoCapture("Data Fix/Data16_116.mp4")
while(vid.isOpened()):
ret, frame = vid.read()
vid.set(3, 480)
vid.set(4, 240)
start = time.time()
if ret == True:
draw = frame.copy()
draw = cv2.cvtColor(draw, cv2.COLOR_BGR2RGB)
scale_percent = 20 # percent of original size
width = 224
height = width
dim = (width, height)
frame_set = cv2.resize(draw, dim, interpolation = cv2.INTER_AREA)
frame_set=np.arange(10*width*height*3).reshape(10,width, height, 3)
frame_set.reshape(10, width, height, 3).shape
frame_set = np.expand_dims(frame_set, axis=0)
result=model.predict_on_batch(frame_set)
# Get the predicted class from the result using argmax
pred_class = np.argmax(result)
# Here I assume that the index is the desired class like most cases
# Now we will write the class label on the image
# Set the font and place
font = cv2.FONT_HERSHEY_SIMPLEX
org = (50, 50)
cv2.putText(draw, str(pred_class), org, font, .5, (255,255,255),2,cv2.LINE_AA)
# now just show the frame
cv2.imshow('frame', draw)
print(result)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
vid.release()
cv2.destroyAllWindows()
the log are like this
2021-08-30 23:18:53.846817: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudart64_110.dll
2021-08-30 23:19:24.046369: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library nvcuda.dll2021-08-30 23:19:24.671644: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1733] Found device 0 with properties:
pciBusID: 0000:03:00.0 name: NVIDIA GeForce 920MX computeCapability: 5.0
coreClock: 0.993GHz coreCount: 2 deviceMemorySize: 2.00GiB deviceMemoryBandwidth: 13.41GiB/s
2021-08-30 23:19:24.672060: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudart64_110.dll
2021-08-30 23:19:24.687853: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cublas64_11.dll
2021-08-30 23:19:24.688315: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cublasLt64_11.dll
2021-08-30 23:19:24.709928: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cufft64_10.dll
2021-08-30 23:19:24.714666: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library curand64_10.dll
2021-08-30 23:19:24.720694: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cusolver64_11.dll
2021-08-30 23:19:24.728896: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cusparse64_11.dll
2021-08-30 23:19:24.730655: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudnn64_8.dll
2021-08-30 23:19:24.731295: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1871] Adding visible gpu devices: 0
2021-08-30 23:19:24.732060: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-08-30 23:19:24.733284: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1733] Found device 0 with properties:
pciBusID: 0000:03:00.0 name: NVIDIA GeForce 920MX computeCapability: 5.0
coreClock: 0.993GHz coreCount: 2 deviceMemorySize: 2.00GiB deviceMemoryBandwidth: 13.41GiB/s
2021-08-30 23:19:24.734279: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1871] Adding visible gpu devices: 0
2021-08-30 23:19:25.486129: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1258] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-08-30 23:19:25.486614: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1264] 0
2021-08-30 23:19:25.486863: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1277] 0: N
2021-08-30 23:19:25.487580: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1418] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1363 MB memory) -> physical GPU (device: 0, name: NVIDIA GeForce 920MX, pci bus id: 0000:03:00.0, compute capability: 5.0)
nothing error show up but the cv2.imshow didnt work, i try to add some print before the cv2.imshow too for testing but no result for print too
any answer would be helpfull
thank you so much
Solution
Move your video file into your project folder, change
vid = cv2.VideoCapture("Data Fix/Data16_116.mp4")
as
vid = cv2.VideoCapture("Data16_116.mp4")
You can try adding this code if your video is opened or not, add this under vid = cv2…. line
if (vid.isOpened()== False):
print("error")
Answered By – acemi
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0