Page orientation model redownloading when container starts #66
-
Hi, I have deployed a small project on serverless, I have specified the custom models like below in my image. However, I see in my server that whenever my container starts, it is downloading the orientation model and saving to my /root/.cache not sure why. Note that I only see page orientation model downloaded and not the other. What will be the reason for this and how can I avoid this redownloading? Thank :)
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hey 👋; A quick fix would be: from onnxtr.models import detection, recognition, mobilenet_v3_small_page_orientation, mobilenet_v3_small_crop_orientation
from onnxtr.models import ocr_predictor
from onnxtr.models.classification.zoo import page_orientation_predictor, crop_orienatation_predictor
detection_model_path = os.path.abspath('onnx/onnxtr-db-mobilenet-v3-large.onnx')
recognition_model_path = os.path.abspath('onnx/onnxtr-crnn-mobilenet-v3-large.onnx')
page_orientation_model_path = os.path.abspath('onnx/mobilenet_v3_small_page_orientation-60606ce4.onnx')
crop_orientation_model_path = ...
det_model = detection.db_mobilenet_v3_large(detection_model_path)
rec_model = recognition.crnn_mobilenet_v3_large(recognition_model_path)
custom_page_orientation_model = mobilenet_v3_small_page_orientation(page_orientation_model_path)
custom_crop_orientation_model = mobilenet_v3_small_crop_orientation(crop_orientation_model_path)
ocr = ocr_predictor(det_arch=det_model,
reco_arch=rec_model,
assume_straight_pages=True,
straighten_pages=True,
disable_crop_orientation=True, # <-- disable before
disable_page_orientation=True, # <-- disable before
)
# Assign custom orientation models
ocr.crop_orientation_predictor = crop_orientation_predictor(custom_crop_orientation_model)
ocr.page_orientation_predictor = page_orientation_predictor(custom_page_orientation_model)
# Reenable orientation detection after loading custom models
ocr._page_orientation_disabled = False
ocr._crop_orientation_disabled = False |
Beta Was this translation helpful? Give feedback.
-
I'd like to add that the proposed quick fix didn't work for me as my detection model needed to have predictor.assume_straight_pages = assume_straight_pages
predictor.det_predictor.model.assume_straight_pages = assume_straight_pages
predictor.det_predictor.model.postprocessor.assume_straight_pages = assume_straight_pages |
Beta Was this translation helpful? Give feedback.
Hey 👋;
A quick fix would be: