parent
55b05c2836
commit
b10e13caea
@ -1,27 +0,0 @@
|
||||
import cv2
|
||||
import torchvision.transforms as transforms
|
||||
import numpy as np
|
||||
net = cv2.dnn.readNetFromONNX("ministNet.onnx") # 加载训练好的识别模型
|
||||
img = cv2.imread('./data/8.png')
|
||||
img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
|
||||
img = img/255
|
||||
|
||||
transf = transforms.ToTensor()
|
||||
imgTensor = transf(img).unsqueeze(0)
|
||||
|
||||
|
||||
|
||||
im = img[np.newaxis, np.newaxis,:, :]
|
||||
im = im.astype(np.float32)
|
||||
outNames = net.getUnconnectedOutLayersNames()
|
||||
net.setInput(im)
|
||||
out = net.forward(outNames)
|
||||
|
||||
|
||||
ind = np.where(out[0][0]==np.max(out[0][0]))
|
||||
print(ind[0])
|
||||
|
||||
|
||||
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue