mirror of
https://github.com/open-mmlab/mmdeploy.git
synced 2025-01-14 08:09:43 +08:00
* [Feature]: Add github prebuild workflow after new release. (#1852) * add prebuild dockerfile * add prebuild test workflw * update * update * rm other workflow for test * Update docker image * add win1o prebuild * add test prebuild * add windows scripts in prebuilt package * add linux scripts in prebuilt package * generate_build_config.py * fix cudnn search * fix env * fix script * fix rpath * fix cwd * fix windows * fix lint * windows prebuild ci * linux prebuild ci * fix * update trigger * Revert "rm other workflow for test" This reverts commit 0a0387275014efab71046d33a0e52904672b4012. * update sdk build readme * update prebuild * fix dll deps for python >= 3.8 on windows * fix ci * test prebuild * update test script to avoid modify upload folder * add onnxruntime.dll to mmdeploy_python * update prebuild workflow * update prebuild * Update loader.cpp.in * remove exists prebuild files * fix opencv env * update cmake options for mmdeploy python build * remove test code * fix lint --------- Co-authored-by: RunningLeon <mnsheng@yeah.net> Co-authored-by: RunningLeon <maningsheng@sensetime.com> * rename mmdeploy_python -> mmdeploy_runtime * test master prebuild * fix trt net build * Revert "test master prebuild" This reverts commit aad5258648f5f2c410c965b295c309fd1166da22. * add master branch * fix linux set_env script * update package_tools docs * fix gcc 7.3 aligned_alloc * comment temporarily as text_det_recog can't be built with prebuild package built under manylinux --------- Co-authored-by: RunningLeon <mnsheng@yeah.net> Co-authored-by: RunningLeon <maningsheng@sensetime.com>
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
# Copyright (c) OpenMMLab. All rights reserved.
|
|
import argparse
|
|
from math import cos, sin
|
|
|
|
import cv2
|
|
import numpy as np
|
|
from mmdeploy_runtime import RotatedDetector
|
|
|
|
|
|
def parse_args():
|
|
parser = argparse.ArgumentParser(
|
|
description='show how to use sdk python api')
|
|
parser.add_argument('device_name', help='name of device, cuda or cpu')
|
|
parser.add_argument(
|
|
'model_path', help='path of SDK model dumped by model converter')
|
|
parser.add_argument('image_path', help='path of an image')
|
|
args = parser.parse_args()
|
|
return args
|
|
|
|
|
|
def main():
|
|
args = parse_args()
|
|
|
|
img = cv2.imread(args.image_path)
|
|
detector = RotatedDetector(
|
|
model_path=args.model_path, device_name=args.device_name, device_id=0)
|
|
rbboxes, labels = detector(img)
|
|
|
|
indices = [i for i in range(len(rbboxes))]
|
|
for index, rbbox, label_id in zip(indices, rbboxes, labels):
|
|
[cx, cy, w, h, angle], score = rbbox[0:5], rbbox[-1]
|
|
if score < 0.1:
|
|
continue
|
|
[wx, wy, hx, hy] = \
|
|
0.5 * np.array([w, w, -h, h]) * \
|
|
np.array([cos(angle), sin(angle), sin(angle), cos(angle)])
|
|
points = np.array([[[int(cx - wx - hx),
|
|
int(cy - wy - hy)],
|
|
[int(cx + wx - hx),
|
|
int(cy + wy - hy)],
|
|
[int(cx + wx + hx),
|
|
int(cy + wy + hy)],
|
|
[int(cx - wx + hx),
|
|
int(cy - wy + hy)]]])
|
|
cv2.drawContours(img, points, -1, (0, 255, 0), 2)
|
|
|
|
cv2.imwrite('output_detection.png', img)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|