test_sdk_python.ps1 782 Bytes
Newer Older
limm's avatar
limm committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
$ErrorActionPreference = 'Stop'

$WORKSPACE = ""
$MODEL_DIR = "D:\DEPS\citest\mmcls"
$SDK_PYTHON_DIR = "mmdeploy_runtime"

if ($args.Count -gt 0) {
    $WORKSPACE = $args[0]
}

Push-Location $WORKSPACE
Push-Location $SDK_PYTHON_DIR

$pkgs = $(ls).Name
$test_pkg = ""
if ($pkgs.Count -gt 1) {
    foreach ($pkg in $pkgs) {
        if ($pkg -like 'mmdeploy_runtime-*cp38*-win_amd64.whl') {
            $test_pkg = $pkg
            break
        }
    }
}

pip install $test_pkg --force-reinstall

$code = "
import cv2
from mmdeploy_runtime import Classifier
import sys
handle = Classifier('$MODEL_DIR', 'cpu', 0)
img = cv2.imread('$MODEL_DIR\demo.jpg')
try:
    res = handle(img)
    print(res)
except:
    print('error')
    sys.exit(1)
"

python -c $code

Pop-Location
Pop-Location