caffe-ocr icon indicating copy to clipboard operation
caffe-ocr copied to clipboard

Howto use to recognize images with texts?

Open jmokoistinen opened this issue 8 years ago • 2 comments

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?

jmokoistinen avatar Feb 16 '16 14:02 jmokoistinen

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.

twmht avatar Jul 13 '16 08:07 twmht

@twmht where you put the script you wrote?

shendaizi avatar Nov 06 '16 05:11 shendaizi