Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
BERT_migraphx
Commits
cb8f0018
Commit
cb8f0018
authored
Jun 13, 2023
by
liucong
Browse files
删除多余代码
parent
43193e02
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
127 deletions
+11
-127
CMakeLists.txt
CMakeLists.txt
+0
-1
Src/Bert.h
Src/Bert.h
+11
-3
Src/Utility/CommonDefinition.h
Src/Utility/CommonDefinition.h
+0
-59
Src/Utility/CommonUtility.cpp
Src/Utility/CommonUtility.cpp
+0
-44
Src/Utility/CommonUtility.h
Src/Utility/CommonUtility.h
+0
-20
No files found.
CMakeLists.txt
View file @
cb8f0018
...
...
@@ -35,7 +35,6 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/Src/main.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/Src/Bert.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/Src/Utility/tokenization.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/Src/Utility/utf8proc.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/Src/Utility/CommonUtility.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/Src/Utility/Filesystem.cpp
)
# 添加可执行目标
...
...
Src/Bert.h
View file @
cb8f0018
#ifndef BERT_H
#define BERT_H
#ifndef
__
BERT_H
__
#define
__
BERT_H
__
#include <cstdint>
#include <string>
#include <migraphx/program.hpp>
#include <CommonDefinition.h>
#include <tokenization.h>
namespace
migraphxSamples
{
typedef
enum
_ErrorCode
{
SUCCESS
=
0
,
MODEL_NOT_EXIST
,
CONFIG_FILE_NOT_EXIST
,
FAIL_TO_LOAD_MODEL
,
FAIL_TO_OPEN_CONFIG_FILE
,
}
ErrorCode
;
typedef
struct
_Sort_st
{
int
index
;
...
...
Src/Utility/CommonDefinition.h
deleted
100644 → 0
View file @
43193e02
// 常用定义
#ifndef __COMMON_DEFINITION_H__
#define __COMMON_DEFINITION_H__
#include <opencv2/opencv.hpp>
namespace
migraphxSamples
{
// 路径分隔符(Linux:‘/’,Windows:’\\’)
#ifdef _WIN32
#define PATH_SEPARATOR '\\'
#else
#define PATH_SEPARATOR '/'
#endif
#define CONFIG_FILE "../Resource/Configuration.xml"
typedef
enum
_ErrorCode
{
SUCCESS
=
0
,
// 0
MODEL_NOT_EXIST
,
// 模型不存在
CONFIG_FILE_NOT_EXIST
,
// 配置文件不存在
FAIL_TO_LOAD_MODEL
,
// 加载模型失败
FAIL_TO_OPEN_CONFIG_FILE
,
// 加载配置文件失败
IMAGE_ERROR
,
// 图像错误
}
ErrorCode
;
typedef
struct
_ResultOfPrediction
{
float
confidence
;
int
label
;
_ResultOfPrediction
()
:
confidence
(
0.0
f
),
label
(
0
){}
}
ResultOfPrediction
;
typedef
struct
_ResultOfDetection
{
cv
::
Rect
boundingBox
;
float
confidence
;
int
classID
;
std
::
string
className
;
bool
exist
;
_ResultOfDetection
()
:
confidence
(
0.0
f
),
classID
(
0
),
exist
(
true
){}
}
ResultOfDetection
;
typedef
struct
_InitializationParameterOfNLP
{
std
::
string
parentPath
;
std
::
string
configFilePath
;
}
InitializationParameterOfNLP
;
}
#endif
Src/Utility/CommonUtility.cpp
deleted
100644 → 0
View file @
43193e02
#include <CommonUtility.h>
namespace
migraphxSamples
{
bool
CompareConfidence
(
const
ResultOfDetection
&
L
,
const
ResultOfDetection
&
R
)
{
return
L
.
confidence
>
R
.
confidence
;
}
bool
CompareArea
(
const
ResultOfDetection
&
L
,
const
ResultOfDetection
&
R
)
{
return
L
.
boundingBox
.
area
()
>
R
.
boundingBox
.
area
();
}
void
NMS
(
std
::
vector
<
ResultOfDetection
>
&
detections
,
float
IOUThreshold
)
{
// sort
std
::
sort
(
detections
.
begin
(),
detections
.
end
(),
CompareConfidence
);
for
(
int
i
=
0
;
i
<
detections
.
size
();
++
i
)
{
if
(
detections
[
i
].
exist
)
{
for
(
int
j
=
i
+
1
;
j
<
detections
.
size
();
++
j
)
{
if
(
detections
[
j
].
exist
)
{
// compute IOU
float
intersectionArea
=
(
detections
[
i
].
boundingBox
&
detections
[
j
].
boundingBox
).
area
();
float
intersectionRate
=
intersectionArea
/
(
detections
[
i
].
boundingBox
.
area
()
+
detections
[
j
].
boundingBox
.
area
()
-
intersectionArea
);
if
(
intersectionRate
>
IOUThreshold
)
{
detections
[
j
].
exist
=
false
;
}
}
}
}
}
}
}
Src/Utility/CommonUtility.h
deleted
100644 → 0
View file @
43193e02
// 常用工具
#ifndef __COMMON_UTILITY_H__
#define __COMMON_UTILITY_H__
#include <CommonDefinition.h>
namespace
migraphxSamples
{
// 排序规则: 按照置信度或者按照面积排序
bool
CompareConfidence
(
const
ResultOfDetection
&
L
,
const
ResultOfDetection
&
R
);
bool
CompareArea
(
const
ResultOfDetection
&
L
,
const
ResultOfDetection
&
R
);
// 非极大抑制
void
NMS
(
std
::
vector
<
ResultOfDetection
>
&
detections
,
float
IOUThreshold
);
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment