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
GPT2_migraphx
Commits
4e0028ec
Commit
4e0028ec
authored
Jun 13, 2023
by
liucong
Browse files
删除多余代码
parent
5c098b75
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1 addition
and
132 deletions
+1
-132
README.md
README.md
+1
-1
Src/Utility/CommonDefinition.h
Src/Utility/CommonDefinition.h
+0
-67
Src/Utility/CommonUtility.cpp
Src/Utility/CommonUtility.cpp
+0
-44
Src/Utility/CommonUtility.h
Src/Utility/CommonUtility.h
+0
-20
No files found.
README.md
View file @
4e0028ec
...
...
@@ -42,7 +42,7 @@ pip install -r requirements.txt
export
MIGRAPHX_DYNAMIC_SHAPE
=
1
```
4.
在Python
/NLP/GPT2
目录下执行如下命令运行该示例程序:
4.
在Python目录下执行如下命令运行该示例程序:
```
python
python
gpt2
.
py
...
...
Src/Utility/CommonDefinition.h
deleted
100644 → 0
View file @
5c098b75
// 常用定义
#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
_InitializationParameterOfDetector
{
std
::
string
parentPath
;
std
::
string
configFilePath
;
}
InitializationParameterOfDetector
;
typedef
struct
_InitializationParameterOfDetector
InitializationParameterOfClassifier
;
typedef
struct
_InitializationParameterOfDetector
InitializationParameterOfSuperresolution
;
typedef
struct
_InitializationParameterOfDetector
InitializationParameterOfSegmentation
;
typedef
struct
_InitializationParameterOfDetector
InitializationParameterOfNLP
;
typedef
struct
_InitializationParameterOfDetector
InitializationParameterOfOcr
;
typedef
struct
_InitializationParameterOfDetector
InitializationParameterOfDB
;
typedef
struct
_InitializationParameterOfDetector
InitializationParameterOfSVTR
;
}
#endif
Src/Utility/CommonUtility.cpp
deleted
100644 → 0
View file @
5c098b75
#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 @
5c098b75
// 常用工具
#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