提交 03eb1be1 编写于 作者: F FlyingQianMM

new ppyolo class

上级 6a4bfdaf
......@@ -26,6 +26,7 @@ ResNet50 = models.ResNet50
DarkNet53 = models.DarkNet53
# detection
YOLOv3 = models.YOLOv3
PPYOLO = models.PPYOLO
#EAST = models.EAST
FasterRCNN = models.FasterRCNN
MaskRCNN = models.MaskRCNN
......
......@@ -38,6 +38,7 @@ from .classifier import HRNet_W18
from .classifier import AlexNet
from .base import BaseAPI
from .yolo_v3 import YOLOv3
from .ppyolo import PPYOLO
from .faster_rcnn import FasterRCNN
from .mask_rcnn import MaskRCNN
from .unet import UNet
......
此差异已折叠。
此差异已折叠。
......@@ -496,15 +496,14 @@ class YOLOv3:
gt_label = inputs['gt_label']
gt_score = inputs['gt_score']
im_size = inputs['im_size']
#num_boxes = fluid.layers.shape(gt_box)[1]
#im_size_wh = fluid.layers.reverse(im_size, axis=1)
#whwh = fluid.layers.concat([im_size_wh, im_size_wh], axis=1)
#whwh = fluid.layers.unsqueeze(whwh, axes=[1])
#whwh = fluid.layers.expand(whwh, expand_times=[1, num_boxes, 1])
#whwh = fluid.layers.cast(whwh, dtype='float32')
#whwh.stop_gradient = True
#normalized_box = fluid.layers.elementwise_div(gt_box, whwh)
normalized_box = gt_box
num_boxes = fluid.layers.shape(gt_box)[1]
im_size_wh = fluid.layers.reverse(im_size, axis=1)
whwh = fluid.layers.concat([im_size_wh, im_size_wh], axis=1)
whwh = fluid.layers.unsqueeze(whwh, axes=[1])
whwh = fluid.layers.expand(whwh, expand_times=[1, num_boxes, 1])
whwh = fluid.layers.cast(whwh, dtype='float32')
whwh.stop_gradient = True
normalized_box = fluid.layers.elementwise_div(gt_box, whwh)
targets = []
if self.use_fine_grained_loss:
......
......@@ -91,7 +91,10 @@ def arrange_transforms(model_type, class_name, transforms, mode='train'):
elif model_type == 'segmenter':
arrange_transform = seg_transforms.ArrangeSegmenter
elif model_type == 'detector':
arrange_name = 'Arrange{}'.format(class_name)
if class_name == "PPYOLO":
arrange_name = 'ArrangeYOLOv3'
else:
arrange_name = 'Arrange{}'.format(class_name)
arrange_transform = getattr(det_transforms, arrange_name)
else:
raise Exception("Unrecognized model type: {}".format(self.model_type))
......
......@@ -17,6 +17,7 @@ from . import cv
FasterRCNN = cv.models.FasterRCNN
YOLOv3 = cv.models.YOLOv3
PPYOLO = cv.models.PPYOLO
MaskRCNN = cv.models.MaskRCNN
transforms = cv.transforms.det_transforms
visualize = cv.models.utils.visualize.visualize_detection
......
......@@ -43,17 +43,7 @@ eval_dataset = pdx.datasets.VOCDetection(
num_classes = len(train_dataset.labels)
# API说明: https://paddlex.readthedocs.io/zh_CN/develop/apis/models/detection.html#paddlex-det-yolov3
model = pdx.det.YOLOv3(
num_classes=num_classes,
backbone='ResNet50_vd',
with_dcn_v2=True,
use_coord_conv=True,
use_iou_aware=True,
use_spp=True,
use_drop_block=True,
scale_x_y=1.05,
use_iou_loss=True,
use_matrix_nms=True)
model = pdx.det.PPYOLO(num_classes=num_classes)
# API说明: https://paddlex.readthedocs.io/zh_CN/develop/apis/models/detection.html#train
# 各参数介绍与调整说明:https://paddlex.readthedocs.io/zh_CN/develop/appendix/parameters.html
......@@ -64,6 +54,5 @@ model.train(
eval_dataset=eval_dataset,
learning_rate=0.000125,
lr_decay_epochs=[210, 240],
use_ema=True,
save_dir='output/ppyolo',
use_vdl=True)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册