Cherry-pick PR 1366, 1370, 1460, 1577, 1598, 1601, 1612, 1626 to dev-1.x (#1635)
* [Fix] Fix example standalone build for msvc (#1626) * fix example build for msvc * move /Zc:__cplusplus to core * [FIX] Fix csharp net48 and batch inference (#1370) * fix csharp net48 * add missing file * update * fix batch inference * update demo * update * update version * update nuget package version & fix project name * build monolithic SDK by default (#1577) * Fix debug build for PoseTracker (#1601) * [Fix] Fix aligned allocations on Android (#1612) * fix android alignment * fix typo * fix size * Fix build error on windows-cuda platform (#1598) * [Fix] Relax module adapter template constraints (#1366) * relax module adapter constraint * remove forwarding `operator()` * fix YOLOV5Head naming Co-authored-by: Li Zhang <lzhang329@gmail.com>pull/1681/head
parent
953d33cc09
commit
15ad234a7a
|
@ -22,9 +22,9 @@ endif ()
|
|||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
# options
|
||||
option(MMDEPLOY_SHARED_LIBS "build shared libs" ON)
|
||||
option(MMDEPLOY_SHARED_LIBS "build shared libs" OFF)
|
||||
option(MMDEPLOY_BUILD_SDK "build MMDeploy SDK" OFF)
|
||||
option(MMDEPLOY_BUILD_SDK_MONOLITHIC "build single lib for SDK API" OFF)
|
||||
option(MMDEPLOY_BUILD_SDK_MONOLITHIC "build single lib for SDK API" ON)
|
||||
option(MMDEPLOY_BUILD_TEST "build unittests" OFF)
|
||||
option(MMDEPLOY_BUILD_SDK_PYTHON_API "build SDK Python API" OFF)
|
||||
option(MMDEPLOY_BUILD_SDK_CXX_API "build SDK C++ API" OFF)
|
||||
|
@ -73,8 +73,6 @@ endif ()
|
|||
|
||||
if (MSVC)
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/diagnostics:classic>)
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/Zc:preprocessor>) # /experimental:preprocessor on VS2017
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/Zc:__cplusplus>)
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/wd4251>)
|
||||
endif ()
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31729.503
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MMDeploy", "MMDeploy\MMDeploy.csproj", "{3DC914EB-A8FB-4A89-A7CF-7DF9CC5284A6}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MMDeploy", "MMDeploy\MMDeployCSharp.csproj", "{3DC914EB-A8FB-4A89-A7CF-7DF9CC5284A6}"
|
||||
EndProject
|
||||
|
||||
Global
|
||||
|
|
|
@ -53,6 +53,7 @@ namespace MMDeploy
|
|||
public int Channel;
|
||||
public PixelFormat Format;
|
||||
public DataType Type;
|
||||
public void* Device;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<TargetFrameworks>netcoreapp3.1;net48;</TargetFrameworks>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<AssemblyName>MMDeploy</AssemblyName>
|
||||
<AssemblyName>MMDeployCSharp</AssemblyName>
|
||||
<RootNamespace>MMDeploy</RootNamespace>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Deterministic>true</Deterministic>
|
||||
|
@ -17,7 +17,16 @@
|
|||
<MMDeployNativeDlls>$(MSBuildThisFileDirectory)\..\..\..\..\..</MMDeployNativeDlls>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Content CopyToOutputDirectory="PreserveNewest" Include="$(MMDeployNativeDlls)\build\bin\Release\mmdeploy.dll" Pack="true" PackagePath="runtimes\win-x64\native\mmdeploy.dll" />
|
||||
<Content Include="$(MMDeployNativeDlls)\build\bin\Release\mmdeploy.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<Pack>true</Pack>
|
||||
<PackagePath>runtimes\win-x64\native\mmdeploy.dll</PackagePath>
|
||||
</Content>
|
||||
<Content Include="MMDeployCSharp.props">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<Pack>true</Pack>
|
||||
<PackagePath>build\net48\MMDeployCSharp.props</PackagePath>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
|
@ -0,0 +1,11 @@
|
|||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<MMDeployNativeDlls>$(MSBuildThisFileDirectory)..\..\runtimes</MMDeployNativeDlls>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition="$(TargetFrameworkVersion.StartsWith('v4')) Or $(TargetFramework.StartsWith('net4'))">
|
||||
<Content Include="$(MMDeployNativeDlls)\win-x64\native\mmdeploy.dll">
|
||||
<Link>mmdeploy.dll</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -33,10 +33,10 @@ There are two methods to build the nuget package.
|
|||
|
||||
(*option 1*) Use the command.
|
||||
|
||||
If your environment is well prepared, you can just go to the `csrc\apis\csharp` folder, open a terminal and type the following command, the nupkg will be built in `csrc\apis\csharp\MMDeploy\bin\Release\MMDeploy.1.0.0.nupkg`.
|
||||
If your environment is well prepared, you can just go to the `csrc\apis\csharp` folder, open a terminal and type the following command, the nupkg will be built in `csrc\apis\csharp\MMDeploy\bin\Release\MMDeployCSharp.1.0.0-rc1.nupkg`.
|
||||
|
||||
```shell
|
||||
dotnet build --configuration Release -p:Version=1.0.0
|
||||
dotnet build --configuration Release -p:Version=1.0.0-rc1
|
||||
```
|
||||
|
||||
(*option 2*) Open MMDeploy.sln && Build.
|
||||
|
|
|
@ -197,10 +197,6 @@ Result<Detections> YOLOHead::GetBBoxes(const Value& prep_res,
|
|||
return objs;
|
||||
}
|
||||
|
||||
Result<Value> YOLOV3Head::operator()(const Value& prep_res, const Value& infer_res) {
|
||||
return YOLOHead::operator()(prep_res, infer_res);
|
||||
}
|
||||
|
||||
std::array<float, 4> YOLOV3Head::yolo_decode(float box_x, float box_y, float box_w, float box_h,
|
||||
float stride,
|
||||
const std::vector<std::vector<float>>& anchor, int j,
|
||||
|
@ -212,11 +208,7 @@ std::array<float, 4> YOLOV3Head::yolo_decode(float box_x, float box_y, float box
|
|||
return std::array<float, 4>{box_x, box_y, box_w, box_h};
|
||||
}
|
||||
|
||||
Result<Value> YOLOv5Head::operator()(const Value& prep_res, const Value& infer_res) {
|
||||
return YOLOHead::operator()(prep_res, infer_res);
|
||||
}
|
||||
|
||||
std::array<float, 4> YOLOv5Head::yolo_decode(float box_x, float box_y, float box_w, float box_h,
|
||||
std::array<float, 4> YOLOV5Head::yolo_decode(float box_x, float box_y, float box_w, float box_h,
|
||||
float stride,
|
||||
const std::vector<std::vector<float>>& anchor, int j,
|
||||
int i, int a) const {
|
||||
|
@ -232,6 +224,6 @@ std::array<float, 4> YOLOv5Head::yolo_decode(float box_x, float box_y, float box
|
|||
}
|
||||
|
||||
MMDEPLOY_REGISTER_CODEBASE_COMPONENT(MMDetection, YOLOV3Head);
|
||||
MMDEPLOY_REGISTER_CODEBASE_COMPONENT(MMDetection, YOLOv5Head);
|
||||
MMDEPLOY_REGISTER_CODEBASE_COMPONENT(MMDetection, YOLOV5Head);
|
||||
|
||||
} // namespace mmdeploy::mmdet
|
||||
|
|
|
@ -33,16 +33,14 @@ class YOLOHead : public MMDetection {
|
|||
class YOLOV3Head : public YOLOHead {
|
||||
public:
|
||||
using YOLOHead::YOLOHead;
|
||||
Result<Value> operator()(const Value& prep_res, const Value& infer_res);
|
||||
std::array<float, 4> yolo_decode(float box_x, float box_y, float box_w, float box_h, float stride,
|
||||
const std::vector<std::vector<float>>& anchor, int j, int i,
|
||||
int a) const override;
|
||||
};
|
||||
|
||||
class YOLOv5Head : public YOLOHead {
|
||||
class YOLOV5Head : public YOLOHead {
|
||||
public:
|
||||
using YOLOHead::YOLOHead;
|
||||
Result<Value> operator()(const Value& prep_res, const Value& infer_res);
|
||||
std::array<float, 4> yolo_decode(float box_x, float box_y, float box_w, float box_h, float stride,
|
||||
const std::vector<std::vector<float>>& anchor, int j, int i,
|
||||
int a) const override;
|
||||
|
|
|
@ -54,6 +54,11 @@ target_include_directories(${PROJECT_NAME}
|
|||
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/third_party/json>
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
target_compile_options(${PROJECT_NAME} PUBLIC
|
||||
$<$<COMPILE_LANGUAGE:CXX>:/Zc:preprocessor;/Zc:__cplusplus>)
|
||||
endif ()
|
||||
|
||||
if (MMDEPLOY_STATUS_USE_STACKTRACE)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/stacktrace.cmake)
|
||||
else ()
|
||||
|
|
|
@ -11,9 +11,12 @@ class CpuHostMemory : public NonCopyable {
|
|||
public:
|
||||
CpuHostMemory() : size_(), data_(), owned_data_{false} {}
|
||||
Result<void> Init(size_t size, size_t alignment) {
|
||||
size_t space = (size + alignment - 1) / alignment * alignment;
|
||||
alignment = std::max(alignment, sizeof(void*));
|
||||
auto space = (size + alignment - 1) / alignment * alignment;
|
||||
#ifdef _MSC_VER
|
||||
data_ = _aligned_malloc(space, alignment);
|
||||
#elif defined(ANDROID)
|
||||
posix_memalign(&data_, alignment, space);
|
||||
#else
|
||||
data_ = std::aligned_alloc(alignment, space);
|
||||
#endif
|
||||
|
|
|
@ -63,12 +63,12 @@ Result<Value> Invoke(Ret (*f)(Args...), const Value& args) {
|
|||
}
|
||||
|
||||
// member function pointer
|
||||
template <typename Ret, typename C, typename... Args>
|
||||
Result<Value> Invoke(Ret (C::*f)(Args...) const, C* inst, const Value& args) {
|
||||
template <typename Ret, typename C0, typename C1, typename... Args>
|
||||
Result<Value> Invoke(Ret (C0::*f)(Args...) const, C1* inst, const Value& args) {
|
||||
return InvokeImpl<Ret, Args...>::apply(f, args, inst);
|
||||
}
|
||||
template <typename Ret, typename C, typename... Args>
|
||||
Result<Value> Invoke(Ret (C::*f)(Args...), C* inst, const Value& args) {
|
||||
template <typename Ret, typename C0, typename C1, typename... Args>
|
||||
Result<Value> Invoke(Ret (C0::*f)(Args...), C1* inst, const Value& args) {
|
||||
return InvokeImpl<Ret, Args...>::apply(f, args, inst);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Copyright (c) OpenMMLab. All rights reserved.
|
||||
#include <array>
|
||||
|
||||
#include "mmdeploy/core/utils/formatter.h"
|
||||
#include "mmdeploy/operation/vision.h"
|
||||
|
|
|
@ -82,6 +82,7 @@ namespace image_classification
|
|||
mats[i].Channel = cvMats[i].Dims;
|
||||
mats[i].Format = PixelFormat.BGR;
|
||||
mats[i].Type = DataType.Int8;
|
||||
mats[i].Device = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MMDeploy" Version="1.0.0" />
|
||||
<PackageReference Include="MMDeployCSharp" Version="1.0.0-rc1" />
|
||||
<PackageReference Include="OpenCvSharp4" Version="4.5.5.20211231" />
|
||||
<PackageReference Include="OpenCvSharp4.Extensions" Version="4.5.5.20211231" />
|
||||
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.5.5.20211231" />
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace image_restorer
|
|||
mats[i].Channel = cvMats[i].Dims;
|
||||
mats[i].Format = PixelFormat.BGR;
|
||||
mats[i].Type = DataType.Int8;
|
||||
mats[i].Device = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MMDeploy" Version="1.0.0" />
|
||||
<PackageReference Include="MMDeployCSharp" Version="1.0.0-rc1" />
|
||||
<PackageReference Include="OpenCvSharp4" Version="4.5.5.20211231" />
|
||||
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.5.5.20211231" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace image_segmentation
|
|||
mats[i].Channel = cvMats[i].Dims;
|
||||
mats[i].Format = PixelFormat.BGR;
|
||||
mats[i].Type = DataType.Int8;
|
||||
mats[i].Device = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MMDeploy" Version="1.0.0" />
|
||||
<PackageReference Include="MMDeployCSharp" Version="1.0.0-rc1" />
|
||||
<PackageReference Include="OpenCvSharp4" Version="4.5.5.20211231" />
|
||||
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.5.5.20211231" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace object_detection
|
|||
mats[i].Channel = cvMats[i].Dims;
|
||||
mats[i].Format = PixelFormat.BGR;
|
||||
mats[i].Type = DataType.Int8;
|
||||
mats[i].Device = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
|
@ -14,7 +14,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MMDeploy" Version="1.0.0" />
|
||||
<PackageReference Include="MMDeployCSharp" Version="1.0.0-rc1" />
|
||||
<PackageReference Include="OpenCvSharp4" Version="4.5.5.20211231" />
|
||||
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.5.5.20211231" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace ocr_detection
|
|||
mats[i].Channel = cvMats[i].Dims;
|
||||
mats[i].Format = PixelFormat.BGR;
|
||||
mats[i].Type = DataType.Int8;
|
||||
mats[i].Device = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MMDeploy" Version="1.0.0" />
|
||||
<PackageReference Include="MMDeployCSharp" Version="1.0.0-rc1" />
|
||||
<PackageReference Include="OpenCvSharp4" Version="4.5.5.20211231" />
|
||||
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.5.5.20211231" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace ocr_recognition
|
|||
mats[i].Channel = cvMats[i].Dims;
|
||||
mats[i].Format = PixelFormat.BGR;
|
||||
mats[i].Type = DataType.Int8;
|
||||
mats[i].Device = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MMDeploy" Version="1.0.0" />
|
||||
<PackageReference Include="MMDeployCSharp" Version="1.0.0-rc1" />
|
||||
<PackageReference Include="OpenCvSharp4" Version="4.5.5.20211231" />
|
||||
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.5.5.20211231" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace pose_detection
|
|||
mats[i].Channel = cvMats[i].Dims;
|
||||
mats[i].Format = PixelFormat.BGR;
|
||||
mats[i].Type = DataType.Int8;
|
||||
mats[i].Device = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MMDeploy" Version="1.0.0" />
|
||||
<PackageReference Include="MMDeployCSharp" Version="1.0.0-rc1" />
|
||||
<PackageReference Include="OpenCvSharp4" Version="4.5.5.20211231" />
|
||||
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.5.5.20211231" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -489,8 +489,8 @@ class Tracker {
|
|||
|
||||
float ObjectKeypointSimilarity(const Points& pts_a, const Bbox& box_a, const Points& pts_b,
|
||||
const Bbox& box_b) {
|
||||
assert(pts_a.size() == sigmas.size());
|
||||
assert(pts_b.size() == sigmas.size());
|
||||
assert(pts_a.size() == params.sigmas.size());
|
||||
assert(pts_b.size() == params.sigmas.size());
|
||||
auto scale = [](const Bbox& bbox) -> float {
|
||||
auto a = bbox[2] - bbox[0];
|
||||
auto b = bbox[3] - bbox[1];
|
||||
|
|
Loading…
Reference in New Issue