pannous / caffe-ocr

OCR with caffe deep learning framework -> Migrated to tensorflow
https://github.com/pannous/tensorflow-ocr
215 stars 115 forks source link

Howto use to recognize images with texts? #3

Open jmokoistinen opened 8 years ago

jmokoistinen commented 8 years ago

Used this data for training. I got alpha_iter_1300.caffemodel and alpha_iter_1300.solverstate. (etc 1200, 1100, ... 100) How can I use it to recognize images with text?

twmht commented 7 years ago

I just write a python interface to do that.

import caffe
import numpy as np

img = caffe.io.load_image( "AndaleMono-6-4.png" )
img = img[:,:,::-1]*255.0 # convert RGB->BGR
img = img.transpose((2,0,1))
img = img[None,:] # add singleton dimension
net = caffe.Net("alpha_deploy.prototxt","alpha_iter_1300.caffemodel",  caffe.TEST)
out = net.forward_all( data = img )
prob = net.blobs['prob'].data[0]
index = np.argmax(prob)

where AndaleMono-6-4.png comes from one of the image in training images.

but it shows


F0713 16:57:02.346405 23560 net.cpp:765] Cannot copy param 0 weights from layer 'ip2'; shape mismatch.  Source param shape is 62 500 (31000); target param shape is 36 500 (18000). To learn this layer's parameters from scratch rather than copying from a saved net, rename the layer.

I am trying to figure out what the problem is.

shendaizi commented 7 years ago

@twmht where you put the script you wrote?