mmdeploy/.github/scripts/test_java_demo.py
hanrui1sensetime b59d83bf7b
[Feature] Add Java APIs and demos for pose tracker, segmentor and rotated-object detector (#1795)
* move to dev-1.x

* fix wrong class name

* redesign Params argument mechanisms

* change demo build to ant

* remove unused debugging file

* fix demo

* remove hardcode

* a general build.xml

* update README

* fix clang-format

* rename follow java format

* update docs

* fix lint

* fix java_api build

* fix ci

* fix java api ci

* fix lint

* fix opencv build privilege

* fix CI ant build

* remove opencv build because is too slow

* fix lib path

* fix wrong dir

* fix run demo location

* fix ant command

* fix opencv

* mv opencv to java demo

* fix CI

* fix comments

* add absolute lib path in ci

* find lib

* find lib

* fix mmdeploy lib path in ci

* fix pose ocr pose-tracker

* support RotatedDetection and Segmentation score

* add cmake

* fix lint

* fix yapf

* fix clang-format

* fix clang-format

* fix java api ci

* fix ocr src pic

* add rotate

* add opencv lib

* fix lib

* fix libgstreamer missing

* add libgstreamer-plugin

* fix comments

* fix comments

* add avcodec for posetracker

* fix CI

* fix java ci comments

* fix test_java_demo format

* fix lint and ffmpeg missing

* fix comments

* a copy of array for java

* fix demo stuck

* fix test_java_demo.py

* fix popd and pushd

* fix java_api

* fix java api handle

* update for api

* add java docstrings for demo

* add docstring for posetracker java and fix handle

* add some java api docstrings

* return ec

* add error code for java

* add all java docs

* fix clang-format

* fix PoseTracker apply api for batch inference

* fix missing error code

* remove author

* remove author

* remove destroy window

* fix wrong code

* fix Context

* fix java docs

* fix comments

* fix compile failed

* fix for and if format

* fix error code

* fix bracket
2023-03-08 14:39:39 +08:00

110 lines
3.6 KiB
Python

# Copyright (c) OpenMMLab. All rights reserved.
import os
# list of dict: task name and deploy configs.
PARAMS = [
{
'task':
'ImageClassification',
'configs': [
'https://media.githubusercontent.com/media/hanrui1sensetime/mmdeploy-javaapi-testdata/master/resnet.tar' # noqa: E501
]
},
{
'task':
'ObjectDetection',
'configs': [
'https://media.githubusercontent.com/media/hanrui1sensetime/mmdeploy-javaapi-testdata/master/mobilessd.tar' # noqa: E501
]
},
{
'task':
'ImageSegmentation',
'configs': [
'https://media.githubusercontent.com/media/hanrui1sensetime/mmdeploy-javaapi-testdata/master/fcn.tar' # noqa: E501
]
},
{
'task':
'ImageRestorer',
'configs': [
'https://media.githubusercontent.com/media/hanrui1sensetime/mmdeploy-javaapi-testdata/master/srcnn.tar' # noqa: E501
]
},
{
'task':
'Ocr',
'configs': [
'https://media.githubusercontent.com/media/hanrui1sensetime/mmdeploy-javaapi-testdata/master/dbnet.tar', # noqa: E501
'https://media.githubusercontent.com/media/hanrui1sensetime/mmdeploy-javaapi-testdata/master/crnn.tar' # noqa: E501
]
},
{
'task':
'PoseDetection',
'configs': [
'https://media.githubusercontent.com/media/hanrui1sensetime/mmdeploy-javaapi-testdata/master/litehrnet.tar' # noqa: E501
]
},
{
'task':
'PoseTracker',
'configs': [
'https://media.githubusercontent.com/media/hanrui1sensetime/mmdeploy-javaapi-testdata/master/rtmdet-nano.tar', # noqa: E501
'https://media.githubusercontent.com/media/hanrui1sensetime/mmdeploy-javaapi-testdata/master/rtmpose-tiny.tar' # noqa: E501
]
},
{
'task':
'RotatedDetection',
'configs': [
'https://media.githubusercontent.com/media/hanrui1sensetime/mmdeploy-javaapi-testdata/master/gliding-vertex.tar' # noqa: E501
]
}
]
def main():
"""test java apis and demos.
Run all java demos for test.
"""
for params in PARAMS:
task = params['task']
configs = params['configs']
java_command = '\"cpu'
for config in configs:
model_url = config
os.system('wget {} && tar xvf {}'.format(model_url,
model_url.split('/')[-1]))
model_dir = model_url.split('/')[-1].split('.')[0]
java_command += (' ' + model_dir)
if task in [
'ImageClassification', 'ObjectDetection', 'ImageSegmentation',
'ImageRestorer', 'PoseDetection', 'RotatedDetection'
]:
java_command += (' $GITHUB_WORKSPACE/demo' +
'/resources/human-pose.jpg\"')
elif task in ['Ocr']:
java_command += (' $GITHUB_WORKSPACE/demo' +
'/resources/text_det.jpg\"')
elif task in ['PoseTracker']:
os.system(
'wget https://media.githubusercontent.com/media/hanrui1sensetime/mmdeploy-javaapi-testdata/master/dance.mp4' # noqa: E501
)
java_command += ' dance.mp4\"'
else:
java_command += '\"'
print(f'java_command: {java_command}')
os.system('ant -DtaskName=' + task +
' -DjarDir=${OPENCV_DIR}/build/bin ' +
'-DlibDir=${OPENCV_DIR}/build/lib:$GITHUB_WORKSPACE/' +
'build/lib -Dcommand=' + java_command)
if __name__ == '__main__':
main()