mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-05 16:48:03 +08:00
[Example] Merge Download Paddle Model, Paddle->ONNX->MLIR->BModel (#1643)
* fix infer.py and README * [Example] Merge Download Paddle Model, Paddle->Onnx->Mlir->Bmodel and inference into infer.py. Modify README.md * modify pp_liteseg sophgo infer.py and README.md * fix PPOCR,PPYOLOE,PICODET,LITESEG sophgo infer.py and README.md * fix memory overflow problem while inferring with sophgo backend * fix memory overflow problem while inferring with sophgo backend --------- Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com> Co-authored-by: xuyizhou <yizhou.xu@sophgo.com>
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
def prepare(img_path, sz):
|
||||
im = cv2.imread(img_path)
|
||||
im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)
|
||||
im = cv2.resize(im, sz)
|
||||
im = im.transpose((2,0,1))
|
||||
im = im[np.newaxis,...]
|
||||
im_scale_y = sz[0] / float(im.shape[2])
|
||||
im_scale_x = sz[1] / float(im.shape[3])
|
||||
inputs = {}
|
||||
inputs['image'] = np.array(im).astype('float32')
|
||||
# scale = np.array([im_scale_y, im_scale_x])
|
||||
# scale = scale[np.newaxis,...]
|
||||
inputs['scale_factor'] = np.array(([im_scale_y, im_scale_x], )).astype('float32')
|
||||
np.savez('inputs.npz', image=inputs['image'], scale_factor=inputs['scale_factor'])
|
Reference in New Issue
Block a user