HusseinYoussef / Arabic-OCR

OCR system for Arabic language that converts images of typed text to machine-encoded text.
MIT License
267 stars 73 forks source link

TypeError: Cannot cast array data from dtype('uint32') to dtype('int32') according to the rule 'safe' #2

Closed Joe-Mobarak closed 4 years ago

Joe-Mobarak commented 4 years ago

Hey when i m loading one of your test images i m getting this error any idea how to solve this ?

Joe-Mobarak commented 4 years ago

That is happening when segmenting use segment method

HusseinYoussef commented 4 years ago

There was a problem with the dataset. So we updated the link and fixed some conflict in preprocessing.py file Reclone and try again using the images in the new dataset.

Joe-Mobarak commented 4 years ago

Hey man but the data set images are still the same 2 months ago

HusseinYoussef commented 4 years ago

The images still have the same names but they have only letters now. Since the system supports only letters for now (29 letters) ا-ى, لا. The older version of the dataset contained characters other than Arabic letters.

Joe-Mobarak commented 4 years ago

Ok man i will give it a shot and let you know Thank you

Joe-Mobarak commented 4 years ago

Hey man i am afraid the issue remains :

TypeError: Cannot cast array data from dtype('uint32') to dtype('int32') according to the rule 'safe'

HusseinYoussef commented 4 years ago

Can you specify what image that produces the error ?

Joe-Mobarak commented 4 years ago

Traceback (most recent call last): File "C:\Users\mobar\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\pool.py", line 125, in worker result = (True, func(*args, *kwds)) File "C:\Users\mobar\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\pool.py", line 48, in mapstar return list(map(args)) File "C:\Users\mobar\Downloads\Omega\Omega\src\OCR.py", line 24, in run2 char_imgs = segment(line, word) File "C:\Users\mobar\Downloads\Omega\Omega\src\character_segmentation.py", line 746, in segment valid = filter_regions(binary_word, no_dots_copy, SRL, VP, upper_base, lower_base, MTI, MFV, top_line) File "C:\Users\mobar\Downloads\Omega\Omega\src\character_segmentation.py", line 584, in filter_regions (check_stroke(no_dots_copy, no_dots_copy[:, SEG[0]:SEG[1]], upper_base, lower_base, SEG_SR1, SEG_SR2) \ File "C:\Users\mobar\Downloads\Omega\Omega\src\character_segmentation.py", line 361, in check_stroke MFV_HP = np.argmax(np.bincount(HP)[1:])+1 File "<__array_function__ internals>", line 5, in bincount TypeError: Cannot cast array data from dtype('uint32') to dtype('int32') according to the rule 'safe' """

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:/Users/mobar/Downloads/Omega/Omega/src/OCR.py", line 115, in running_time.append(run(images_path)) File "C:/Users/mobar/Downloads/Omega/Omega/src/OCR.py", line 50, in run predicted_words = pool.map(run2, words) File "C:\Users\mobar\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\pool.py", line 364, in map return self._map_async(func, iterable, mapstar, chunksize).get() File "C:\Users\mobar\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\pool.py", line 768, in get raise self._value TypeError: Cannot cast array data from dtype('uint32') to dtype('int32') according to the rule 'safe'

Joe-Mobarak commented 4 years ago

I am using capr2.png from your drive

HusseinYoussef commented 4 years ago

That's weird. We had no problem with casting on our machines but i have updated utilities.py file to explicitly cast to int32. so please try again and let me know.

Joe-Mobarak commented 4 years ago

It worked man Thank you