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

Method __init__

trainer/modules/transformation.py:85–98  ·  view source on GitHub ↗

Generate P_hat and inv_delta_C for later

(self, F, I_r_size)

Source from the content-addressed store, hash-verified

83 """ Grid Generator of RARE, which produces P_prime by multiplying T with P """
84
85 def __init__(self, F, I_r_size):
86 """ Generate P_hat and inv_delta_C for later """
87 super(GridGenerator, self).__init__()
88 self.eps = 1e-6
89 self.I_r_height, self.I_r_width = I_r_size
90 self.F = F
91 self.C = self._build_C(self.F) # F x 2
92 self.P = self._build_P(self.I_r_width, self.I_r_height)
93 ## for multi-gpu, you need register buffer
94 self.register_buffer("inv_delta_C", torch.tensor(self._build_inv_delta_C(self.F, self.C)).float()) # F+3 x F+3
95 self.register_buffer("P_hat", torch.tensor(self._build_P_hat(self.F, self.C, self.P)).float()) # n x F+3
96 ## for fine-tuning with different image width, you may use below instead of self.register_buffer
97 #self.inv_delta_C = torch.tensor(self._build_inv_delta_C(self.F, self.C)).float().cuda() # F+3 x F+3
98 #self.P_hat = torch.tensor(self._build_P_hat(self.F, self.C, self.P)).float().cuda() # n x F+3
99
100 def _build_C(self, F):
101 """ Return coordinates of fiducial points in I_r; C """

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls 4

_build_CMethod · 0.95
_build_PMethod · 0.95
_build_inv_delta_CMethod · 0.95
_build_P_hatMethod · 0.95

Tested by

no test coverage detected