MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / CenterSquareResize

Class CenterSquareResize

examples/SuperResolution/data_sampler.py:74–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72
73
74class CenterSquareResize(MapDataComponent):
75 def __init__(self, ds, index=0):
76 """See section 5.3
77 """
78 def func(img):
79 try:
80 h, w, _ = img.shape
81 if h > w:
82 off = (h - w) // 2
83 if off > 0:
84 img = img[off:-off, :, :]
85 if w > h:
86 off = (w - h) // 2
87 if off > 0:
88 img = img[:, off:-off, :]
89
90 img = cv2.resize(img, (256, 256))
91 return img
92 except Exception:
93 return None
94 super(CenterSquareResize, self).__init__(ds, func, index=index)
95
96
97# Testcode for encode/decode.

Callers 2

get_dataFunction · 0.90
data_sampler.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected