MCPcopy Create free account
hub / github.com/AgentMaker/PaddleQuickInference / preprocess

Function preprocess

examples/UGATIT/processor.py:7–24  ·  view source on GitHub ↗
(img_path)

Source from the content-addressed store, hash-verified

5__all__ = ['preprocess', 'postprocess']
6
7def preprocess(img_path):
8 # 读取图片
9 img = cv2.imread(img_path)
10
11 # 缩放图像
12 img = cv2.resize(img, (256, 256))
13
14 # 归一化
15 img = (img / 255.0 - 0.5) / 0.5
16
17 # 转置
18 img = img.transpose((2, 0, 1))
19
20 # 增加维度
21 img = np.expand_dims(img, axis=0).astype('float32')
22
23 # 返回输入数据
24 return img
25
26def postprocess(outputs, output_dir, model_name):
27 # 反归一化

Callers 1

main.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected