我曾尝试将我的视频卡用于物体识别的训练和图像处理,但没有成功。我已经将Pycharm用作IDE,并为我的系统环境进行了所有必要的设置。 我运行的是Windows 10。我为该版本安装了Cuda Tookit 9.0和cuDNN。我还使用conda安装了tensorflow gpu 1.13.1。 在我的项目中,我安装了tensorflow 1.13.1和tensorflow gpu 1.13.1。我尝试在不使用tensorflow的情况下运行该算法,仅使用tensorflow gpu,但执行时出现错误。 我的视频卡和GT 625M。 我正在显示我的环境配置和我使用的主要代码的图像。我希望有一个解决我的问题的解决方案,因为我花了5天多的时间进行了一次培训,使用了不到200张图片,我确信使用GPU不会花费超过几个小时的时间
1-树代码
from darkflow.net.build import TFNet
#opções do treino
options = {"model": "cfg/yolo-new.cfg",
"load": "bin/yolo.weights",
"batch": 1,
"epoch": 100,
"gpu": 1.0,
"train": True,
"annotation": "DataSet-Part/_DataSetNovo_Annotation/",
"dataset": "DataSet-Part/_DataSetNovo_Image/"}
#configurando a rede com as opções
tfnet = TFNet(options)
#treino
tfnet.train()
2-图像识别代码
#importar biblioteca numpy
import numpy as np
#importa biblioteca da rede
from darkflow.net.build import TFNet
#importar opencv
import cv2
#função para criar o retangulo
def boxing(original_img , predictions):
newImage = np.copy(original_img)
#cria um box pra cada objeto detectado
for result in predictions:
top_x = result['topleft']['x']
top_y = result['topleft']['y']
btm_x = result['bottomright']['x']
btm_y = result['bottomright']['y']
confidence = result['confidence']
label = result['label'] + " " + str(round(confidence, 3))
#se for maior que 30% mostra
if confidence > 0.3:
#desenha o retangulo
newImage = cv2.rectangle(newImage, (top_x, top_y), (btm_x, btm_y), (255,0,0), 6)
#escreve o texto
newImage = cv2.putText(newImage, label, (top_x, top_y-5), cv2.FONT_HERSHEY_SIMPLEX , 1, (28, 28, 28), 2, cv2.LINE_AA)
cv2.imwrite("C:/Users/davin/source/repos/Yolo 3/darkflow-master/Novas Imagens/"+"novaImage.jpg", newImage)
return newImage
#opções para carregar o modelo
options = {"model": "cfg/yolo-new.cfg",
"load": -1,
"gpu": 1.0}
#configura a rede com as opções
tfnet2 = TFNet(options)
#carrega a rede
tfnet2.load_from_ckpt()
#Le a imagem
original_img = cv2.imread("sample_img/8.jpg")
#Reconhece objetos na imagem
results = tfnet2.return_predict(original_img)
if results:
print("\nResults---------------------------------------------------")
#Para cada objeto reconhecido printa o nome e com qual confiança
for y in range(0, len(results)):
print("Label:%s\tConfidence:%f"%(results[y]['label'], results[y]['confidence']))
#mostra imagem
cv2.imshow('image',boxing(original_img, results))
cv2.waitKey(0)
cv2.destroyAllWindows()
3-网络摄像头识别代码
#importar biblioteca numpy
import numpy as np
#importa biblioteca da rede
from darkflow.net.build import TFNet
#importar opencv
import cv2
#função para criar o retangulo
def boxing(original_img , predictions):
newImage = np.copy(original_img)
#cria um box pra cada objeto detectado
for result in predictions:
top_x = result['topleft']['x']
top_y = result['topleft']['y']
btm_x = result['bottomright']['x']
btm_y = result['bottomright']['y']
confidence = result['confidence']
label = result['label'] + " " + str(round(confidence, 3))
#se for maior que 30% mostra
if confidence > 0.3:
#desenha o retangulo
newImage = cv2.rectangle(newImage, (top_x, top_y), (btm_x, btm_y), (255,0,0), 6)
#escreve o texto
newImage = cv2.putText(newImage, label, (top_x, top_y-5), cv2.FONT_HERSHEY_COMPLEX_SMALL , 3, (0, 230, 0), 1, cv2.LINE_AA)
return newImage
#opções para carregar o modelo
options = {"model": "cfg/yolo-new.cfg",
"load": -1,
"gpu": 1.0}
#configura a rede com as opções
tfnet2 = TFNet(options)
#carrega a rede
tfnet2.load_from_ckpt()
#Captura video
cam = cv2.VideoCapture(0)
#Cria janela chamada YOLO
cv2.namedWindow("Yolo")
while True:
#Lê frame
ret, frame = cam.read()
#Reconhece objetos no frame
results = tfnet2.return_predict(frame)
if results:
print("\nResults---------------------------------------------------")
for y in range(0, len(results)):
#Para cada objeto reconhecido printa o nome e com qual confiança
print("Label:%s\tConfidence:%f"%(results[y]['label'], results[y]['confidence']))
#mostra imagem
cv2.imshow('YoloV3',boxing(frame, results))
#Se não encontra frame
if not ret:
break
k = cv2.waitKey(1)
#Se Clicar no Esc fecha
if k%256 == 27:
print("Escape hit, closing...")
break
#Libera os recursos de software e hardware da câmera
cam.release()
#Destroi a janela
cv2.destroyAllWindows()
我的盘子
5-Cuda
6-cuDNN
7-Pycharm
进程正常进行,但我的GPU仍然未使用
目前没有回答
相关问题 更多 >
编程相关推荐