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

Function preprocess

examples/ExtremeC3Net/processor.py:11–33  ·  view source on GitHub ↗
(img_path)

Source from the content-addressed store, hash-verified

9
10# 预处理函数
11def preprocess(img_path):
12 # 读取图像
13 img = cv2.imread(img_path)
14
15 # 缩放
16 h, w = img.shape[:2]
17 img = cv2.resize(img, (224, 224))
18
19 # 格式转换
20 img = img.astype(np.float32)
21
22 # 归一化
23 for j in range(3):
24 img[:, :, j] -= mean[j]
25 for j in range(3):
26 img[:, :, j] /= std[j]
27 img /= 255.
28
29 # 格式转换
30 img = img.transpose((2, 0, 1))
31 img = img[np.newaxis, ...]
32
33 return img
34
35# 后处理函数
36def postprocess(results, output_dir, img_path, model_name):

Callers 1

main.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected