Created
February 28, 2019 12:32
-
-
Save DibyaranjanSathua/d45b5c4955e79ea6a8cb7b04c028a66d to your computer and use it in GitHub Desktop.
Test opencv dnn module with tensorflow pre-trained model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
def test_dnn_module(): | |
""" Function to test OpenCV DNN module. """ | |
model = 'removed_dropout_graph.pb' | |
net = cv2.dnn.readNet(model) | |
img = cv2.imread('F1_R0_A.png') | |
imgGray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) | |
imgGray = imgGray.astype(np.uint8) | |
blob = cv2.dnn.blobFromImage(imgGray, 1.0, (28,28), swapRB=True, crop=False) | |
net.setInput(blob) | |
output = net.forward() | |
print(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment