Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load wpod model #145

Open
bhargavravat opened this issue Oct 12, 2020 · 2 comments
Open

Unable to load wpod model #145

bhargavravat opened this issue Oct 12, 2020 · 2 comments

Comments

@bhargavravat
Copy link

bhargavravat commented Oct 12, 2020

ValueError: Tensor Tensor("concatenate_1/concat:0", shape=(?, ?, ?, 8), dtype=float32) is not an element of this graph.

I am trying to receive an image from using socket io and then trying to apply it to wpod net for number plate detection. But I am getting above mentioned error.

Here is the code snippet
output_dir = 'lp_images/' lp_threshold = .5 wpod_net_path = 'data/lp-detector/wpod-net_update1.h5' wpod_net = load_model(wpod_net_path) ocr_threshold = .4 ocr_weights = 'data/ocr/ocr-net.weights' ocr_netcfg = 'data/ocr/ocr-net.cfg' ocr_dataset = 'data/ocr/ocr-net.data' ocr_net = dn.load_net(ocr_netcfg.encode(), ocr_weights.encode(), 0) ocr_meta = dn.load_meta(ocr_dataset.encode())
`
def anpr_detection(img_np, Rwidth , Rheight, sId , ske):
print ("In Side anpr_detection ======>")
frame = img_np
w = frame.shape[0]
h = frame.shape[1]
ratio = float(max(frame.shape[:2]))/min(frame.shape[:2])
side = int(ratio*288.)
bound_dim = min(side + (side%(24)),608)
print ("bound_dim ==>",bound_dim)
print (type(frame))
#wpod_net = load_model(wpod_net_path)
Llp,LlpImgs,_ = detect_lp(wpod_net,im2single(frame),bound_dim,2
4,(240,80),lp_threshold)
if len(LlpImgs) > 0:
print ("LlpImgs ========> ")
Ilp = LlpImgs[0]
s = Shape(Llp[0].pts)
for shape in [s]:
ptsarray = shape.pts.flatten()
try:
frame = cv2.rectangle(frame,(int(ptsarray[0]*h), int(ptsarray[5]*w)),(int(ptsarray[1]*h),int(ptsarray[6]*w)),(0,255,0),3)
X1 = int(ptsarray[0]*h)
Y1 = int(ptsarray[5]*w)
X2 = int(ptsarray[1]*h)
Y2 = int(ptsarray[6]w)
Pwidth = X2 - X1
Pheight = Y2 - Y1
except:
traceback.print_exc()
sys.exit(1)
cv2.imwrite('%s/_lp.png' % (output_dir),Ilp
255.)
R,(width,height) = detect(ocr_net, ocr_meta, 'lp_images/_lp.png'.encode() ,thresh=ocr_threshold, nms=None)

    if len(R):
        L = dknet_label_conversion(R,width,height)
        L = nms(L,.45)
        L.sort(key=lambda x: x.tl()[0])
        lp_str = ''.join([chr(l.cl()) for l in L])
        print("License Plate Detected: ", lp_str)`
@bhargavravat bhargavravat changed the title ValueError: Tensor Tensor("concatenate_1/concat:0", shape=(?, ?, ?, 8), dtype=float32) is not an element of this graph. Unable to load wpod model Oct 12, 2020
@Harsha-1729
Copy link

Harsha-1729 commented Nov 6, 2020

Check if this helps you
We need wpod-net.json file as well to load the model. I don't see any .json file being read in your code.
I am able to load the wpod model successfully

image

@TDiblik
Copy link

TDiblik commented Jul 31, 2022

Hi, I've encountered the same error. I was able to resolve it by simply re-downloading the models

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants