Skip to content

Commit 7082b35

Browse files
committed
Use LRU cache for shape transformation
Only cache transform if shapes are actually the same
1 parent 814e6a2 commit 7082b35

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

deface/centerface.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import datetime
21
import os
32

3+
from functools import lru_cache
4+
45
import numpy as np
56
import cv2
67

@@ -121,6 +122,7 @@ def __call__(self, img, threshold=0.5):
121122
return dets, lms
122123

123124
@staticmethod
125+
@lru_cache(maxsize=128)
124126
def shape_transform(in_shape, orig_shape):
125127
h_orig, w_orig = orig_shape
126128
w_new, h_new = in_shape

0 commit comments

Comments
 (0)