Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleX
提交
b2ccd9ab
P
PaddleX
项目概览
PaddlePaddle
/
PaddleX
通知
138
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
43
列表
看板
标记
里程碑
合并请求
5
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleX
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
43
Issue
43
列表
看板
标记
里程碑
合并请求
5
合并请求
5
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b2ccd9ab
编写于
9月 03, 2020
作者:
J
jiangjiajun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
compatible with paddlepaddle lower than 1.8.4
上级
63f88667
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
56 addition
and
28 deletion
+56
-28
paddlex/__init__.py
paddlex/__init__.py
+0
-5
paddlex/cv/models/ppyolo.py
paddlex/cv/models/ppyolo.py
+4
-0
paddlex/cv/nets/detection/loss/yolo_loss.py
paddlex/cv/nets/detection/loss/yolo_loss.py
+29
-13
paddlex/cv/nets/detection/yolo_v3.py
paddlex/cv/nets/detection/yolo_v3.py
+23
-10
未找到文件。
paddlex/__init__.py
浏览文件 @
b2ccd9ab
...
...
@@ -43,11 +43,6 @@ except:
"[WARNING] pycocotools install: https://paddlex.readthedocs.io/zh_CN/develop/install.html#pycocotools"
)
import
paddle
if
paddle
.
__version__
==
'0.0.0'
:
print
(
"[NOTICE]
\t
You are using paddlepaddle with version= 0.0.0"
)
elif
paddle
.
__version__
<
'1.8.4'
:
raise
Exception
(
"[ERROR] paddlepaddle-gpu or paddlepaddle >= 1.8.4 is required"
)
import
paddlehub
as
hub
if
hub
.
version
.
hub_version
<
'1.8.2'
:
raise
Exception
(
"[ERROR] paddlehub >= 1.8.2 is required"
)
...
...
paddlex/cv/models/ppyolo.py
浏览文件 @
b2ccd9ab
...
...
@@ -18,6 +18,7 @@ import tqdm
import
os.path
as
osp
import
numpy
as
np
from
multiprocessing.pool
import
ThreadPool
import
paddle
import
paddle.fluid
as
fluid
from
paddle.fluid.layers.learning_rate_scheduler
import
_decay_step_counter
from
paddle.fluid.optimizer
import
ExponentialMovingAverage
...
...
@@ -123,6 +124,9 @@ class PPYOLO(BaseAPI):
self
.
use_ema
=
False
self
.
with_dcn_v2
=
with_dcn_v2
if
paddle
.
__version__
<
'1.8.4'
and
paddle
.
__version__
!=
'0.0.0'
:
raise
Exception
(
"PPYOLO requires paddlepaddle or paddlepaddle-gpu >= 1.8.4"
)
def
_get_backbone
(
self
,
backbone_name
):
if
backbone_name
.
startswith
(
'ResNet50_vd'
):
backbone
=
paddlex
.
cv
.
nets
.
ResNet
(
...
...
paddlex/cv/nets/detection/loss/yolo_loss.py
浏览文件 @
b2ccd9ab
...
...
@@ -16,6 +16,7 @@ from __future__ import absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
paddle
from
paddle
import
fluid
try
:
from
collections.abc
import
Sequence
...
...
@@ -67,19 +68,34 @@ class YOLOv3Loss(object):
scale_x_y
=
self
.
scale_x_y
if
not
isinstance
(
self
.
scale_x_y
,
Sequence
)
else
self
.
scale_x_y
[
i
]
anchor_mask
=
anchor_masks
[
i
]
loss
=
fluid
.
layers
.
yolov3_loss
(
x
=
output
,
gt_box
=
gt_box
,
gt_label
=
gt_label
,
gt_score
=
gt_score
,
anchors
=
anchors
,
anchor_mask
=
anchor_mask
,
class_num
=
num_classes
,
ignore_thresh
=
self
.
_ignore_thresh
,
downsample_ratio
=
self
.
downsample
[
i
],
use_label_smooth
=
self
.
_label_smooth
,
scale_x_y
=
scale_x_y
,
name
=
prefix_name
+
"yolo_loss"
+
str
(
i
))
if
paddle
.
__version__
<
'1.8.4'
and
paddle
.
__version__
!=
'0.0.0'
:
loss
=
fluid
.
layers
.
yolov3_loss
(
x
=
output
,
gt_box
=
gt_box
,
gt_label
=
gt_label
,
gt_score
=
gt_score
,
anchors
=
anchors
,
anchor_mask
=
anchor_mask
,
class_num
=
num_classes
,
ignore_thresh
=
self
.
_ignore_thresh
,
downsample_ratio
=
self
.
downsample
[
i
],
use_label_smooth
=
self
.
_label_smooth
,
name
=
prefix_name
+
"yolo_loss"
+
str
(
i
))
else
:
loss
=
fluid
.
layers
.
yolov3_loss
(
x
=
output
,
gt_box
=
gt_box
,
gt_label
=
gt_label
,
gt_score
=
gt_score
,
anchors
=
anchors
,
anchor_mask
=
anchor_mask
,
class_num
=
num_classes
,
ignore_thresh
=
self
.
_ignore_thresh
,
downsample_ratio
=
self
.
downsample
[
i
],
use_label_smooth
=
self
.
_label_smooth
,
scale_x_y
=
scale_x_y
,
name
=
prefix_name
+
"yolo_loss"
+
str
(
i
))
losses
.
append
(
fluid
.
layers
.
reduce_mean
(
loss
))
...
...
paddlex/cv/nets/detection/yolo_v3.py
浏览文件 @
b2ccd9ab
...
...
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
paddle
from
paddle
import
fluid
from
paddle.fluid.param_attr
import
ParamAttr
from
paddle.fluid.regularizer
import
L2Decay
...
...
@@ -407,16 +408,28 @@ class YOLOv3:
scale_x_y
=
self
.
scale_x_y
if
not
isinstance
(
self
.
scale_x_y
,
Sequence
)
else
self
.
scale_x_y
[
i
]
box
,
score
=
fluid
.
layers
.
yolo_box
(
x
=
input
,
img_size
=
im_size
,
anchors
=
self
.
mask_anchors
[
i
],
class_num
=
self
.
num_classes
,
conf_thresh
=
self
.
nms
.
score_threshold
,
downsample_ratio
=
self
.
downsample
[
i
],
name
=
self
.
prefix_name
+
'yolo_box'
+
str
(
i
),
clip_bbox
=
self
.
clip_bbox
,
scale_x_y
=
self
.
scale_x_y
)
if
paddle
.
__version__
<
'1.8.4'
and
paddle
.
__version__
!=
'0.0.0'
:
box
,
score
=
fluid
.
layers
.
yolo_box
(
x
=
input
,
img_size
=
im_size
,
anchors
=
self
.
mask_anchors
[
i
],
class_num
=
self
.
num_classes
,
conf_thresh
=
self
.
nms
.
score_threshold
,
downsample_ratio
=
self
.
downsample
[
i
],
name
=
self
.
prefix_name
+
'yolo_box'
+
str
(
i
),
clip_bbox
=
self
.
clip_bbox
)
else
:
box
,
score
=
fluid
.
layers
.
yolo_box
(
x
=
input
,
img_size
=
im_size
,
anchors
=
self
.
mask_anchors
[
i
],
class_num
=
self
.
num_classes
,
conf_thresh
=
self
.
nms
.
score_threshold
,
downsample_ratio
=
self
.
downsample
[
i
],
name
=
self
.
prefix_name
+
'yolo_box'
+
str
(
i
),
clip_bbox
=
self
.
clip_bbox
,
scale_x_y
=
self
.
scale_x_y
)
boxes
.
append
(
box
)
scores
.
append
(
fluid
.
layers
.
transpose
(
score
,
perm
=
[
0
,
2
,
1
]))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录