Open R4Ajeti opened 4 months ago
I found a temporary fix while debugging:
From:
ext = importlib.import_module('mmcv.' + name)
for fun in funcs:
assert hasattr(ext, fun), f'{fun} miss in module {name}'
return ext
to:
if not name == "_ext":
ext = importlib.import_module('mmcv.' + name)
for fun in funcs:
assert hasattr(ext, fun), f'{fun} miss in module {name}'
return ext
Hi @R4Ajeti , how did you install mmcv? You could try to uninstall mmcv and follow the below commands to install it again.
pip install openmim
mim install mmcv==2.1.0
Prerequisite
Task
I'm using the official example scripts/configs for the officially supported tasks/models/datasets.
Branch
main branch https://github.com/open-mmlab/mmocr
Environment
python mmocr/utils/collect_env.py sys.platform: darwin Python: 3.12.1 (main, Apr 10 2024, 22:20:38) [Clang 15.0.0 (clang-1500.3.9.4)] CUDA available: False MUSA available: False numpy_random_seed: 2147483648 GCC: Apple clang version 15.0.0 (clang-1500.3.9.4) PyTorch: 2.2.2 PyTorch compiling details: PyTorch built with:
TorchVision: 0.17.2 OpenCV: 4.9.0 MMEngine: 0.10.4 MMOCR: 1.0.1+2caab0a
Reproduces the problem - code sample
Device: MacBook M3 chip
Following installation using this link: https://github.com/open-mmlab/mmocr
Also following discussion from here: https://github.com/open-mmlab/mmcv/issues/204
Nothing worked for me to make OCR work.
The installation process is going all just fine but the package is not working when It comes to OCR samples.
I am getting this error: File "../env/lib/python3.12/site-packages/mmcv/utils/ext_loader.py", line 13, in load_ext ext = importlib.import_module('mmcv.' + name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File " File "../.pyenv/versions/3.12.1/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ModuleNotFoundError: No module named 'mmcv._ext'"
$ pip list | grep mm Is giving me
mmcv 2.1.0 mmdet 3.3.0 mmengine 0.10.4 mmocr 1.0.1 ../repositories/mmocr
What am I doing wrong? Does anyone, have any experience on mac releted to this one?
BTW: I am using python3.12.1
Reproduces the problem - command or script
from mmocr.apis import MMOCRInferencer from mmocr.utils import poly2bbox import numpy as np import time import cv2
Load models into memory
ocr = MMOCRInferencer(det='DBNet', rec=None, device='cpu') # Time taken: 1.3455498218536377 seconds
Perform inference
startTime = time.time() aaa = ocr('../mmocr/images/00_04_24_000-00_04_24_375.jpg') print(aaa["predictions"]) print([poly2bbox(poly) for poly in aaa["predictions"][0]["det_polygons"]]) print(f"Time taken: {time.time() - startTime} seconds")
img = cv2.imread('images/00_04_24_000-00_04_24_375.jpg', cv2.IMREAD_COLOR)
window_name = 'Image'
for text_lines_one in aaa["predictions"][0]["det_polygons"]:
Polygon corner points coordinates
Displaying the image
while(1):
cv2.destroyAllWindows()
Reproduces the problem - error message
I am using "DBNet"
Additional information
Device: MacBook M3 chip
Following installation using this link: https://github.com/open-mmlab/mmocr
Also following discussion from here: https://github.com/open-mmlab/mmcv/issues/204
Nothing worked for me to make OCR work.
The installation process is going all just fine but the package is not working when It comes to OCR samples.
I am getting this error: File "../env/lib/python3.12/site-packages/mmcv/utils/ext_loader.py", line 13, in load_ext ext = importlib.import_module('mmcv.' + name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File " File "../.pyenv/versions/3.12.1/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ModuleNotFoundError: No module named 'mmcv._ext'"
$ pip list | grep mm Is giving me
mmcv 2.1.0 mmdet 3.3.0 mmengine 0.10.4 mmocr 1.0.1 ../repositories/mmocr
What am I doing wrong? Does anyone, have any experience on mac releted to this one?
BTW: I am using python3.12.1