MCPcopy Index your code
hub / github.com/JaidedAI/EasyOCR / initialize_model

Method initialize_model

easyocr/DBNet/DBNet.py:176–195  ·  view source on GitHub ↗

Wrapper to initialize text detection model. This model includes contructing and weight loading. Parameters ---------- model_config : dict Configuration dictionary. weight_path : str Path to trained weight. Returns

(self, model_config, weight_path)

Source from the content-addressed store, hash-verified

174 self.model = Configurable.construct_class_from_config(config).structure.builder.build(self.device)
175
176 def initialize_model(self, model_config, weight_path):
177 '''
178 Wrapper to initialize text detection model. This model includes contructing
179 and weight loading.
180
181 Parameters
182 ----------
183 model_config : dict
184 Configuration dictionary.
185 weight_path : str
186 Path to trained weight.
187
188 Returns
189 -------
190 None.
191 '''
192 self.construct_model(model_config)
193 self.load_weight(weight_path)
194 if isinstance(self.model.model, torch.nn.DataParallel) and self.device == 'cpu':
195 self.model.model = self.model.model.module.to(self.device)
196
197 def get_cv2_image(self, image):
198 '''

Callers 2

get_detectorFunction · 0.95
__init__Method · 0.95

Calls 2

construct_modelMethod · 0.95
load_weightMethod · 0.95

Tested by

no test coverage detected