Belval / CRNN

A TensorFlow implementation of https://github.com/bgshih/crnn
MIT License
297 stars 101 forks source link

resize function bug #32

Closed sevenHsu closed 5 years ago

sevenHsu commented 5 years ago

Question describe

Belval commented 5 years ago

Just to clarify, you believe that the resulting array should be (32, 100) or (32, 133)?

Using a slice like in the code pictured should produce a (32, 100) array as expected and desired.

xxlxx1 commented 5 years ago

@sevenHsu 我看这里的代码也有这个疑惑,test的时候这里就报错了。我改成如果长度太长,只取前面100列,感觉这样还是有问题的,不能识别后面的文字了。 还有一个问题,我把放入session run之前的batchx图片保存下来,它是被reshape了的,宽和高纬度交换的时候,所以保存出来的看不出字的形状,感觉很奇怪啊

xxlxx1 commented 5 years ago

@Belval I can't understand your answer, when i try a picture in (22,92), will be (32,133) in your code , then will error in next code. another question, when you prepare training data, from raw_batch_x to batch_x in function "__generate_all_test_batches", you just reshape, i think you should use transpose to change the width and height axis. save the batch_x in this step is not a readable picture anymore.

Belval commented 5 years ago

@xxlxx1 I reproduced the problem. We could simply change the line to:

final_arr[:, 0:min(input_width, np.shape(im_arr_resized)[1]] = im_arr_resized[:, 0:input_width]

Please tell me if it works on your size. I got this result:

Before: test3

After: result

from utils import resize_image
from scipy.misc import imsave

im = resize_image('test3.png', 100)
print(len(im[0]))
imsave('result.png', im[0])

I'm investigating your other question.

Belval commented 5 years ago

For your second question:

There indeed seems to be a big problem with the reshaping, I changed it to np.swapaxes, which gives the desired result.

I'm currently retraining the whole thing, I'll keep you updated.

sevenHsu commented 5 years ago

Thank you!

Belval commented 5 years ago

Please check my last commit, it should fix both the issues mentionned here.

Belval commented 5 years ago

Closing for lack of activity.