see icon indicating copy to clipboard operation
see copied to clipboard

text_recognition_demo.py with GPU

Open ran337287 opened this issue 7 years ago • 10 comments

When I run text_recognition_demo.py with parameters gpu=-1(that is cpu), it can return the results. But if I set gpu=0, there is something wrong. The error is ValueError:numpy and cupy must not be used together type(W):<class 'numpy.ndarray'>, type(x):<class 'cupy.core.core.ndarray'>,type(b):<class 'numpy.ndarray'> I know nothing about Chainer, what should I do to solve it?

ran337287 avatar Apr 10 '18 03:04 ran337287

That's a very good question. I can not reproduce this error on my machine. The error tells you that your model (i.e. the parameters) has not been copied to the GPU, but your data is. The model should be copied to the GPU automatically, if you set the command line argument --gpu to 0 Did you change anything in text_recognition_demo.py?

Bartzi avatar Apr 10 '18 08:04 Bartzi

Thank U for your reply. @Bartzi I didn't change anything in text_recognition_demo.py. The only thing I changed is gpu=-1 or gpu=0. I installed pipenv, and ran the code in virtual environment. The version of requirements is satisfied.

ran337287 avatar Apr 11 '18 00:04 ran337287

Could you provide the exact command you used to invoke the script and also the exact error you get? As I said, I can not reproduce the error here...

Bartzi avatar Apr 11 '18 08:04 Bartzi

I download the text_recognition_model.zip from https://bartzi.de/research/see, and unzip it to folder 'see'. When I execute python ~/see/chainer/text_recognition_demo.py ~/see/text_recognition_model/model \ ~/see/text_recognition_model/model/model_190000.npz ~/see/demo/19.png \ ~/see/datasets/textrec/ctc_char_map.json --gpu=-1 It returns image

I download the text_recognition_model.zip from https://bartzi.de/research/see, and unzip it to folder 'see When I execute python ~/see/chainer/text_recognition_demo.py ~/see/text_recognition_model/model \ ~/see/text_recognition_model/model/model_190000.npz ~/see/demo/19.png \ ~/see/datasets/textrec/ctc_char_map.json --gpu=0 it returns image

ran337287 avatar Apr 11 '18 10:04 ran337287

I'm not sure, whether this will fix it, but I your command-line should look like this:

python ~/see/chainer/text_recognition_demo.py ~/see/text_recognition_model/model  \
 model_190000.npz ~/see/demo/19.png \ 
~/see/datasets/textrec/ctc_char_map.json --gpu=0

Bartzi avatar Apr 11 '18 10:04 Bartzi

HI @Bartzi

I am facing a similar issue as well, the output i get always returns an ordered Dictionary.

Am i missing any steps here?

Regards Sekar

chansekar avatar Apr 13 '18 08:04 chansekar

An ordered dictionary is the expected output =)

The keys of this dictionary are the predicted words and the values are ordered dictionaries with the bboxes predicted for this word.

Bartzi avatar Apr 13 '18 09:04 Bartzi

HI Bartzi,

My understanding was the same, however for the same file i ran i got the below output.

prediction [26 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] word1 [26 15] word2 pe select-003

python text_recognition_demo.py ~/TextOcr/SEE/text_recognition_model/model \model_190000.npz ~/Pictures/select_003.png ~/TextOcr/SEE/see-master/datasets/textrec/ctc_char_map.json

Which does not match the image. Can you let me know where am i going wrong?

Regards Sekar

chansekar avatar Apr 16 '18 06:04 chansekar

You are using an image, where the network does not know how to handle it. It has only been trained on images with one line of cropped-text, and not two. You can not use this model for such predictions. That is the problem you are facing here.

Bartzi avatar Apr 16 '18 08:04 Bartzi

Thanks Bartzi,

That really helped, appreciate your timely help.

chansekar avatar Apr 16 '18 12:04 chansekar