open-mmlab / mmocr

OpenMMLab Text Detection, Recognition and Understanding Toolbox
https://mmocr.readthedocs.io/en/dev-1.x/
Apache License 2.0
4.18k stars 735 forks source link

[Bug] On the latest version of mmocr how do I set statically the model download path? #2046

Open R4Ajeti opened 1 month ago

R4Ajeti commented 1 month ago

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

This code is working fine for me but how do I define the path of the model where "mmocr" should download the detection model and recognition model because I wanna send it statically on serverless to reduce time consuming?

Reproduces the problem - code sample

import numpy as np import time import cv2

from mmocr.apis import MMOCRInferencer from mmocr.utils import poly2bbox

Load models into memory

ocr = MMOCRInferencer(det='DBNet', rec='SAR', device='cpu')

startTime = time.time() img = cv2.imread('../mmocr/images/00_04_24_000-00_04_24_375.jpg', cv2.IMREAD_COLOR)

Perform inference

aaa = ocr(img) print(aaa["predictions"]) print([poly2bbox(poly) for poly in aaa["predictions"][0]["det_polygons"]]) print(f"Time taken: {time.time() - startTime} seconds")

Reproduces the problem - command or script

...

Reproduces the problem - error message

...

Additional information

No response