Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add YOLOv5 support for RV1126 device. #1321

Merged
merged 25 commits into from
Dec 16, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'dev-1.x' into rv1126-yolov5
AllentDan committed Dec 15, 2022
commit 4e1393b5d76c6a3318c8462f6fed6a4461e8bd8d
4 changes: 2 additions & 2 deletions .circleci/test.yml
Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@ commands:
python -m mim install -r requirements/codebases.txt
python -m pip install -r requirements/tests.txt
python -m pip install -r requirements/runtime.txt
python -m pip install -U numpy
python -m pip install -U numpy clip
cd ..
perform_model_converter_ut:
steps:
@@ -147,7 +147,7 @@ jobs:
docker exec mmdeploy mim install -r mmdeploy/requirements/codebases.txt
docker exec mmdeploy pip install -r mmdeploy/requirements/tests.txt
docker exec mmdeploy pip install -r mmdeploy/requirements/runtime.txt
docker exec mmdeploy pip install -U numpy
docker exec mmdeploy pip install -U numpy clip
- run:
name: Perform Model Converter unittests
command: |
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/1-bug-report.yml
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ body:
label: Checklist
options:
- label: I have searched related issues but cannot get the expected help.
- label: 2. I have read the [FAQ documentation](https://github.com/open-mmlab/mmdeploy/blob/master/docs/en/faq.md) but cannot get the expected help.
- label: 2. I have read the [FAQ documentation](https://github.com/open-mmlab/mmdeploy/tree/1.x/docs/en/faq.md) but cannot get the expected help.
- label: 3. The bug has not been fixed in the latest version.
- type: textarea
attributes:
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ blank_issues_enabled: false

contact_links:
- name: 💥 FAQ
url: https://github.com/open-mmlab/mmdeploy/blob/master/docs/en/faq.md
url: https://github.com/open-mmlab/mmdeploy/tree/1.x/docs/en/faq.md
about: Check if your issue already has solutions
- name: 💬 Forum
url: https://github.com/open-mmlab/mmdeploy/discussions
33 changes: 33 additions & 0 deletions .github/md-link-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"ignorePatterns": [

{
"pattern": "^https://developer.nvidia.com/"
},
{
"pattern": "^https://docs.openvino.ai/"
},
{
"pattern": "^https://developer.android.com/"
},
{
"pattern": "^https://developer.qualcomm.com/"
},
{
"pattern": "^http://localhost"
}
],
"httpHeaders": [
{
"urls": ["https://github.com/", "https://guides.github.com/", "https://help.github.com/", "https://docs.github.com/"],
"headers": {
"Accept-Encoding": "zstd, br, gzip, deflate"
}
}
],
"timeout": "20s",
"retryOn429": true,
"retryCount": 5,
"fallbackRetryDelay": "30s",
"aliveStatusCodes": [200, 206, 429]
}
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ jobs:
python -m pip install -r requirements.txt -r requirements/backends.txt
python -m mim install "mmcv>=2.0.0rc1"
python -m mim install -r requirements/codebases.txt
python -m pip install -U numpy
python -m pip install -U numpy clip
python -m pip list
- name: Build and install
run: |
@@ -142,7 +142,7 @@ jobs:
python -m pip install -r requirements.txt -r requirements/backends.txt
python -m mim install "mmcv>=2.0.0rc1"
CFLAGS=$CFLAGS python -m mim install -r requirements/codebases.txt
python -m pip install -U pycuda numpy
python -m pip install -U pycuda numpy clip
python -m pip list
- name: Build and install
run: |
@@ -190,7 +190,7 @@ jobs:
python -m pip install -r requirements.txt -r requirements/backends.txt
python -m mim install "mmcv>=2.0.0rc1"
python -m mim install -r requirements/codebases.txt
python -m pip install -U pycuda numpy
python -m pip install -U pycuda numpy clip
python -m pip list
- name: Build and install
run: |
9 changes: 9 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -27,6 +27,15 @@ jobs:
run: |
python .github/scripts/check_index_rst.py docs/en/index.rst
python .github/scripts/check_index_rst.py docs/zh_cn/index.rst
- name: Check markdown link
uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: 'yes'
use-verbose-mode: 'yes'
# check-modified-files-only: 'yes'
config-file: '.github/md-link-config.json'
folder-path: 'docs/en, docs/zh_cn'
file-path: './README.md, ./LICENSE, ./README_zh-CN.md'
- name: Check doc link
run: |
python .github/scripts/doc_link_checker.py --target docs/zh_cn
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -19,10 +19,10 @@
<div>&nbsp;</div>
</div>

[![docs](https://img.shields.io/badge/docs-latest-blue)](https://mmdeploy.readthedocs.io/en/latest/)
[![docs](https://img.shields.io/badge/docs-latest-blue)](https://mmdeploy.readthedocs.io/en/1.x/)
[![badge](https://github.com/open-mmlab/mmdeploy/workflows/build/badge.svg)](https://github.com/open-mmlab/mmdeploy/actions)
[![codecov](https://codecov.io/gh/open-mmlab/mmdeploy/branch/master/graph/badge.svg)](https://codecov.io/gh/open-mmlab/mmdeploy)
[![license](https://img.shields.io/github/license/open-mmlab/mmdeploy.svg)](https://github.com/open-mmlab/mmdeploy/blob/master/LICENSE)
[![codecov](https://codecov.io/gh/open-mmlab/mmdeploy/branch/1.x/graph/badge.svg)](https://codecov.io/gh/open-mmlab/mmdeploy)
[![license](https://img.shields.io/github/license/open-mmlab/mmdeploy.svg)](https://github.com/open-mmlab/mmdeploy/tree/1.x/LICENSE)
[![issue resolution](https://img.shields.io/github/issues-closed-raw/open-mmlab/mmdeploy)](https://github.com/open-mmlab/mmdeploy/issues)
[![open issues](https://img.shields.io/github/issues-raw/open-mmlab/mmdeploy)](https://github.com/open-mmlab/mmdeploy/issues)

@@ -50,6 +50,7 @@ The currently supported codebases and models are as follows, and more will be in
- [mmpose](docs/en/04-supported-codebases/mmpose.md)
- [mmdet3d](docs/en/04-supported-codebases/mmdet3d.md)
- [mmrotate](docs/en/04-supported-codebases/mmrotate.md)
- [mmaction2](docs/en/04-supported-codebases/mmaction2.md)

### Multiple inference backends are available

@@ -74,7 +75,7 @@ The benchmark can be found from [here](docs/en/03-benchmark/benchmark.md)

All kinds of modules in the SDK can be extended, such as `Transform` for image processing, `Net` for Neural Network inference, `Module` for postprocessing and so on

## [Documentation](https://mmdeploy.readthedocs.io/en/latest/)
## [Documentation](https://mmdeploy.readthedocs.io/en/1.x/)

Please read [getting_started](docs/en/get_started.md) for the basic usage of MMDeploy. We also provide tutoials about:

11 changes: 6 additions & 5 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
@@ -19,10 +19,10 @@
<div>&nbsp;</div>
</div>

[![docs](https://img.shields.io/badge/docs-latest-blue)](https://mmdeploy.readthedocs.io/zh_CN/latest/)
[![docs](https://img.shields.io/badge/docs-latest-blue)](https://mmdeploy.readthedocs.io/zh_CN/1.x/)
[![badge](https://github.com/open-mmlab/mmdeploy/workflows/build/badge.svg)](https://github.com/open-mmlab/mmdeploy/actions)
[![codecov](https://codecov.io/gh/open-mmlab/mmdeploy/branch/master/graph/badge.svg)](https://codecov.io/gh/open-mmlab/mmdeploy)
[![license](https://img.shields.io/github/license/open-mmlab/mmdeploy.svg)](https://github.com/open-mmlab/mmdeploy/blob/master/LICENSE)
[![codecov](https://codecov.io/gh/open-mmlab/mmdeploy/branch/1.x/graph/badge.svg)](https://codecov.io/gh/open-mmlab/mmdeploy)
[![license](https://img.shields.io/github/license/open-mmlab/mmdeploy.svg)](https://github.com/open-mmlab/mmdeploy/tree/1.x/LICENSE)
[![issue resolution](https://img.shields.io/github/issues-closed-raw/open-mmlab/mmdeploy)](https://github.com/open-mmlab/mmdeploy/issues)
[![open issues](https://img.shields.io/github/issues-raw/open-mmlab/mmdeploy)](https://github.com/open-mmlab/mmdeploy/issues)

@@ -50,6 +50,7 @@ MMDeploy 是 [OpenMMLab](https://openmmlab.com/) 模型部署工具箱,**为
- [mmpose](docs/zh_cn/04-supported-codebases/mmpose.md)
- [mmdet3d](docs/zh_cn/04-supported-codebases/mmdet3d.md)
- [mmrotate](docs/zh_cn/04-supported-codebases/mmrotate.md)
- [mmaction2](docs/zh_cn/04-supported-codebases/mmaction2.md)

### 支持多种推理后端

@@ -74,7 +75,7 @@ MMDeploy 是 [OpenMMLab](https://openmmlab.com/) 模型部署工具箱,**为
- Net 推理
- Module 后处理

## [中文文档](https://mmdeploy.readthedocs.io/zh_CN/latest/)
## [中文文档](https://mmdeploy.readthedocs.io/zh_CN/1.x/)

- [快速上手](docs/zh_cn/get_started.md)
- [编译](docs/zh_cn/01-how-to-build/build_from_source.md)
@@ -118,7 +119,7 @@ MMDeploy 是 [OpenMMLab](https://openmmlab.com/) 模型部署工具箱,**为

## 基准与模型库

基准和支持的模型列表可以在[基准](https://mmdeploy.readthedocs.io/zh_CN/latest/benchmark.html)和[模型列表](https://mmdeploy.readthedocs.io/en/latest/supported_models.html)中获得。
基准和支持的模型列表可以在[基准](https://mmdeploy.readthedocs.io/zh_CN/1.x/03-benchmark/benchmark.html)和[模型列表](https://mmdeploy.readthedocs.io/en/1.x/03-benchmark/supported_models.html)中获得。

## 贡献指南

1 change: 1 addition & 0 deletions csrc/mmdeploy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ if (MMDEPLOY_BUILD_SDK)
add_subdirectory(device)
add_subdirectory(graph)
add_subdirectory(model)
add_subdirectory(operation)
add_subdirectory(preprocess)
add_subdirectory(net)
add_subdirectory(codebase)
20 changes: 20 additions & 0 deletions csrc/mmdeploy/apis/c/mmdeploy/common.cpp
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
#include "common_internal.h"
#include "executor_internal.h"
#include "mmdeploy/core/mat.h"
#include "mmdeploy/core/profiler.h"

mmdeploy_value_t mmdeploy_value_copy(mmdeploy_value_t value) {
if (!value) {
@@ -72,6 +73,19 @@ int mmdeploy_device_create(const char* device_name, int device_id, mmdeploy_devi

void mmdeploy_device_destroy(mmdeploy_device_t device) { delete (Device*)device; }

int mmdeploy_profiler_create(const char* path, mmdeploy_profiler_t* profiler) {
*profiler = (mmdeploy_profiler_t) new profiler::Profiler(path);
return MMDEPLOY_SUCCESS;
}

void mmdeploy_profiler_destroy(mmdeploy_profiler_t profiler) {
if (profiler) {
auto p = (profiler::Profiler*)profiler;
p->Release();
delete p;
}
}

int mmdeploy_context_add(mmdeploy_context_t context, mmdeploy_context_type_t type, const char* name,
const void* object) {
auto& ctx = *Cast(context);
@@ -88,6 +102,12 @@ int mmdeploy_context_add(mmdeploy_context_t context, mmdeploy_context_type_t typ
case MMDEPLOY_TYPE_MODEL:
ctx["model"][name] = *Cast((const mmdeploy_model_t)object);
break;
case MMDEPLOY_TYPE_PROFILER: {
const auto& profiler = *(profiler::Profiler*)object;
profiler::Scope* root(profiler.scope());
ctx["scope"] = root;
break;
}
default:
return MMDEPLOY_E_NOT_SUPPORTED;
}
18 changes: 18 additions & 0 deletions csrc/mmdeploy/apis/c/mmdeploy/common.h
Original file line number Diff line number Diff line change
@@ -56,6 +56,8 @@ typedef enum mmdeploy_status_t {

typedef struct mmdeploy_device* mmdeploy_device_t;

typedef struct mmdeploy_profiler* mmdeploy_profiler_t;

typedef struct mmdeploy_mat_t {
uint8_t* data;
int height;
@@ -88,6 +90,7 @@ typedef enum mmdeploy_context_type_t {
MMDEPLOY_TYPE_MODEL = 2,
MMDEPLOY_TYPE_SCHEDULER = 3,
MMDEPLOY_TYPE_MAT = 4,
MMDEPLOY_TYPE_PROFILER = 5,
} mmdeploy_context_type_t;

#if __cplusplus
@@ -123,6 +126,21 @@ MMDEPLOY_API int mmdeploy_device_create(const char* device_name, int device_id,
*/
MMDEPLOY_API void mmdeploy_device_destroy(mmdeploy_device_t device);

/**
* Create profiler
* @param path path to save the profile data
* @param profiler handle for profiler, should be added to context and deleted by
* mmdeploy_profiler_destroy
* @return status of create
*/
MMDEPLOY_API int mmdeploy_profiler_create(const char* path, mmdeploy_profiler_t* profiler);

/**
* Destroy profiler handle
* @param profiler handle for profiler, profile data will be written to disk after this call
*/
MMDEPLOY_API void mmdeploy_profiler_destroy(mmdeploy_profiler_t profiler);

/**
* Create context
* @param context
4 changes: 2 additions & 2 deletions csrc/mmdeploy/apis/c/mmdeploy/executor.cpp
Original file line number Diff line number Diff line change
@@ -13,10 +13,10 @@ namespace {

mmdeploy_scheduler_t CreateScheduler(const char* type, const Value& config = Value()) {
try {
auto creator = Registry<SchedulerType>::Get().GetCreator(type);
auto creator = gRegistry<SchedulerType>().Get(type);
if (!creator) {
MMDEPLOY_ERROR("Creator for {} not found. Available schedulers: {}", type,
Registry<SchedulerType>::Get().List());
gRegistry<SchedulerType>().List());
return nullptr;
}
return Cast(new SchedulerType(creator->Create(config)));
23 changes: 23 additions & 0 deletions csrc/mmdeploy/apis/cxx/mmdeploy/common.hpp
Original file line number Diff line number Diff line change
@@ -76,6 +76,24 @@ class Device {
std::shared_ptr<mmdeploy_device> device_;
};

class Profiler {
public:
explicit Profiler(std::string_view path) : path_(path) {
mmdeploy_profiler_t profiler{};
auto ec = mmdeploy_profiler_create(path_.c_str(), &profiler);
if (ec != MMDEPLOY_SUCCESS) {
throw_exception(static_cast<ErrorCode>(ec));
}
profiler_.reset(profiler, [](auto p) { mmdeploy_profiler_destroy(p); });
};

operator mmdeploy_profiler_t() const noexcept { return profiler_.get(); }

private:
std::string path_;
std::shared_ptr<mmdeploy_profiler> profiler_;
};

class Mat {
public:
Mat() : desc_{} {}
@@ -187,6 +205,10 @@ class Context {
mmdeploy_context_add(*this, MMDEPLOY_TYPE_DEVICE, nullptr, device);
}

void Add(const Profiler& profiler) {
mmdeploy_context_add(*this, MMDEPLOY_TYPE_PROFILER, nullptr, profiler);
}

operator mmdeploy_context_t() const noexcept { return context_.get(); }

private:
@@ -199,6 +221,7 @@ using cxx::Context;
using cxx::Device;
using cxx::Mat;
using cxx::Model;
using cxx::Profiler;
using cxx::Rect;
using cxx::Scheduler;

14 changes: 9 additions & 5 deletions csrc/mmdeploy/apis/python/detector.cpp
Original file line number Diff line number Diff line change
@@ -28,12 +28,16 @@ class PyDetector {
if (status != MMDEPLOY_SUCCESS) {
throw std::runtime_error("failed to apply detector, code: " + std::to_string(status));
}
using Sptr = std::shared_ptr<mmdeploy_detection_t>;
Sptr holder(detection, [result_count, n = mats.size()](auto p) {
mmdeploy_detector_release_result(p, result_count, n);
});
auto output = py::list{};
auto result = detection;
for (int i = 0; i < mats.size(); ++i) {
auto bboxes = py::array_t<float>({result_count[i], 5});
auto labels = py::array_t<int>(result_count[i]);
auto masks = std::vector<py::array_t<uint8_t>>{};
auto masks = std::vector<py::array>();
masks.reserve(result_count[i]);
for (int j = 0; j < result_count[i]; ++j, ++result) {
auto bbox = bboxes.mutable_data(j);
@@ -44,16 +48,16 @@ class PyDetector {
bbox[4] = result->score;
labels.mutable_at(j) = result->label_id;
if (result->mask) {
py::array_t<uint8_t> mask({result->mask->height, result->mask->width});
memcpy(mask.mutable_data(), result->mask->data, mask.nbytes());
masks.push_back(std::move(mask));
masks.emplace_back(std::array{result->mask->height, result->mask->width}, // shape
reinterpret_cast<uint8_t*>(result->mask->data), // data
py::capsule(new Sptr(holder), // handle
[](void* p) { delete reinterpret_cast<Sptr*>(p); }));
} else {
masks.emplace_back();
}
}
output.append(py::make_tuple(std::move(bboxes), std::move(labels), std::move(masks)));
}
mmdeploy_detector_release_result(detection, result_count, (int)mats.size());
return output;
}
~PyDetector() {
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.