@@ -78,14 +78,17 @@ def __init__(
7878 download_enabled = False
7979 model_storage_directory = str (artifacts_path / self ._model_repo_folder )
8080
81- self .reader = easyocr .Reader (
82- lang_list = self .options .lang ,
83- gpu = use_gpu ,
84- model_storage_directory = model_storage_directory ,
85- recog_network = self .options .recog_network ,
86- download_enabled = download_enabled ,
87- verbose = False ,
88- )
81+ with warnings .catch_warnings ():
82+ if self .options .suppress_mps_warnings :
83+ warnings .filterwarnings ("ignore" , message = ".*pin_memory.*MPS.*" )
84+ self .reader = easyocr .Reader (
85+ lang_list = self .options .lang ,
86+ gpu = use_gpu ,
87+ model_storage_directory = model_storage_directory ,
88+ recog_network = self .options .recog_network ,
89+ download_enabled = download_enabled ,
90+ verbose = False ,
91+ )
8992
9093 @staticmethod
9194 def download_models (
@@ -147,7 +150,14 @@ def __call__(
147150 scale = self .scale , cropbox = ocr_rect
148151 )
149152 im = numpy .array (high_res_image )
150- result = self .reader .readtext (im )
153+
154+ with warnings .catch_warnings ():
155+ if self .options .suppress_mps_warnings :
156+ warnings .filterwarnings (
157+ "ignore" , message = ".*pin_memory.*MPS.*"
158+ )
159+
160+ result = self .reader .readtext (im )
151161
152162 del high_res_image
153163 del im
0 commit comments