mirror of
https://github.com/open-mmlab/mmdeploy.git
synced 2025-01-14 08:09:43 +08:00
* check in python demos * check in text detector python demo * check in roatated object python demo * check in pose python demo * ignore the output class number when testing metrics with sdk as a backend * fix object_detection * rollback segmentation_model and python/segmentor.cpp
32 lines
821 B
Python
32 lines
821 B
Python
# Copyright (c) OpenMMLab. All rights reserved.
|
|
import argparse
|
|
|
|
import cv2
|
|
from mmdeploy_python import Classifier
|
|
|
|
|
|
def parse_args():
|
|
parser = argparse.ArgumentParser(
|
|
description='show how to use sdk python api')
|
|
parser.add_argument(
|
|
'model_path', help='the directory path of mmdeploy model')
|
|
parser.add_argument('image_path', help='the path of an image')
|
|
parser.add_argument(
|
|
'--device-name', default='cpu', help='the name of device, cuda or cpu')
|
|
args = parser.parse_args()
|
|
return args
|
|
|
|
|
|
def main():
|
|
args = parse_args()
|
|
|
|
img = cv2.imread(args.image_path)
|
|
classifier = Classifier(args.model_path, args.device_name, 0)
|
|
result = classifier([img])
|
|
for label_id, score in result[0]:
|
|
print(label_id, score)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|