Open jhalbrecht opened 1 week ago
Although pytest failed I went on to try some examples. I noticed pip install -r requirements.txt
after running that /tests/pytest
still fails. I went to the /examples
and ran python main.py
resulting in this output;
(ocr) jeffa@ocr:~/dev/handwritten_text_detection_and_recognition/examples$ python main.py
File path: ../data/page
Processing file ../data/page/r06-137.png
Traceback (most recent call last):
File "/home/jeffa/dev/handwritten_text_detection_and_recognition/examples/main.py", line 96, in <module>
save_image_names_to_text_files()
File "/home/jeffa/dev/handwritten_text_detection_and_recognition/examples/main.py", line 46, in save_image_names_to_text_files
detections = detect(img,
^^^^^^^^^^^
File "/home/jeffa/ocr/lib/python3.11/site-packages/word_detector/__init__.py", line 47, in detect
kernel = _compute_kernel(kernel_size, sigma, theta)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jeffa/ocr/lib/python3.11/site-packages/word_detector/__init__.py", line 84, in _compute_kernel
x_term = (x ** 2 - sigma_x ** 2) / (2 * np.math.pi * sigma_x ** 5 * sigma_y)
^^^^^^^
File "/home/jeffa/ocr/lib/python3.11/site-packages/numpy/__init__.py", line 410, in __getattr__
raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'math'. Did you mean: 'emath'?
(ocr) jeffa@ocr:~/dev/handwritten_text_detection_and_recognition/examples$
In "/home/jeffa/ocr/lib/python3.11/site-packages/word_detector/init.py" I changed lines 84,85 for pi s/np.math.pi/np.pi/
Then I ran tests again, which appear to pass.
(ocr) jeffa@ocr:~/dev/handwritten_text_detection_and_recognition/tests$ pytest
===================================================================== test session starts ======================================================================platform linux -- Python 3.11.2, pytest-8.2.2, pluggy-1.5.0
rootdir: /home/jeffa/dev/handwritten_text_detection_and_recognition
collected 1 item
test_synthetic.py . [100%]
====================================================================== 1 passed in 0.59s =======================================================================
Next I tried python main.py
in /examples again failing as;
(ocr) jeffa@ocr:~/dev/handwritten_text_detection_and_recognition/examples$ python main.py
File path: ../data/page
Processing file ../data/page/r06-137.png
Traceback (most recent call last):
File "/home/jeffa/dev/handwritten_text_detection_and_recognition/examples/main.py", line 96, in <module>
save_image_names_to_text_files()
File "/home/jeffa/dev/handwritten_text_detection_and_recognition/examples/main.py", line 58, in save_image_names_to_text_files
colors = plt.cm.get_cmap('rainbow', num_colors)
^^^^^^^^^^^^^^^
AttributeError: module 'matplotlib.cm' has no attribute 'get_cmap'
(ocr) jeffa@ocr:~/dev/handwritten_text_detection_and_recognition/examples$
I invoked
pytest
from the "handwritten_text_detection_and_recognition/tests" directory. I received this error.I tried
pip install numpy
andpip install NumPy
got "Requirement already satisfied: NumPy in /home/jeffa/ocr/lib/python3.11/site-packages (2.0.0)"