MCPcopy
hub / github.com/JaidedAI/EasyOCR / load_weight

Method load_weight

easyocr/DBNet/DBNet.py:138–159  ·  view source on GitHub ↗

Load weight to model. Parameters ---------- weight_path : str Path to trained weight. Raises ------ RuntimeError Raised when the model has not yet been contructed. Returns ------- None.

(self, weight_path)

Source from the content-addressed store, hash-verified

136 return configs
137
138 def load_weight(self, weight_path):
139 '''
140 Load weight to model.
141
142 Parameters
143 ----------
144 weight_path : str
145 Path to trained weight.
146
147 Raises
148 ------
149 RuntimeError
150 Raised when the model has not yet been contructed.
151
152 Returns
153 -------
154 None.
155 '''
156 if self.model is None:
157 raise RuntimeError("model has not yet been constructed.")
158 self.model.load_state_dict(torch.load(weight_path, map_location=self.device), strict=False)
159 self.model.eval()
160
161 def construct_model(self, config):
162 '''

Callers 1

initialize_modelMethod · 0.95

Calls 1

loadMethod · 0.80

Tested by

no test coverage detected