author
int64
658
755k
date
stringlengths
19
19
timezone
int64
-46,800
43.2k
hash
stringlengths
40
40
message
stringlengths
5
490
mods
list
language
stringclasses
20 values
license
stringclasses
3 values
repo
stringlengths
5
68
original_message
stringlengths
12
491
499,310
29.07.2020 12:54:18
-28,800
e8c4f816b24feebb4234c22a49f3f052fd56e9e8
fix cpp precision
[ { "change_type": "MODIFY", "old_path": "deploy/cpp/src/main.cc", "new_path": "deploy/cpp/src/main.cc", "diff": "@@ -94,7 +94,7 @@ void PredictImage(const std::string& image_path,\nstd::vector<PaddleDetection::ObjectResult> result;\ndet->Predict(im, &result);\nfor (const auto& item : result) {\n- printf(\"class=%d confidence=%.2f rect=[%d %d %d %d]\\n\",\n+ printf(\"class=%d confidence=%.4f rect=[%d %d %d %d]\\n\",\nitem.class_id,\nitem.confidence,\nitem.rect[0],\n" }, { "change_type": "MODIFY", "old_path": "deploy/cpp/src/object_detector.cc", "new_path": "deploy/cpp/src/object_detector.cc", "diff": "// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n-\n+#include <sstream>\n+// for setprecision\n+#include <iomanip>\n#include \"include/object_detector.h\"\nnamespace PaddleDetection {\n@@ -71,13 +73,15 @@ cv::Mat VisualizeResult(const cv::Mat& img,\ncv::Rect roi = cv::Rect(results[i].rect[0], results[i].rect[2], w, h);\n// Configure color and text size\n- std::string text = lable_list[results[i].class_id];\n+ std::ostringstream oss;\n+ oss << std::setiosflags(std::ios::fixed) << std::setprecision(4);\n+ oss << lable_list[results[i].class_id] << \" \";\n+ oss << results[i].confidence;\n+ std::string text = oss.str();\nint c1 = colormap[3 * results[i].class_id + 0];\nint c2 = colormap[3 * results[i].class_id + 1];\nint c3 = colormap[3 * results[i].class_id + 2];\ncv::Scalar roi_color = cv::Scalar(c1, c2, c3);\n- text += \" \";\n- text += std::to_string(static_cast<int>(results[i].confidence * 100)) + \"%\";\nint font_face = cv::FONT_HERSHEY_COMPLEX_SMALL;\ndouble font_scale = 0.5f;\nfloat thickness = 0.5;\n" }, { "change_type": "MODIFY", "old_path": "deploy/python/infer.py", "new_path": "deploy/python/infer.py", "diff": "@@ -456,7 +456,7 @@ class Detector():\nexpect_boxes = (np_boxes[:, 1] > threshold) & (np_boxes[:, 0] > -1)\nnp_boxes = np_boxes[expect_boxes, :]\nfor box in np_boxes:\n- print('class_id:{:d}, confidence:{:.2f},'\n+ print('class_id:{:d}, confidence:{:.4f},'\n'left_top:[{:.2f},{:.2f}],'\n' right_bottom:[{:.2f},{:.2f}]'.format(\nint(box[0]), box[1], box[2], box[3], box[4], box[5]))\n" }, { "change_type": "MODIFY", "old_path": "deploy/python/visualize.py", "new_path": "deploy/python/visualize.py", "diff": "@@ -180,7 +180,7 @@ def draw_box(im, np_boxes, labels):\nfill=color)\n# draw label\n- text = \"{} {:.2f}\".format(labels[clsid], score)\n+ text = \"{} {:.4f}\".format(labels[clsid], score)\ntw, th = draw.textsize(text)\ndraw.rectangle(\n[(xmin + 1, ymin - th), (xmin + tw + 1, ymin)], fill=color)\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix cpp precision (#1095)
499,313
01.08.2020 20:18:17
-28,800
e9c67639d5f1a0295acfa0cf7cc9de0c0c949ef3
fix ppyolo config iters
[ { "change_type": "MODIFY", "old_path": "configs/ppyolo/ppyolo.yml", "new_path": "configs/ppyolo/ppyolo.yml", "diff": "architecture: YOLOv3\nuse_gpu: true\n-max_iters: 500000\n+max_iters: 250000\nlog_smooth_window: 100\nlog_iter: 100\nsave_dir: output\n@@ -70,13 +70,13 @@ MatrixNMS:\npost_threshold: 0.01\nLearningRate:\n- base_lr: 0.00333\n+ base_lr: 0.01\nschedulers:\n- !PiecewiseDecay\ngamma: 0.1\nmilestones:\n- - 400000\n- - 450000\n+ - 150000\n+ - 200000\n- !LinearWarmup\nstart_factor: 0.\nsteps: 4000\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix ppyolo config iters (#1138)
499,313
02.08.2020 21:11:48
-28,800
68ca9401d123c0e840c83695b0b2a3ac392804e9
fix exclude_nms
[ { "change_type": "MODIFY", "old_path": "ppdet/modeling/architectures/cascade_mask_rcnn.py", "new_path": "ppdet/modeling/architectures/cascade_mask_rcnn.py", "diff": "@@ -437,4 +437,4 @@ class CascadeMaskRCNN(object):\ndef test(self, feed_vars, exclude_nms=False):\nassert not exclude_nms, \"exclude_nms for {} is not support currently\".format(\nself.__class__.__name__)\n- return self.build(feed_vars, 'test', exclude_nms=exclude_nms)\n+ return self.build(feed_vars, 'test')\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/architectures/cascade_rcnn_cls_aware.py", "new_path": "ppdet/modeling/architectures/cascade_rcnn_cls_aware.py", "diff": "@@ -319,7 +319,7 @@ class CascadeRCNNClsAware(object):\nreturn self.build_multi_scale(feed_vars)\nreturn self.build(feed_vars, 'test')\n- def test(self, feed_vars):\n+ def test(self, feed_vars, exclude_nms=False):\nassert not exclude_nms, \"exclude_nms for {} is not support currently\".format(\nself.__class__.__name__)\nreturn self.build(feed_vars, 'test')\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix exclude_nms (#1141)
499,313
03.08.2020 15:42:52
-28,800
09d01d175f58bbae8160143f42b9e360845d5f91
fix test_architectures
[ { "change_type": "MODIFY", "old_path": "ppdet/modeling/tests/test_architectures.py", "new_path": "ppdet/modeling/tests/test_architectures.py", "diff": "@@ -19,6 +19,7 @@ from __future__ import print_function\nimport unittest\nimport numpy as np\n+import paddle\nimport paddle.fluid as fluid\nimport os\nimport sys\n@@ -70,6 +71,10 @@ class TestCascadeRCNN(TestFasterRCNN):\nself.cfg_file = 'configs/cascade_rcnn_r50_fpn_1x.yml'\n+@unittest.skipIf(\n+ paddle.version.major < \"2\",\n+ \"Paddle 2.0 should be used for YOLOv3 takes scale_x_y as inputs, \"\n+ \"disable this unittest for Paddle major version < 2\")\nclass TestYolov3(TestFasterRCNN):\ndef set_config(self):\nself.cfg_file = 'configs/yolov3_darknet.yml'\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix test_architectures (#1146)
499,313
04.08.2020 19:00:32
-28,800
ce63a4f510d60eb0376aaf1ee859a4ff08cf26ba
add ppyolo_2x
[ { "change_type": "ADD", "old_path": null, "new_path": "configs/ppyolo/ppyolo_2x.yml", "diff": "+architecture: YOLOv3\n+use_gpu: true\n+max_iters: 500000\n+log_smooth_window: 100\n+log_iter: 100\n+save_dir: output\n+snapshot_iter: 10000\n+metric: COCO\n+pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_vd_ssld_pretrained.tar\n+weights: output/ppyolo/model_final\n+num_classes: 80\n+use_fine_grained_loss: true\n+use_ema: true\n+ema_decay: 0.9998\n+\n+YOLOv3:\n+ backbone: ResNet\n+ yolo_head: YOLOv3Head\n+ use_fine_grained_loss: true\n+\n+ResNet:\n+ norm_type: sync_bn\n+ freeze_at: 0\n+ freeze_norm: false\n+ norm_decay: 0.\n+ depth: 50\n+ feature_maps: [3, 4, 5]\n+ variant: d\n+ dcn_v2_stages: [5]\n+\n+YOLOv3Head:\n+ anchor_masks: [[6, 7, 8], [3, 4, 5], [0, 1, 2]]\n+ anchors: [[10, 13], [16, 30], [33, 23],\n+ [30, 61], [62, 45], [59, 119],\n+ [116, 90], [156, 198], [373, 326]]\n+ norm_decay: 0.\n+ coord_conv: true\n+ iou_aware: true\n+ iou_aware_factor: 0.4\n+ scale_x_y: 1.05\n+ spp: true\n+ yolo_loss: YOLOv3Loss\n+ nms: MatrixNMS\n+ drop_block: true\n+\n+YOLOv3Loss:\n+ batch_size: 24\n+ ignore_thresh: 0.7\n+ scale_x_y: 1.05\n+ label_smooth: false\n+ use_fine_grained_loss: true\n+ iou_loss: IouLoss\n+ iou_aware_loss: IouAwareLoss\n+\n+IouLoss:\n+ loss_weight: 2.5\n+ max_height: 608\n+ max_width: 608\n+\n+IouAwareLoss:\n+ loss_weight: 1.0\n+ max_height: 608\n+ max_width: 608\n+\n+MatrixNMS:\n+ background_label: -1\n+ keep_top_k: 100\n+ normalized: false\n+ score_threshold: 0.01\n+ post_threshold: 0.01\n+\n+LearningRate:\n+ base_lr: 0.01\n+ schedulers:\n+ - !PiecewiseDecay\n+ gamma: 0.1\n+ milestones:\n+ - 400000\n+ - 450000\n+ - !LinearWarmup\n+ start_factor: 0.\n+ steps: 4000\n+\n+OptimizerBuilder:\n+ optimizer:\n+ momentum: 0.9\n+ type: Momentum\n+ regularizer:\n+ factor: 0.0005\n+ type: L2\n+\n+_READER_: 'ppyolo_reader.yml'\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
add ppyolo_2x (#1155)
499,304
14.08.2020 18:22:32
-28,800
0e40029fa1a16cb06b2d154fd9909945684f3c50
add ssdlite-ghostnet model
[ { "change_type": "ADD", "old_path": null, "new_path": "configs/ssd/ssdlite_ghostnet.yml", "diff": "+architecture: SSD\n+use_gpu: true\n+max_iters: 400000\n+snapshot_iter: 20000\n+log_smooth_window: 20\n+log_iter: 20\n+metric: COCO\n+pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/GhostNet_x1_3_ssld_pretrained.tar\n+save_dir: output\n+weights: output/ssdlite_ghostnet/model_final\n+# 80(label_class) + 1(background)\n+num_classes: 81\n+\n+SSD:\n+ backbone: GhostNet\n+ multi_box_head: SSDLiteMultiBoxHead\n+ output_decoder:\n+ background_label: 0\n+ keep_top_k: 200\n+ nms_eta: 1.0\n+ nms_threshold: 0.45\n+ nms_top_k: 400\n+ score_threshold: 0.01\n+\n+\n+GhostNet:\n+ scale: 1.3\n+ extra_block_filters: [[256, 512], [128, 256], [128, 256], [64, 128]]\n+ feature_maps: [5, 7, 8, 9, 10, 11]\n+ conv_decay: 0.00004\n+ lr_mult_list: [0.25, 0.25, 0.5, 0.5, 0.75]\n+\n+SSDLiteMultiBoxHead:\n+ aspect_ratios: [[2.], [2., 3.], [2., 3.], [2., 3.], [2., 3.], [2., 3.]]\n+ base_size: 320\n+ steps: [16, 32, 64, 107, 160, 320]\n+ flip: true\n+ clip: true\n+ max_ratio: 95\n+ min_ratio: 20\n+ offset: 0.5\n+ conv_decay: 0.00004\n+\n+LearningRate:\n+ base_lr: 0.2\n+ schedulers:\n+ - !CosineDecay\n+ max_iters: 400000\n+ - !LinearWarmup\n+ start_factor: 0.33333\n+ steps: 2000\n+\n+OptimizerBuilder:\n+ optimizer:\n+ momentum: 0.9\n+ type: Momentum\n+ regularizer:\n+ factor: 0.0005\n+ type: L2\n+\n+TrainReader:\n+ inputs_def:\n+ image_shape: [3, 320, 320]\n+ fields: ['image', 'gt_bbox', 'gt_class']\n+ dataset:\n+ !COCODataSet\n+ dataset_dir: dataset/coco\n+ anno_path: annotations/instances_train2017.json\n+ image_dir: train2017\n+ sample_transforms:\n+ - !DecodeImage\n+ to_rgb: true\n+ - !RandomDistort\n+ brightness_lower: 0.875\n+ brightness_upper: 1.125\n+ is_order: true\n+ - !RandomExpand\n+ fill_value: [123.675, 116.28, 103.53]\n+ - !RandomCrop\n+ allow_no_crop: false\n+ - !NormalizeBox {}\n+ - !ResizeImage\n+ interp: 1\n+ target_size: 320\n+ use_cv2: false\n+ - !RandomFlipImage\n+ is_normalized: false\n+ - !NormalizeImage\n+ mean: [0.485, 0.456, 0.406]\n+ std: [0.229, 0.224, 0.225]\n+ is_scale: true\n+ is_channel_first: false\n+ - !Permute\n+ to_bgr: false\n+ channel_first: true\n+ batch_size: 64\n+ shuffle: true\n+ drop_last: true\n+ # Number of working threads/processes. To speed up, can be set to 16 or 32 etc.\n+ worker_num: 8\n+ # Size of shared memory used in result queue. After increasing `worker_num`, need expand `memsize`.\n+ memsize: 8G\n+ # Buffer size for multi threads/processes.one instance in buffer is one batch data.\n+ # To speed up, can be set to 64 or 128 etc.\n+ bufsize: 32\n+ use_process: true\n+\n+\n+EvalReader:\n+ inputs_def:\n+ image_shape: [3, 320, 320]\n+ fields: ['image', 'gt_bbox', 'gt_class', 'im_shape', 'im_id']\n+ dataset:\n+ !COCODataSet\n+ dataset_dir: dataset/coco\n+ anno_path: annotations/instances_val2017.json\n+ image_dir: val2017\n+ sample_transforms:\n+ - !DecodeImage\n+ to_rgb: true\n+ - !NormalizeBox {}\n+ - !ResizeImage\n+ interp: 1\n+ target_size: 320\n+ use_cv2: false\n+ - !NormalizeImage\n+ mean: [0.485, 0.456, 0.406]\n+ std: [0.229, 0.224, 0.225]\n+ is_scale: true\n+ is_channel_first: false\n+ - !Permute\n+ to_bgr: false\n+ channel_first: True\n+ batch_size: 8\n+ worker_num: 8\n+ bufsize: 32\n+ use_process: false\n+\n+TestReader:\n+ inputs_def:\n+ image_shape: [3,320,320]\n+ fields: ['image', 'im_id', 'im_shape']\n+ dataset:\n+ !ImageFolder\n+ anno_path: annotations/instances_val2017.json\n+ sample_transforms:\n+ - !DecodeImage\n+ to_rgb: true\n+ - !ResizeImage\n+ interp: 1\n+ max_size: 0\n+ target_size: 320\n+ use_cv2: false\n+ - !NormalizeImage\n+ mean: [0.485, 0.456, 0.406]\n+ std: [0.229, 0.224, 0.225]\n+ is_scale: true\n+ is_channel_first: false\n+ - !Permute\n+ to_bgr: false\n+ channel_first: True\n+ batch_size: 1\n" }, { "change_type": "MODIFY", "old_path": "docs/MODEL_ZOO.md", "new_path": "docs/MODEL_ZOO.md", "diff": "@@ -200,6 +200,7 @@ results of image size 608/416/320 above. Deformable conv is added on stage 5 of\n| MobileNet_v3 large | 320 | 64 | Cosine decay(40w) | - | 23.3 | [model](https://paddlemodels.bj.bcebos.com/object_detection/mobile_models/ssdlite_mobilenet_v3_large.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/ssd/ssdlite_mobilenet_v3_large.yml) |\n| MobileNet_v3 small w/ FPN | 320 | 64 | Cosine decay(40w) | - | 18.9 | [model](https://paddlemodels.bj.bcebos.com/object_detection/mobile_models/ssdlite_mobilenet_v3_small_fpn.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/ssd/ssdlite_mobilenet_v3_small_fpn.yml) |\n| MobileNet_v3 large w/ FPN | 320 | 64 | Cosine decay(40w) | - | 24.3 | [model](https://paddlemodels.bj.bcebos.com/object_detection/mobile_models/ssdlite_mobilenet_v3_large_fpn.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/ssd/ssdlite_mobilenet_v3_large_fpn.yml) |\n+| GhostNet | 320 | 64 | Cosine decay(40w) | - | 23.3 | [model](htts://paddlemodels.bj.bcebos.com/object_detection/mobile_models/ssdlite_ghostnet.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/ssd/ssdlite_ghostnet.yml) |\n**Notes:** `SSDLite` is trained in 8 GPU with total batch size as 512 and uses cosine decay strategy to train.\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/backbones/__init__.py", "new_path": "ppdet/modeling/backbones/__init__.py", "diff": "@@ -34,6 +34,7 @@ from . import efficientnet\nfrom . import bifpn\nfrom . import cspdarknet\nfrom . import acfpn\n+from . import ghostnet\nfrom .resnet import *\nfrom .resnext import *\n@@ -55,3 +56,4 @@ from .efficientnet import *\nfrom .bifpn import *\nfrom .cspdarknet import *\nfrom .acfpn import *\n+from .ghostnet import *\n" }, { "change_type": "ADD", "old_path": null, "new_path": "ppdet/modeling/backbones/ghostnet.py", "diff": "+# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+# http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+\n+from __future__ import absolute_import\n+from __future__ import division\n+from __future__ import print_function\n+\n+import math\n+\n+import paddle.fluid as fluid\n+from paddle.fluid.param_attr import ParamAttr\n+from paddle.fluid.regularizer import L2Decay\n+\n+from collections import OrderedDict\n+\n+from ppdet.core.workspace import register\n+\n+__all__ = [\"GhostNet\"]\n+\n+\n+@register\n+class GhostNet(object):\n+ \"\"\"\n+ scale (float): scaling factor for convolution groups proportion of GhostNet.\n+ feature_maps (list): index of stages whose feature maps are returned.\n+ conv_decay (float): weight decay for convolution layer weights.\n+ extra_block_filters (list): number of filter for each extra block.\n+ lr_mult_list (list): learning rate ratio of different blocks, lower learning rate ratio\n+ is need for pretrained model got using distillation(default as\n+ [1.0, 1.0, 1.0, 1.0, 1.0]).\n+ \"\"\"\n+\n+ def __init__(\n+ self,\n+ scale,\n+ feature_maps=[5, 6, 7, 8, 9, 10],\n+ conv_decay=0.00001,\n+ extra_block_filters=[[256, 512], [128, 256], [128, 256], [64, 128]],\n+ lr_mult_list=[1.0, 1.0, 1.0, 1.0, 1.0],\n+ freeze_norm=False):\n+ self.scale = scale\n+ self.feature_maps = feature_maps\n+ self.extra_block_filters = extra_block_filters\n+ self.end_points = []\n+ self.block_stride = 0\n+ self.conv_decay = conv_decay\n+ self.lr_mult_list = lr_mult_list\n+ self.freeze_norm = freeze_norm\n+ self.curr_stage = 0\n+\n+ self.cfgs = [\n+ # k, t, c, se, s\n+ [3, 16, 16, 0, 1],\n+ [3, 48, 24, 0, 2],\n+ [3, 72, 24, 0, 1],\n+ [5, 72, 40, 1, 2],\n+ [5, 120, 40, 1, 1],\n+ [3, 240, 80, 0, 2],\n+ [3, 200, 80, 0, 1],\n+ [3, 184, 80, 0, 1],\n+ [3, 184, 80, 0, 1],\n+ [3, 480, 112, 1, 1],\n+ [3, 672, 112, 1, 1],\n+ [5, 672, 160, 1, 2],\n+ [5, 960, 160, 0, 1],\n+ [5, 960, 160, 1, 1],\n+ [5, 960, 160, 0, 1],\n+ [5, 960, 160, 1, 1]\n+ ]\n+\n+ def _conv_bn_layer(self,\n+ input,\n+ num_filters,\n+ filter_size,\n+ stride=1,\n+ groups=1,\n+ act=None,\n+ name=None):\n+ lr_idx = self.curr_stage // 3\n+ lr_idx = min(lr_idx, len(self.lr_mult_list) - 1)\n+ lr_mult = self.lr_mult_list[lr_idx]\n+ norm_lr = 0. if self.freeze_norm else lr_mult\n+\n+ x = fluid.layers.conv2d(\n+ input=input,\n+ num_filters=num_filters,\n+ filter_size=filter_size,\n+ stride=stride,\n+ padding=(filter_size - 1) // 2,\n+ groups=groups,\n+ act=None,\n+ param_attr=ParamAttr(\n+ regularizer=L2Decay(self.conv_decay),\n+ learning_rate=lr_mult,\n+ initializer=fluid.initializer.MSRA(),\n+ name=name + \"_weights\"),\n+ bias_attr=False)\n+ bn_name = name + \"_bn\"\n+ x = fluid.layers.batch_norm(\n+ input=x,\n+ act=act,\n+ param_attr=ParamAttr(\n+ name=bn_name + \"_scale\",\n+ learning_rate=norm_lr,\n+ regularizer=L2Decay(0.0)),\n+ bias_attr=ParamAttr(\n+ name=bn_name + \"_offset\",\n+ learning_rate=norm_lr,\n+ regularizer=L2Decay(0.0)),\n+ moving_mean_name=bn_name + \"_mean\",\n+ moving_variance_name=name + \"_variance\")\n+ return x\n+\n+ def se_block(self, input, num_channels, reduction_ratio=4, name=None):\n+ lr_idx = self.curr_stage // 3\n+ lr_idx = min(lr_idx, len(self.lr_mult_list) - 1)\n+ lr_mult = self.lr_mult_list[lr_idx]\n+ pool = fluid.layers.pool2d(\n+ input=input, pool_type='avg', global_pooling=True, use_cudnn=False)\n+ stdv = 1.0 / math.sqrt(pool.shape[1] * 1.0)\n+ squeeze = fluid.layers.fc(\n+ input=pool,\n+ size=num_channels // reduction_ratio,\n+ act='relu',\n+ param_attr=ParamAttr(\n+ learning_rate=lr_mult,\n+ initializer=fluid.initializer.Uniform(-stdv, stdv),\n+ name=name + '_1_weights'),\n+ bias_attr=ParamAttr(\n+ name=name + '_1_offset', learning_rate=lr_mult))\n+ stdv = 1.0 / math.sqrt(squeeze.shape[1] * 1.0)\n+ excitation = fluid.layers.fc(\n+ input=squeeze,\n+ size=num_channels,\n+ act=None,\n+ param_attr=ParamAttr(\n+ learning_rate=lr_mult,\n+ initializer=fluid.initializer.Uniform(-stdv, stdv),\n+ name=name + '_2_weights'),\n+ bias_attr=ParamAttr(\n+ name=name + '_2_offset', learning_rate=lr_mult))\n+ excitation = fluid.layers.clip(x=excitation, min=0, max=1)\n+ se_scale = fluid.layers.elementwise_mul(x=input, y=excitation, axis=0)\n+ return se_scale\n+\n+ def depthwise_conv(self,\n+ input,\n+ output,\n+ kernel_size,\n+ stride=1,\n+ relu=False,\n+ name=None):\n+ return self._conv_bn_layer(\n+ input=input,\n+ num_filters=output,\n+ filter_size=kernel_size,\n+ stride=stride,\n+ groups=input.shape[1],\n+ act=\"relu\" if relu else None,\n+ name=name + \"_depthwise\")\n+\n+ def ghost_module(self,\n+ input,\n+ output,\n+ kernel_size=1,\n+ ratio=2,\n+ dw_size=3,\n+ stride=1,\n+ relu=True,\n+ name=None):\n+ self.output = output\n+ init_channels = int(math.ceil(output / ratio))\n+ new_channels = int(init_channels * (ratio - 1))\n+ primary_conv = self._conv_bn_layer(\n+ input=input,\n+ num_filters=init_channels,\n+ filter_size=kernel_size,\n+ stride=stride,\n+ groups=1,\n+ act=\"relu\" if relu else None,\n+ name=name + \"_primary_conv\")\n+ cheap_operation = self._conv_bn_layer(\n+ input=primary_conv,\n+ num_filters=new_channels,\n+ filter_size=dw_size,\n+ stride=1,\n+ groups=init_channels,\n+ act=\"relu\" if relu else None,\n+ name=name + \"_cheap_operation\")\n+ out = fluid.layers.concat([primary_conv, cheap_operation], axis=1)\n+ return out\n+\n+ def ghost_bottleneck(self,\n+ input,\n+ hidden_dim,\n+ output,\n+ kernel_size,\n+ stride,\n+ use_se,\n+ name=None):\n+ inp_channels = input.shape[1]\n+ x = self.ghost_module(\n+ input=input,\n+ output=hidden_dim,\n+ kernel_size=1,\n+ stride=1,\n+ relu=True,\n+ name=name + \"_ghost_module_1\")\n+\n+ if self.block_stride == 4 and stride == 2:\n+ self.block_stride += 1\n+ if self.block_stride in self.feature_maps:\n+ self.end_points.append(x)\n+\n+ if stride == 2:\n+ x = self.depthwise_conv(\n+ input=x,\n+ output=hidden_dim,\n+ kernel_size=kernel_size,\n+ stride=stride,\n+ relu=False,\n+ name=name + \"_depthwise\")\n+ if use_se:\n+ x = self.se_block(\n+ input=x, num_channels=hidden_dim, name=name + \"_se\")\n+ x = self.ghost_module(\n+ input=x,\n+ output=output,\n+ kernel_size=1,\n+ relu=False,\n+ name=name + \"_ghost_module_2\")\n+ if stride == 1 and inp_channels == output:\n+ shortcut = input\n+ else:\n+ shortcut = self.depthwise_conv(\n+ input=input,\n+ output=inp_channels,\n+ kernel_size=kernel_size,\n+ stride=stride,\n+ relu=False,\n+ name=name + \"_shortcut_depthwise\")\n+ shortcut = self._conv_bn_layer(\n+ input=shortcut,\n+ num_filters=output,\n+ filter_size=1,\n+ stride=1,\n+ groups=1,\n+ act=None,\n+ name=name + \"_shortcut_conv\")\n+ return fluid.layers.elementwise_add(x=x, y=shortcut, axis=-1)\n+\n+ def _extra_block_dw(self,\n+ input,\n+ num_filters1,\n+ num_filters2,\n+ stride,\n+ name=None):\n+ pointwise_conv = self._conv_bn_layer(\n+ input=input,\n+ filter_size=1,\n+ num_filters=int(num_filters1),\n+ stride=1,\n+ act='relu6',\n+ name=name + \"_extra1\")\n+ depthwise_conv = self._conv_bn_layer(\n+ input=pointwise_conv,\n+ filter_size=3,\n+ num_filters=int(num_filters2),\n+ stride=stride,\n+ groups=int(num_filters1),\n+ act='relu6',\n+ name=name + \"_extra2_dw\")\n+ normal_conv = self._conv_bn_layer(\n+ input=depthwise_conv,\n+ filter_size=1,\n+ num_filters=int(num_filters2),\n+ stride=1,\n+ act='relu6',\n+ name=name + \"_extra2_sep\")\n+ return normal_conv\n+\n+ def _make_divisible(self, v, divisor=8, min_value=None):\n+ if min_value is None:\n+ min_value = divisor\n+ new_v = max(min_value, int(v + divisor / 2) // divisor * divisor)\n+ if new_v < 0.9 * v:\n+ new_v += divisor\n+ return new_v\n+\n+ def __call__(self, input):\n+ # build first layer\n+ output_channel = int(self._make_divisible(16 * self.scale, 4))\n+ x = self._conv_bn_layer(\n+ input=input,\n+ num_filters=output_channel,\n+ filter_size=3,\n+ stride=2,\n+ groups=1,\n+ act=\"relu\",\n+ name=\"conv1\")\n+ # build inverted residual blocks\n+ idx = 0\n+ for k, exp_size, c, use_se, s in self.cfgs:\n+ if s == 2:\n+ self.block_stride += 1\n+ if self.block_stride in self.feature_maps:\n+ self.end_points.append(x)\n+ output_channel = int(self._make_divisible(c * self.scale, 4))\n+ hidden_channel = int(self._make_divisible(exp_size * self.scale, 4))\n+ x = self.ghost_bottleneck(\n+ input=x,\n+ hidden_dim=hidden_channel,\n+ output=output_channel,\n+ kernel_size=k,\n+ stride=s,\n+ use_se=use_se,\n+ name=\"_ghostbottleneck_\" + str(idx))\n+ idx += 1\n+ self.curr_stage += 1\n+ self.block_stride += 1\n+ if self.block_stride in self.feature_maps:\n+ self.end_points.append(conv)\n+\n+ # extra block\n+ # check whether conv_extra is needed\n+ if self.block_stride < max(self.feature_maps):\n+ conv_extra = self._conv_bn_layer(\n+ x,\n+ num_filters=self._make_divisible(self.scale * self.cfgs[-1][1]),\n+ filter_size=1,\n+ stride=1,\n+ groups=1,\n+ act='relu6',\n+ name='conv' + str(idx + 2))\n+ self.block_stride += 1\n+ if self.block_stride in self.feature_maps:\n+ self.end_points.append(conv_extra)\n+ idx += 1\n+ for block_filter in self.extra_block_filters:\n+ conv_extra = self._extra_block_dw(conv_extra, block_filter[0],\n+ block_filter[1], 2,\n+ 'conv' + str(idx + 2))\n+ self.block_stride += 1\n+ if self.block_stride in self.feature_maps:\n+ self.end_points.append(conv_extra)\n+ idx += 1\n+\n+ return OrderedDict([('ghost_{}'.format(idx), feat)\n+ for idx, feat in enumerate(self.end_points)])\n+ return res\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
add ssdlite-ghostnet model (#1133)
499,304
18.08.2020 13:41:54
-28,800
10212b49f0b1205ce9e7ad177b6d1e58faea9acc
add faster_r34_fpn_1x model
[ { "change_type": "ADD", "old_path": null, "new_path": "configs/faster_rcnn_r34_fpn_1x.yml", "diff": "+architecture: FasterRCNN\n+max_iters: 90000\n+use_gpu: true\n+snapshot_iter: 10000\n+log_smooth_window: 20\n+save_dir: output\n+pretrain_weights: ResNet34_pretrained\n+metric: COCO\n+weights: output/faster_rcnn_r34_fpn_1x/model_final\n+num_classes: 81\n+\n+FasterRCNN:\n+ backbone: ResNet\n+ fpn: FPN\n+ rpn_head: FPNRPNHead\n+ roi_extractor: FPNRoIAlign\n+ bbox_head: BBoxHead\n+ bbox_assigner: BBoxAssigner\n+\n+ResNet:\n+ norm_type: bn\n+ norm_decay: 0.\n+ depth: 34\n+ feature_maps: [2, 3, 4, 5]\n+ freeze_at: 2\n+\n+FPN:\n+ min_level: 2\n+ max_level: 6\n+ num_chan: 256\n+ spatial_scale: [0.03125, 0.0625, 0.125, 0.25]\n+\n+FPNRPNHead:\n+ anchor_generator:\n+ anchor_sizes: [32, 64, 128, 256, 512]\n+ aspect_ratios: [0.5, 1.0, 2.0]\n+ stride: [16.0, 16.0]\n+ variance: [1.0, 1.0, 1.0, 1.0]\n+ anchor_start_size: 32\n+ min_level: 2\n+ max_level: 6\n+ num_chan: 256\n+ rpn_target_assign:\n+ rpn_batch_size_per_im: 256\n+ rpn_fg_fraction: 0.5\n+ rpn_positive_overlap: 0.7\n+ rpn_negative_overlap: 0.3\n+ rpn_straddle_thresh: 0.0\n+ train_proposal:\n+ min_size: 0.0\n+ nms_thresh: 0.7\n+ pre_nms_top_n: 2000\n+ post_nms_top_n: 2000\n+ test_proposal:\n+ min_size: 0.0\n+ nms_thresh: 0.7\n+ pre_nms_top_n: 1000\n+ post_nms_top_n: 1000\n+\n+FPNRoIAlign:\n+ canconical_level: 4\n+ canonical_size: 224\n+ min_level: 2\n+ max_level: 5\n+ box_resolution: 7\n+ sampling_ratio: 2\n+\n+BBoxAssigner:\n+ batch_size_per_im: 512\n+ bbox_reg_weights: [0.1, 0.1, 0.2, 0.2]\n+ bg_thresh_lo: 0.0\n+ bg_thresh_hi: 0.5\n+ fg_fraction: 0.25\n+ fg_thresh: 0.5\n+\n+BBoxHead:\n+ head: TwoFCHead\n+ nms:\n+ keep_top_k: 100\n+ nms_threshold: 0.5\n+ score_threshold: 0.05\n+\n+TwoFCHead:\n+ mlp_dim: 1024\n+\n+LearningRate:\n+ base_lr: 0.02\n+ schedulers:\n+ - !PiecewiseDecay\n+ gamma: 0.1\n+ milestones: [60000, 80000]\n+ - !LinearWarmup\n+ start_factor: 0.1\n+ steps: 1000\n+\n+OptimizerBuilder:\n+ optimizer:\n+ momentum: 0.9\n+ type: Momentum\n+ regularizer:\n+ factor: 0.0001\n+ type: L2\n+\n+_READER_: 'faster_fpn_reader.yml'\n+TrainReader:\n+ batch_size: 2\n" }, { "change_type": "ADD", "old_path": null, "new_path": "configs/faster_rcnn_r34_vd_fpn_1x.yml", "diff": "+architecture: FasterRCNN\n+max_iters: 90000\n+use_gpu: true\n+snapshot_iter: 10000\n+log_smooth_window: 20\n+save_dir: output\n+pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet34_vd_pretrained.tar\n+metric: COCO\n+weights: output/faster_rcnn_r34_fpn_1x/model_final\n+num_classes: 81\n+\n+FasterRCNN:\n+ backbone: ResNet\n+ fpn: FPN\n+ rpn_head: FPNRPNHead\n+ roi_extractor: FPNRoIAlign\n+ bbox_head: BBoxHead\n+ bbox_assigner: BBoxAssigner\n+\n+ResNet:\n+ norm_type: bn\n+ norm_decay: 0.\n+ depth: 34\n+ feature_maps: [2, 3, 4, 5]\n+ freeze_at: 2\n+ variant: d\n+\n+FPN:\n+ min_level: 2\n+ max_level: 6\n+ num_chan: 256\n+ spatial_scale: [0.03125, 0.0625, 0.125, 0.25]\n+\n+FPNRPNHead:\n+ anchor_generator:\n+ anchor_sizes: [32, 64, 128, 256, 512]\n+ aspect_ratios: [0.5, 1.0, 2.0]\n+ stride: [16.0, 16.0]\n+ variance: [1.0, 1.0, 1.0, 1.0]\n+ anchor_start_size: 32\n+ min_level: 2\n+ max_level: 6\n+ num_chan: 256\n+ rpn_target_assign:\n+ rpn_batch_size_per_im: 256\n+ rpn_fg_fraction: 0.5\n+ rpn_positive_overlap: 0.7\n+ rpn_negative_overlap: 0.3\n+ rpn_straddle_thresh: 0.0\n+ train_proposal:\n+ min_size: 0.0\n+ nms_thresh: 0.7\n+ pre_nms_top_n: 2000\n+ post_nms_top_n: 2000\n+ test_proposal:\n+ min_size: 0.0\n+ nms_thresh: 0.7\n+ pre_nms_top_n: 1000\n+ post_nms_top_n: 1000\n+\n+FPNRoIAlign:\n+ canconical_level: 4\n+ canonical_size: 224\n+ min_level: 2\n+ max_level: 5\n+ box_resolution: 7\n+ sampling_ratio: 2\n+\n+BBoxAssigner:\n+ batch_size_per_im: 512\n+ bbox_reg_weights: [0.1, 0.1, 0.2, 0.2]\n+ bg_thresh_lo: 0.0\n+ bg_thresh_hi: 0.5\n+ fg_fraction: 0.25\n+ fg_thresh: 0.5\n+\n+BBoxHead:\n+ head: TwoFCHead\n+ nms:\n+ keep_top_k: 100\n+ nms_threshold: 0.5\n+ score_threshold: 0.05\n+\n+TwoFCHead:\n+ mlp_dim: 1024\n+\n+LearningRate:\n+ base_lr: 0.02\n+ schedulers:\n+ - !PiecewiseDecay\n+ gamma: 0.1\n+ milestones: [60000, 80000]\n+ - !LinearWarmup\n+ start_factor: 0.1\n+ steps: 1000\n+\n+OptimizerBuilder:\n+ optimizer:\n+ momentum: 0.9\n+ type: Momentum\n+ regularizer:\n+ factor: 0.0001\n+ type: L2\n+\n+_READER_: 'faster_fpn_reader.yml'\n+TrainReader:\n+ batch_size: 2\n" }, { "change_type": "MODIFY", "old_path": "docs/MODEL_ZOO.md", "new_path": "docs/MODEL_ZOO.md", "diff": "@@ -41,6 +41,8 @@ The backbone models pretrained on ImageNet are available. All backbone models ar\n| ResNet50 | Mask | 1 | 1x | 11.615 | 36.5 | 32.2 | [model](https://paddlemodels.bj.bcebos.com/object_detection/mask_rcnn_r50_1x.tar) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/mask_rcnn_r50_1x.yml) |\n| ResNet50 | Mask | 1 | 2x | 11.494 | 38.2 | 33.4 | [model](https://paddlemodels.bj.bcebos.com/object_detection/mask_rcnn_r50_2x.tar) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/mask_rcnn_r50_2x.yml) |\n| ResNet50-vd | Faster | 1 | 1x | 12.575 | 36.4 | - | [model](https://paddlemodels.bj.bcebos.com/object_detection/faster_rcnn_r50_vd_1x.tar) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/faster_rcnn_r50_vd_1x.yml) |\n+| ResNet34-FPN | Faster | 2 | 1x | - | 36.7 | - | [model](https://paddlemodels.bj.bcebos.com/object_detection/faster_rcnn_r34_fpn_1x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/faster_rcnn_r34_fpn_1x.yml) |\n+| ResNet34-vd-FPN | Faster | 2 | 1x | - | 37.4 | - | [model](https://paddlemodels.bj.bcebos.com/object_detection/faster_rcnn_r34_vd_fpn_1x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/faster_rcnn_r34_vd_fpn_1x.yml) |\n| ResNet50-FPN | Faster | 2 | 1x | 22.273 | 37.2 | - | [model](https://paddlemodels.bj.bcebos.com/object_detection/faster_rcnn_r50_fpn_1x.tar) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/faster_rcnn_r50_fpn_1x.yml) |\n| ResNet50-FPN | Faster | 2 | 2x | 22.297 | 37.7 | - | [model](https://paddlemodels.bj.bcebos.com/object_detection/faster_rcnn_r50_fpn_2x.tar) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/faster_rcnn_r50_fpn_2x.yml) |\n| ResNet50-FPN | Mask | 1 | 1x | 15.184 | 37.9 | 34.2 | [model](https://paddlemodels.bj.bcebos.com/object_detection/mask_rcnn_r50_fpn_1x.tar) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/mask_rcnn_r50_fpn_1x.yml) |\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
add faster_r34_fpn_1x model (#1230)
499,313
18.08.2020 15:44:52
-28,800
4229a94947870a9ddd054fd94b82ac9d49d9ef9d
fix training hang in PaddleCloud single machine.
[ { "change_type": "MODIFY", "old_path": "tools/train.py", "new_path": "tools/train.py", "diff": "@@ -53,7 +53,9 @@ logger = logging.getLogger(__name__)\ndef main():\nenv = os.environ\n- FLAGS.dist = 'PADDLE_TRAINER_ID' in env and 'PADDLE_TRAINERS_NUM' in env\n+ FLAGS.dist = 'PADDLE_TRAINER_ID' in env \\\n+ and 'PADDLE_TRAINERS_NUM' in env \\\n+ and int(env['PADDLE_TRAINERS_NUM']) > 1\nif FLAGS.dist:\ntrainer_id = int(env['PADDLE_TRAINER_ID'])\nlocal_seed = (99 + trainer_id)\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix training hang in PaddleCloud single machine. (#1232)
499,313
18.08.2020 20:53:18
-28,800
c1c537b77e897a57fc2b6d93b527b1a1ae2557a5
fix diou_loss_yolo.py scale_x_y & eps not set
[ { "change_type": "MODIFY", "old_path": "ppdet/modeling/losses/diou_loss_yolo.py", "new_path": "ppdet/modeling/losses/diou_loss_yolo.py", "diff": "@@ -65,9 +65,10 @@ class DiouLossYolo(IouLoss):\neps (float): the decimal to prevent the denominator eqaul zero\n'''\nx1, y1, x2, y2 = self._bbox_transform(\n- x, y, w, h, anchors, downsample_ratio, batch_size, False)\n- x1g, y1g, x2g, y2g = self._bbox_transform(\n- tx, ty, tw, th, anchors, downsample_ratio, batch_size, True)\n+ x, y, w, h, anchors, downsample_ratio, batch_size, False, 1.0, eps)\n+ x1g, y1g, x2g, y2g = self._bbox_transform(tx, ty, tw, th, anchors,\n+ downsample_ratio, batch_size,\n+ True, 1.0, eps)\n#central coordinates\ncx = (x1 + x2) / 2\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix diou_loss_yolo.py scale_x_y & eps not set (#1239)
499,333
19.08.2020 11:05:44
-28,800
4fc516d25882727e80d9cd17a45196d8b9433d34
update elementwise api in fcos
[ { "change_type": "MODIFY", "old_path": "ppdet/modeling/losses/fcos_loss.py", "new_path": "ppdet/modeling/losses/fcos_loss.py", "diff": "@@ -76,14 +76,14 @@ class FCOSLoss(object):\nReturn:\nloss (Varialbes): location loss\n\"\"\"\n- plw = pred[:, 0] * positive_mask\n- pth = pred[:, 1] * positive_mask\n- prw = pred[:, 2] * positive_mask\n- pbh = pred[:, 3] * positive_mask\n- tlw = targets[:, 0] * positive_mask\n- tth = targets[:, 1] * positive_mask\n- trw = targets[:, 2] * positive_mask\n- tbh = targets[:, 3] * positive_mask\n+ plw = fluid.layers.elementwise_mul(pred[:, 0], positive_mask, axis=0)\n+ pth = fluid.layers.elementwise_mul(pred[:, 1], positive_mask, axis=0)\n+ prw = fluid.layers.elementwise_mul(pred[:, 2], positive_mask, axis=0)\n+ pbh = fluid.layers.elementwise_mul(pred[:, 3], positive_mask, axis=0)\n+ tlw = fluid.layers.elementwise_mul(targets[:, 0], positive_mask, axis=0)\n+ tth = fluid.layers.elementwise_mul(targets[:, 1], positive_mask, axis=0)\n+ trw = fluid.layers.elementwise_mul(targets[:, 2], positive_mask, axis=0)\n+ tbh = fluid.layers.elementwise_mul(targets[:, 3], positive_mask, axis=0)\ntlw.stop_gradient = True\ntrw.stop_gradient = True\ntth.stop_gradient = True\n@@ -101,7 +101,7 @@ class FCOSLoss(object):\narea_inter = (ilw + irw) * (ith + ibh)\nious = (area_inter + 1.0) / (\narea_predict + area_target - area_inter + 1.0)\n- ious = ious * positive_mask\n+ ious = fluid.layers.elementwise_mul(ious, positive_mask, axis=0)\nif self.iou_loss_type.lower() == \"linear_iou\":\nloss = 1.0 - ious\nelif self.iou_loss_type.lower() == \"giou\":\n@@ -187,16 +187,20 @@ class FCOSLoss(object):\nnormalize_sum.stop_gradient = True\nnormalize_sum = fluid.layers.reduce_sum(mask_positive_float *\nnormalize_sum)\n+\nnormalize_sum.stop_gradient = True\ncls_loss = fluid.layers.sigmoid_focal_loss(\ncls_logits_flatten, tag_labels_flatten,\nnum_positive_int32) / num_positive_fp32\n- reg_loss = self.__iou_loss(\n- bboxes_reg_flatten, tag_bboxes_flatten, mask_positive_float,\n- tag_center_flatten) * mask_positive_float / normalize_sum\n+ reg_loss = self.__iou_loss(bboxes_reg_flatten, tag_bboxes_flatten,\n+ mask_positive_float, tag_center_flatten)\n+ reg_loss = fluid.layers.elementwise_mul(\n+ reg_loss, mask_positive_float, axis=0) / normalize_sum\nctn_loss = fluid.layers.sigmoid_cross_entropy_with_logits(\nx=centerness_flatten,\nlabel=tag_center_flatten) * mask_positive_float / num_positive_fp32\n+ ctn_loss = fluid.layers.elementwise_mul(\n+ ctn_loss, mask_positive_float, axis=0) / normalize_sum\nloss_all = {\n\"loss_centerness\": fluid.layers.reduce_sum(ctn_loss),\n\"loss_cls\": fluid.layers.reduce_sum(cls_loss),\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
update elementwise api in fcos (#1245)
499,313
19.08.2020 14:50:49
-28,800
a77455bc7267c364251245475f642ace0a46531e
remove useless is_test in yolo_head.py
[ { "change_type": "MODIFY", "old_path": "ppdet/modeling/anchor_heads/yolo_head.py", "new_path": "ppdet/modeling/anchor_heads/yolo_head.py", "diff": "@@ -154,7 +154,6 @@ class YOLOv3Head(object):\nstride,\npadding,\nact='leaky',\n- is_test=True,\nname=None):\nconv = fluid.layers.conv2d(\ninput=input,\n@@ -174,7 +173,6 @@ class YOLOv3Head(object):\nout = fluid.layers.batch_norm(\ninput=conv,\nact=None,\n- is_test=is_test,\nparam_attr=bn_param_attr,\nbias_attr=bn_bias_attr,\nmoving_mean_name=bn_name + '.mean',\n@@ -184,7 +182,7 @@ class YOLOv3Head(object):\nout = fluid.layers.leaky_relu(x=out, alpha=0.1)\nreturn out\n- def _spp_module(self, input, is_test=True, name=\"\"):\n+ def _spp_module(self, input, name=\"\"):\noutput1 = input\noutput2 = fluid.layers.pool2d(\ninput=output1,\n@@ -231,17 +229,15 @@ class YOLOv3Head(object):\nfilter_size=1,\nstride=1,\npadding=0,\n- is_test=is_test,\nname='{}.{}.0'.format(name, j))\nif self.use_spp and is_first and j == 1:\n- conv = self._spp_module(conv, is_test=is_test, name=\"spp\")\n+ conv = self._spp_module(conv, name=\"spp\")\nconv = self._conv_bn(\nconv,\n512,\nfilter_size=1,\nstride=1,\npadding=0,\n- is_test=is_test,\nname='{}.{}.spp.conv'.format(name, j))\nconv = self._conv_bn(\nconv,\n@@ -249,7 +245,6 @@ class YOLOv3Head(object):\nfilter_size=3,\nstride=1,\npadding=1,\n- is_test=is_test,\nname='{}.{}.1'.format(name, j))\nif self.drop_block and j == 0 and not is_first:\nconv = DropBlock(\n@@ -271,7 +266,6 @@ class YOLOv3Head(object):\nfilter_size=1,\nstride=1,\npadding=0,\n- is_test=is_test,\nname='{}.2'.format(name))\nnew_route = self._add_coord(route, is_test=is_test)\ntip = self._conv_bn(\n@@ -280,7 +274,6 @@ class YOLOv3Head(object):\nfilter_size=3,\nstride=1,\npadding=1,\n- is_test=is_test,\nname='{}.tip'.format(name))\nreturn route, tip\n@@ -371,7 +364,6 @@ class YOLOv3Head(object):\nfilter_size=1,\nstride=1,\npadding=0,\n- is_test=(not is_train),\nname=self.prefix_name + \"yolo_transition.{}\".format(i))\n# upsample\nroute = self._upsample(route)\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
remove useless is_test in yolo_head.py (#1250)
499,304
19.08.2020 17:31:38
-28,800
3268ed1f774e3587ffa28d1802d5165c6727e495
fix faceboxes steps in prior_box
[ { "change_type": "MODIFY", "old_path": "ppdet/modeling/architectures/faceboxes.py", "new_path": "ppdet/modeling/architectures/faceboxes.py", "diff": "@@ -56,7 +56,7 @@ class FaceBoxes(object):\ndensities=[[4, 2, 1], [1], [1]],\nfixed_sizes=[[32., 64., 128.], [256.], [512.]],\nnum_classes=2,\n- steps=[16., 32., 64.]):\n+ steps=[8., 16., 32.]):\nsuper(FaceBoxes, self).__init__()\nself.backbone = backbone\nself.num_classes = num_classes\n@@ -117,7 +117,7 @@ class FaceBoxes(object):\nfixed_ratios=[1.],\nclip=False,\noffset=0.5,\n- steps=[self.steps[i]])\n+ steps=[self.steps[i]] * 2)\nnum_boxes = box.shape[2]\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix faceboxes steps in prior_box (#1255)
499,304
21.08.2020 15:40:12
-28,800
a30abac2c44a33f8a57c4f59007d3cac4d547bf1
fix use_cv2 of SSD in infer
[ { "change_type": "MODIFY", "old_path": "configs/ssd/ssd_mobilenet_v1_voc.yml", "new_path": "configs/ssd/ssd_mobilenet_v1_voc.yml", "diff": "@@ -134,7 +134,7 @@ TestReader:\ninterp: 1\nmax_size: 0\ntarget_size: 300\n- use_cv2: false\n+ use_cv2: true\n- !Permute {}\n- !NormalizeImage\nis_scale: false\n" }, { "change_type": "MODIFY", "old_path": "configs/ssd/ssd_vgg16_300.yml", "new_path": "configs/ssd/ssd_vgg16_300.yml", "diff": "@@ -140,7 +140,7 @@ TestReader:\ninterp: 1\nmax_size: 0\ntarget_size: 300\n- use_cv2: false\n+ use_cv2: true\n- !Permute\nto_bgr: false\n- !NormalizeImage\n" }, { "change_type": "MODIFY", "old_path": "configs/ssd/ssd_vgg16_300_voc.yml", "new_path": "configs/ssd/ssd_vgg16_300_voc.yml", "diff": "@@ -140,7 +140,7 @@ TestReader:\ninterp: 1\nmax_size: 0\ntarget_size: 300\n- use_cv2: false\n+ use_cv2: true\n- !Permute\nto_bgr: false\n- !NormalizeImage\n" }, { "change_type": "MODIFY", "old_path": "configs/ssd/ssd_vgg16_512.yml", "new_path": "configs/ssd/ssd_vgg16_512.yml", "diff": "@@ -142,7 +142,7 @@ TestReader:\ninterp: 1\nmax_size: 0\ntarget_size: 512\n- use_cv2: false\n+ use_cv2: true\n- !Permute\nto_bgr: false\n- !NormalizeImage\n" }, { "change_type": "MODIFY", "old_path": "configs/ssd/ssd_vgg16_512_voc.yml", "new_path": "configs/ssd/ssd_vgg16_512_voc.yml", "diff": "@@ -144,7 +144,7 @@ TestReader:\ninterp: 1\nmax_size: 0\ntarget_size: 512\n- use_cv2: false\n+ use_cv2: true\n- !Permute\nto_bgr: false\n- !NormalizeImage\n" }, { "change_type": "MODIFY", "old_path": "configs/ssd/ssdlite_ghostnet.yml", "new_path": "configs/ssd/ssdlite_ghostnet.yml", "diff": "@@ -150,7 +150,7 @@ TestReader:\ninterp: 1\nmax_size: 0\ntarget_size: 320\n- use_cv2: false\n+ use_cv2: true\n- !NormalizeImage\nmean: [0.485, 0.456, 0.406]\nstd: [0.229, 0.224, 0.225]\n" }, { "change_type": "MODIFY", "old_path": "configs/ssd/ssdlite_mobilenet_v1.yml", "new_path": "configs/ssd/ssdlite_mobilenet_v1.yml", "diff": "@@ -147,7 +147,7 @@ TestReader:\ninterp: 1\nmax_size: 0\ntarget_size: 300\n- use_cv2: false\n+ use_cv2: true\n- !NormalizeImage\nmean: [0.485, 0.456, 0.406]\nstd: [0.229, 0.224, 0.225]\n" }, { "change_type": "MODIFY", "old_path": "configs/ssd/ssdlite_mobilenet_v3_large.yml", "new_path": "configs/ssd/ssdlite_mobilenet_v3_large.yml", "diff": "@@ -151,7 +151,7 @@ TestReader:\ninterp: 1\nmax_size: 0\ntarget_size: 320\n- use_cv2: false\n+ use_cv2: true\n- !NormalizeImage\nmean: [0.485, 0.456, 0.406]\nstd: [0.229, 0.224, 0.225]\n" }, { "change_type": "MODIFY", "old_path": "configs/ssd/ssdlite_mobilenet_v3_large_fpn.yml", "new_path": "configs/ssd/ssdlite_mobilenet_v3_large_fpn.yml", "diff": "@@ -158,7 +158,7 @@ TestReader:\ninterp: 1\nmax_size: 0\ntarget_size: 320\n- use_cv2: false\n+ use_cv2: true\n- !NormalizeImage\nmean: [0.485, 0.456, 0.406]\nstd: [0.229, 0.224, 0.225]\n" }, { "change_type": "MODIFY", "old_path": "configs/ssd/ssdlite_mobilenet_v3_small.yml", "new_path": "configs/ssd/ssdlite_mobilenet_v3_small.yml", "diff": "@@ -151,7 +151,7 @@ TestReader:\ninterp: 1\nmax_size: 0\ntarget_size: 320\n- use_cv2: false\n+ use_cv2: true\n- !NormalizeImage\nmean: [0.485, 0.456, 0.406]\nstd: [0.229, 0.224, 0.225]\n" }, { "change_type": "MODIFY", "old_path": "configs/ssd/ssdlite_mobilenet_v3_small_fpn.yml", "new_path": "configs/ssd/ssdlite_mobilenet_v3_small_fpn.yml", "diff": "@@ -158,7 +158,7 @@ TestReader:\ninterp: 1\nmax_size: 0\ntarget_size: 320\n- use_cv2: false\n+ use_cv2: true\n- !NormalizeImage\nmean: [0.485, 0.456, 0.406]\nstd: [0.229, 0.224, 0.225]\n" }, { "change_type": "MODIFY", "old_path": "deploy/cpp/src/main.cc", "new_path": "deploy/cpp/src/main.cc", "diff": "@@ -25,6 +25,7 @@ DEFINE_string(model_dir, \"\", \"Path of inference model\");\nDEFINE_string(image_path, \"\", \"Path of input image\");\nDEFINE_string(video_path, \"\", \"Path of input video\");\nDEFINE_bool(use_gpu, false, \"Infering with GPU or CPU\");\n+DEFINE_bool(use_camera, false, \"Use camera or not\");\nDEFINE_string(run_mode, \"fluid\", \"Mode of running(fluid/trt_fp32/trt_fp16)\");\nDEFINE_int32(gpu_id, 0, \"Device id of GPU to execute\");\nDEFINE_int32(camera_id, -1, \"Device id of camera to predict\");\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix use_cv2 of SSD in infer (#1264)
499,313
24.08.2020 12:56:15
-28,800
3bc034aacca0f342ec09797eb0a73817db0caf1d
refine create_parameter to global_var to avoid saving to checkpoints
[ { "change_type": "MODIFY", "old_path": "ppdet/modeling/losses/iou_loss.py", "new_path": "ppdet/modeling/losses/iou_loss.py", "diff": "@@ -229,11 +229,7 @@ class IouLoss(object):\nreturn x1, y1, x2, y2\ndef _create_tensor_from_numpy(self, numpy_array):\n- paddle_array = fluid.layers.create_parameter(\n- attr=ParamAttr(),\n- shape=numpy_array.shape,\n- dtype=numpy_array.dtype,\n- default_initializer=NumpyArrayInitializer(numpy_array))\n- paddle_array.stop_gradient = True\n- paddle_array.persistable = False\n+ paddle_array = fluid.layers.create_global_var(\n+ shape=numpy_array.shape, value=0., dtype=numpy_array.dtype)\n+ fluid.layers.assign(numpy_array, paddle_array)\nreturn paddle_array\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
refine create_parameter to global_var to avoid saving to checkpoints (#1274)
499,395
27.08.2020 19:58:53
-28,800
e5605dd888b9c16883398eea1794ca1f559dc950
fix the problem of converting labelme to coco
[ { "change_type": "MODIFY", "old_path": "ppdet/data/tools/x2coco.py", "new_path": "ppdet/data/tools/x2coco.py", "diff": "@@ -154,17 +154,19 @@ def deal_json(ds_type, img_path, json_path):\ncategories_list.append(categories(label, labels_list))\nlabels_list.append(label)\nlabel_to_num[label] = len(labels_list)\n- points = shapes['points']\np_type = shapes['shape_type']\nif p_type == 'polygon':\n+ points = shapes['points']\nannotations_list.append(\nannotations_polygon(data['imageHeight'], data[\n'imageWidth'], points, label, image_num,\nobject_num, label_to_num))\nif p_type == 'rectangle':\n- points.append([points[0][0], points[1][1]])\n- points.append([points[1][0], points[0][1]])\n+ (x1, y1), (x2, y2) = shapes['points']\n+ x1, x2 = sorted([x1, x2])\n+ y1, y2 = sorted([y1, y2])\n+ points = [[x1, y1], [x2, y2], [x1, y2], [x2, y1]]\nannotations_list.append(\nannotations_rectangle(points, label, image_num,\nobject_num, label_to_num))\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix the problem of converting labelme to coco (#1296)
499,313
28.08.2020 12:04:38
-28,800
b9875f212bc5130e0517bccb766c696c36121f16
fix coord conv support h != w
[ { "change_type": "MODIFY", "old_path": "ppdet/modeling/anchor_heads/yolo_head.py", "new_path": "ppdet/modeling/anchor_heads/yolo_head.py", "diff": "@@ -125,8 +125,14 @@ class YOLOv3Head(object):\nx_range = self._create_tensor_from_numpy(gi_np.astype(np.float32))\nx_range.stop_gradient = True\n- y_range = self._create_tensor_from_numpy(\n- gi_np.transpose([0, 1, 3, 2]).astype(np.float32))\n+\n+ idx_j = np.array(\n+ [[j / (grid_y - 1) * 2.0 - 1 for j in range(grid_y)]],\n+ dtype='float32')\n+ gj_np = np.repeat(idx_j, grid_x, axis=1)\n+ gj_np = np.reshape(gj_np, newshape=[1, 1, grid_y, grid_x])\n+ gj_np = np.tile(gi_np, reps=[batch_size, 1, 1, 1])\n+ y_range = self._create_tensor_from_numpy(gj_np.astype(np.float32))\ny_range.stop_gradient = True\n# NOTE: in training mode, H and W is variable for random shape,\n@@ -142,7 +148,11 @@ class YOLOv3Head(object):\nx_range = fluid.layers.unsqueeze(x_range, [0, 1, 2])\nx_range = fluid.layers.expand(x_range, [b, 1, h, 1])\nx_range.stop_gradient = True\n- y_range = fluid.layers.transpose(x_range, [0, 1, 3, 2])\n+\n+ y_range = fluid.layers.range(0, h, 1, 'float32') / ((h - 1.) / 2.)\n+ y_range = y_range - 1.\n+ y_range = fluid.layers.unsqueeze(y_range, [0, 1, 3])\n+ y_range = fluid.layers.expand(y_range, [b, 1, 1, w])\ny_range.stop_gradient = True\nreturn fluid.layers.concat([input, x_range, y_range], axis=1)\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix coord conv support h != w (#1303)
499,304
30.08.2020 11:59:29
-28,800
29a91f30a7465c3254c56720e4d6ec2de34ace60
fix python path in export_serving_model.py
[ { "change_type": "MODIFY", "old_path": "tools/export_serving_model.py", "new_path": "tools/export_serving_model.py", "diff": "@@ -16,7 +16,11 @@ from __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n-import os\n+import os, sys\n+# add python path of PadleDetection to sys.path\n+parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2)))\n+if parent_path not in sys.path:\n+ sys.path.append(parent_path)\nfrom paddle import fluid\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix python path in export_serving_model.py (#1294)
499,304
31.08.2020 12:32:20
-28,800
a86705361cfecd6cea3f745117d4083634ccb354
fix has_empty condition in Reader
[ { "change_type": "MODIFY", "old_path": "ppdet/data/reader.py", "new_path": "ppdet/data/reader.py", "diff": "@@ -338,17 +338,17 @@ class Reader(object):\nsample[\"curr_iter\"] = self._curr_iter\nself._pos += 1\n- if self._drop_empty and self._fields and 'gt_mask' in self._fields:\n- if _has_empty(_segm(sample)):\n- #logger.warn('gt_mask is empty or not valid in {}'.format(\n- # sample['im_file']))\n- continue\n- if self._drop_empty and self._fields and 'gt_bbox' in self._fields:\n+ if self._drop_empty and self._fields and 'gt_bbox' in sample:\nif _has_empty(sample['gt_bbox']):\n#logger.warn('gt_bbox {} is empty or not valid in {}, '\n# 'drop this sample'.format(\n# sample['im_file'], sample['gt_bbox']))\ncontinue\n+ if self._drop_empty and self._fields and 'gt_poly' in sample:\n+ if _has_empty(_segm(sample)):\n+ #logger.warn('gt_mask is empty or not valid in {}'.format(\n+ # sample['im_file']))\n+ continue\nif self._load_img:\nsample['image'] = self._load_image(sample['im_file'])\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix has_empty condition in Reader (#1281)
499,333
01.09.2020 10:09:12
-28,800
25877ca329117bf9499ae9f831377cbf5ece280f
fix mixup & cutmix in multiprocessing
[ { "change_type": "MODIFY", "old_path": "ppdet/data/reader.py", "new_path": "ppdet/data/reader.py", "diff": "@@ -183,6 +183,7 @@ class Reader(object):\ninputs_def (dict): network input definition use to get input fields,\nwhich is used to determine the order of returned data.\ndevices_num (int): number of devices.\n+ num_trainers (int): number of trainers. Default 1.\n\"\"\"\ndef __init__(self,\n@@ -203,7 +204,8 @@ class Reader(object):\nbufsize=-1,\nmemsize='3G',\ninputs_def=None,\n- devices_num=1):\n+ devices_num=1,\n+ num_trainers=1):\nself._dataset = dataset\nself._roidbs = self._dataset.get_roidb()\nself._fields = copy.deepcopy(inputs_def[\n@@ -244,8 +246,8 @@ class Reader(object):\nself._drop_empty = drop_empty\n# sampling\n- self._mixup_epoch = mixup_epoch\n- self._cutmix_epoch = cutmix_epoch\n+ self._mixup_epoch = mixup_epoch // num_trainers\n+ self._cutmix_epoch = cutmix_epoch // num_trainers\nself._class_aware_sampling = class_aware_sampling\nself._load_img = False\n@@ -415,7 +417,11 @@ class Reader(object):\nself._parallel.stop()\n-def create_reader(cfg, max_iter=0, global_cfg=None, devices_num=1):\n+def create_reader(cfg,\n+ max_iter=0,\n+ global_cfg=None,\n+ devices_num=1,\n+ num_trainers=1):\n\"\"\"\nReturn iterable data reader.\n@@ -431,6 +437,7 @@ def create_reader(cfg, max_iter=0, global_cfg=None, devices_num=1):\n'use_fine_grained_loss', False)\ncfg['num_classes'] = getattr(global_cfg, 'num_classes', 80)\ncfg['devices_num'] = devices_num\n+ cfg['num_trainers'] = num_trainers\nreader = Reader(**cfg)()\ndef _reader():\n" }, { "change_type": "MODIFY", "old_path": "tools/train.py", "new_path": "tools/train.py", "diff": "@@ -56,6 +56,7 @@ def main():\nFLAGS.dist = 'PADDLE_TRAINER_ID' in env \\\nand 'PADDLE_TRAINERS_NUM' in env \\\nand int(env['PADDLE_TRAINERS_NUM']) > 1\n+ num_trainers = int(env.get('PADDLE_TRAINERS_NUM', 1))\nif FLAGS.dist:\ntrainer_id = int(env['PADDLE_TRAINER_ID'])\nlocal_seed = (99 + trainer_id)\n@@ -203,7 +204,8 @@ def main():\ntrain_reader = create_reader(\ncfg.TrainReader, (cfg.max_iters - start_iter) * devices_num,\ncfg,\n- devices_num=devices_num)\n+ devices_num=devices_num,\n+ num_trainers=num_trainers)\ntrain_loader.set_sample_list_generator(train_reader, place)\n# whether output bbox is normalized in model output layer\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix mixup & cutmix in multiprocessing (#1319)
499,318
01.09.2020 10:18:58
-28,800
1317022a0b73b53377ac5fa98bdb28b509e77ab4
fix the dtype of loss
[ { "change_type": "MODIFY", "old_path": "ppdet/modeling/anchor_heads/retina_head.py", "new_path": "ppdet/modeling/anchor_heads/retina_head.py", "diff": "@@ -404,5 +404,5 @@ class RetinaHead(object):\ninside_weight=bbox_weight,\noutside_weight=bbox_weight)\nloss_bbox = fluid.layers.reduce_sum(loss_bbox, name='loss_bbox')\n- loss_bbox = loss_bbox / fg_num\n+ loss_bbox = loss_bbox / fluid.layers.cast(fg_num, loss_bbox.dtype)\nreturn {'loss_cls': loss_cls, 'loss_bbox': loss_bbox}\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix the dtype of loss (#1317)
499,304
01.09.2020 19:27:55
-28,800
929c7f202251c6381d709ad6f2a3fc65860f3be9
support depoly infer for fcos
[ { "change_type": "MODIFY", "old_path": "deploy/python/infer.py", "new_path": "deploy/python/infer.py", "diff": "@@ -74,7 +74,7 @@ class Resize(object):\nself.arch = arch\nself.use_cv2 = use_cv2\nself.interp = interp\n- self.scale_set = {'RCNN', 'RetinaNet'}\n+ self.scale_set = {'RCNN', 'RetinaNet', 'FCOS'}\ndef __call__(self, im, im_info):\n\"\"\"\n@@ -259,7 +259,7 @@ def create_inputs(im, im_info, model_arch='YOLO'):\nscale = scale_x\nim_info = np.array([resize_shape + [scale]]).astype('float32')\ninputs['im_info'] = im_info\n- elif 'RCNN' in model_arch:\n+ elif ('RCNN' in model_arch) or ('FCOS' in model_arch):\nscale = scale_x\nim_info = np.array([resize_shape + [scale]]).astype('float32')\nim_shape = np.array([origin_shape + [1.]]).astype('float32')\n@@ -276,7 +276,15 @@ class Config():\nArgs:\nmodel_dir (str): root path of model.yml\n\"\"\"\n- support_models = ['YOLO', 'SSD', 'RetinaNet', 'RCNN', 'Face', 'TTF']\n+ support_models = [\n+ 'YOLO',\n+ 'SSD',\n+ 'RetinaNet',\n+ 'RCNN',\n+ 'Face',\n+ 'TTF',\n+ 'FCOS',\n+ ]\ndef __init__(self, model_dir):\n# parsing Yaml config for Preprocess\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
support depoly infer for fcos (#1331)
499,300
03.09.2020 12:55:50
-28,800
40ff9a639c7136d0f3e6a2db742864de5299683b
Add inference support for efficientdet reuse RetinaNet pipeline for now
[ { "change_type": "MODIFY", "old_path": "tools/export_model.py", "new_path": "tools/export_model.py", "diff": "@@ -78,6 +78,15 @@ def parse_reader(reader_cfg, metric, arch):\nparams['image_shape'] = image_shape[1:]\nif 'target_dim' in params:\nparams.pop('target_dim')\n+ if p['type'] == 'ResizeAndPad':\n+ assert has_shape_def, \"missing input shape\"\n+ p['type'] = 'Resize'\n+ p['target_size'] = params['target_dim']\n+ p['max_size'] = params['target_dim']\n+ p['interp'] = params['interp']\n+ p['image_shape'] = image_shape[1:]\n+ preprocess_list.append(p)\n+ continue\np.update(params)\npreprocess_list.append(p)\nbatch_transforms = reader_cfg.get('batch_transforms', None)\n@@ -113,9 +122,9 @@ def dump_infer_config(FLAGS, config):\n'Face': 3,\n'TTFNet': 3,\n'FCOS': 3,\n- 'EfficientDet': 40\n}\ninfer_arch = config['architecture']\n+ infer_arch = 'RetinaNet' if infer_arch == 'EfficientDet' else infer_arch\nfor arch, min_subgraph_size in trt_min_subgraph.items():\nif arch in infer_arch:\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
Add inference support for efficientdet (#1345) reuse RetinaNet pipeline for now
499,304
07.09.2020 15:30:14
-28,800
57a02fd635ad03522b6779b71789846538712a1d
fix faster_rcnn_r34 config
[ { "change_type": "MODIFY", "old_path": "configs/faster_rcnn_r34_fpn_1x.yml", "new_path": "configs/faster_rcnn_r34_fpn_1x.yml", "diff": "@@ -4,7 +4,7 @@ use_gpu: true\nsnapshot_iter: 10000\nlog_smooth_window: 20\nsave_dir: output\n-pretrain_weights: ResNet34_pretrained\n+pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet34_pretrained.tar\nmetric: COCO\nweights: output/faster_rcnn_r34_fpn_1x/model_final\nnum_classes: 81\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix faster_rcnn_r34 config (#1368)
499,304
09.09.2020 19:59:43
-28,800
2ecbbe59259f51987388686eaf2b3b7111c70726
remove unnecessary code and sort out code in deploy/infer
[ { "change_type": "MODIFY", "old_path": "deploy/python/infer.py", "new_path": "deploy/python/infer.py", "diff": "@@ -25,6 +25,24 @@ import numpy as np\nimport paddle.fluid as fluid\nfrom visualize import visualize_box_mask\n+# Global dictionary\n+RESIZE_SCALE_SET = {\n+ 'RCNN',\n+ 'RetinaNet',\n+ 'FCOS',\n+}\n+\n+SUPPORT_MODELS = {\n+ 'YOLO',\n+ 'SSD',\n+ 'RetinaNet',\n+ 'EfficientDet',\n+ 'RCNN',\n+ 'Face',\n+ 'TTF',\n+ 'FCOS',\n+}\n+\ndef decode_image(im_file, im_info):\n\"\"\"read rgb image\n@@ -70,11 +88,10 @@ class Resize(object):\ninterp=cv2.INTER_LINEAR):\nself.target_size = target_size\nself.max_size = max_size\n- self.image_shape = image_shape,\n+ self.image_shape = image_shape\nself.arch = arch\nself.use_cv2 = use_cv2\nself.interp = interp\n- self.scale_set = {'RCNN', 'RetinaNet', 'FCOS'}\ndef __call__(self, im, im_info):\n\"\"\"\n@@ -129,7 +146,7 @@ class Resize(object):\n\"\"\"\norigin_shape = im.shape[:2]\nim_c = im.shape[2]\n- if self.max_size != 0 and self.arch in self.scale_set:\n+ if self.max_size != 0 and self.arch in RESIZE_SCALE_SET:\nim_size_min = np.min(origin_shape[0:2])\nim_size_max = np.max(origin_shape[0:2])\nim_scale = float(self.target_size) / float(im_size_min)\n@@ -255,7 +272,7 @@ def create_inputs(im, im_info, model_arch='YOLO'):\nif 'YOLO' in model_arch:\nim_size = np.array([origin_shape]).astype('int32')\ninputs['im_size'] = im_size\n- elif 'RetinaNet' in model_arch:\n+ elif 'RetinaNet' or 'EfficientDet' in model_arch:\nscale = scale_x\nim_info = np.array([resize_shape + [scale]]).astype('float32')\ninputs['im_info'] = im_info\n@@ -276,15 +293,6 @@ class Config():\nArgs:\nmodel_dir (str): root path of model.yml\n\"\"\"\n- support_models = [\n- 'YOLO',\n- 'SSD',\n- 'RetinaNet',\n- 'RCNN',\n- 'Face',\n- 'TTF',\n- 'FCOS',\n- ]\ndef __init__(self, model_dir):\n# parsing Yaml config for Preprocess\n@@ -307,11 +315,11 @@ class Config():\nRaises:\nValueError: loaded model not in supported model type\n\"\"\"\n- for support_model in self.support_models:\n+ for support_model in SUPPORT_MODELS:\nif support_model in yml_conf['arch']:\nreturn True\nraise ValueError(\"Unsupported arch: {}, expect {}\".format(yml_conf[\n- 'arch'], self.support_models))\n+ 'arch'], SUPPORT_MODELS))\ndef print_config(self):\nprint('----------- Model Configuration -----------')\n" }, { "change_type": "MODIFY", "old_path": "tools/export_model.py", "new_path": "tools/export_model.py", "diff": "@@ -36,13 +36,29 @@ FORMAT = '%(asctime)s-%(levelname)s: %(message)s'\nlogging.basicConfig(level=logging.INFO, format=FORMAT)\nlogger = logging.getLogger(__name__)\n+# Global dictionary\n+TRT_MIN_SUBGRAPH = {\n+ 'YOLO': 3,\n+ 'SSD': 3,\n+ 'RCNN': 40,\n+ 'RetinaNet': 40,\n+ 'EfficientDet': 40,\n+ 'Face': 3,\n+ 'TTFNet': 3,\n+ 'FCOS': 3,\n+}\n+RESIZE_SCALE_SET = {\n+ 'RCNN',\n+ 'RetinaNet',\n+ 'FCOS',\n+}\n+\ndef parse_reader(reader_cfg, metric, arch):\npreprocess_list = []\nimage_shape = reader_cfg['inputs_def'].get('image_shape', [3, None, None])\nhas_shape_def = not None in image_shape\n- scale_set = {'RCNN', 'RetinaNet'}\ndataset = reader_cfg['dataset']\nanno_file = dataset.get_anno()\n@@ -72,9 +88,9 @@ def parse_reader(reader_cfg, metric, arch):\nparams.pop('_id')\nif p['type'] == 'Resize' and has_shape_def:\nparams['target_size'] = min(image_shape[\n- 1:]) if arch in scale_set else image_shape[1]\n+ 1:]) if arch in RESIZE_SCALE_SET else image_shape[1]\nparams['max_size'] = max(image_shape[\n- 1:]) if arch in scale_set else 0\n+ 1:]) if arch in RESIZE_SCALE_SET else 0\nparams['image_shape'] = image_shape[1:]\nif 'target_dim' in params:\nparams.pop('target_dim')\n@@ -114,19 +130,9 @@ def dump_infer_config(FLAGS, config):\n'draw_threshold': 0.5,\n'metric': config['metric']\n})\n- trt_min_subgraph = {\n- 'YOLO': 3,\n- 'SSD': 3,\n- 'RCNN': 40,\n- 'RetinaNet': 40,\n- 'Face': 3,\n- 'TTFNet': 3,\n- 'FCOS': 3,\n- }\ninfer_arch = config['architecture']\n- infer_arch = 'RetinaNet' if infer_arch == 'EfficientDet' else infer_arch\n- for arch, min_subgraph_size in trt_min_subgraph.items():\n+ for arch, min_subgraph_size in TRT_MIN_SUBGRAPH.items():\nif arch in infer_arch:\ninfer_cfg['arch'] = arch\ninfer_cfg['min_subgraph_size'] = min_subgraph_size\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
remove unnecessary code and sort out code in deploy/infer (#1378)
499,331
10.09.2020 11:23:46
-28,800
399ed5a0fc9545deda1f2505dc1a3506bb00be90
fix bug of function _make_dataset in ppdet/data/source/dataset.py
[ { "change_type": "MODIFY", "old_path": "ppdet/data/source/dataset.py", "new_path": "ppdet/data/source/dataset.py", "diff": "@@ -87,16 +87,16 @@ def _is_valid_file(f, extensions=('.jpg', '.jpeg', '.png', '.bmp')):\nreturn f.lower().endswith(extensions)\n-def _make_dataset(dir):\n- dir = os.path.expanduser(dir)\n- if not os.path.isdir(d):\n- raise ('{} should be a dir'.format(dir))\n+def _make_dataset(data_dir):\n+ data_dir = os.path.expanduser(data_dir)\n+ if not os.path.isdir(data_dir):\n+ raise ('{} should be a dir'.format(data_dir))\nimages = []\n- for root, _, fnames in sorted(os.walk(dir, followlinks=True)):\n+ for root, _, fnames in sorted(os.walk(data_dir, followlinks=True)):\nfor fname in sorted(fnames):\n- path = os.path.join(root, fname)\n- if is_valid_file(path):\n- images.append(path)\n+ file_path = os.path.join(root, fname)\n+ if _is_valid_file(file_path):\n+ images.append(file_path)\nreturn images\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix bug of function _make_dataset in ppdet/data/source/dataset.py (#1380)
499,395
11.09.2020 21:42:39
-28,800
d7d3fbeaa9f26a9445b9ae28218f6a016e98686d
modify deploy inference code fix compile error in code modify code for inference
[ { "change_type": "MODIFY", "old_path": "deploy/cpp/include/object_detector.h", "new_path": "deploy/cpp/include/object_detector.h", "diff": "#include <vector>\n#include <memory>\n#include <utility>\n+#include <ctime>\n#include <opencv2/core/core.hpp>\n#include <opencv2/imgproc/imgproc.hpp>\n@@ -74,9 +75,12 @@ class ObjectDetector {\nconst int gpu_id=0);\n// Run predictor\n- void Predict(\n- const cv::Mat& img,\n- std::vector<ObjectResult>* result);\n+ void Predict(const cv::Mat& im,\n+ const double threshold = 0.5,\n+ const int warmup = 0,\n+ const int repeats = 1,\n+ const bool run_benchmark = false,\n+ std::vector<ObjectResult>* result = nullptr);\n// Get Model Label list\nconst std::vector<std::string>& GetLabelList() const {\n" }, { "change_type": "MODIFY", "old_path": "deploy/cpp/src/main.cc", "new_path": "deploy/cpp/src/main.cc", "diff": "@@ -29,6 +29,9 @@ DEFINE_bool(use_camera, false, \"Use camera or not\");\nDEFINE_string(run_mode, \"fluid\", \"Mode of running(fluid/trt_fp32/trt_fp16)\");\nDEFINE_int32(gpu_id, 0, \"Device id of GPU to execute\");\nDEFINE_int32(camera_id, -1, \"Device id of camera to predict\");\n+DEFINE_bool(run_benchmark, false, \"Whether to predict a image_file repeatedly for benchmark\");\n+DEFINE_double(threshold, 0.5, \"Threshold of score.\");\n+DEFINE_string(output_dir, \"output\", \"Directory of output visualization files.\");\nvoid PredictVideo(const std::string& video_path,\nPaddleDetection::ObjectDetector* det) {\n@@ -72,7 +75,7 @@ void PredictVideo(const std::string& video_path,\nif (frame.empty()) {\nbreak;\n}\n- det->Predict(frame, &result);\n+ det->Predict(frame, 0.5, 0, 1, false, &result);\ncv::Mat out_im = PaddleDetection::VisualizeResult(\nframe, result, labels, colormap);\nfor (const auto& item : result) {\n@@ -93,12 +96,20 @@ void PredictVideo(const std::string& video_path,\n}\nvoid PredictImage(const std::string& image_path,\n- PaddleDetection::ObjectDetector* det) {\n+ const double threshold,\n+ const bool run_benchmark,\n+ PaddleDetection::ObjectDetector* det,\n+ const std::string& output_dir = \"output\") {\n// Open input image as an opencv cv::Mat object\ncv::Mat im = cv::imread(image_path, 1);\n// Store all detected result\nstd::vector<PaddleDetection::ObjectResult> result;\n- det->Predict(im, &result);\n+ if (run_benchmark)\n+ {\n+ det->Predict(im, threshold, 100, 100, run_benchmark, &result);\n+ }else\n+ {\n+ det->Predict(im, 0.5, 0, 1, run_benchmark, &result);\nfor (const auto& item : result) {\nprintf(\"class=%d confidence=%.4f rect=[%d %d %d %d]\\n\",\nitem.class_id,\n@@ -116,9 +127,10 @@ void PredictImage(const std::string& image_path,\nstd::vector<int> compression_params;\ncompression_params.push_back(CV_IMWRITE_JPEG_QUALITY);\ncompression_params.push_back(95);\n- cv::imwrite(\"output.jpg\", vis_img, compression_params);\n+ cv::imwrite(output_dir + \"/output.jpg\", vis_img, compression_params);\nprintf(\"Visualized output saved as output.jpg\\n\");\n}\n+}\nint main(int argc, char** argv) {\n// Parsing command-line\n@@ -139,10 +151,10 @@ int main(int argc, char** argv) {\nPaddleDetection::ObjectDetector det(FLAGS_model_dir, FLAGS_use_gpu,\nFLAGS_run_mode, FLAGS_gpu_id);\n// Do inference on input video or image\n- if (!FLAGS_video_path.empty() or FLAGS_use_camera) {\n+ if (!FLAGS_video_path.empty() || FLAGS_use_camera) {\nPredictVideo(FLAGS_video_path, &det);\n} else if (!FLAGS_image_path.empty()) {\n- PredictImage(FLAGS_image_path, &det);\n+ PredictImage(FLAGS_image_path, FLAGS_threshold, FLAGS_run_benchmark, &det, FLAGS_output_dir);\n}\nreturn 0;\n}\n" }, { "change_type": "MODIFY", "old_path": "deploy/cpp/src/object_detector.cc", "new_path": "deploy/cpp/src/object_detector.cc", "diff": "@@ -39,7 +39,7 @@ void ObjectDetector::LoadModel(const std::string& model_dir,\nprintf(\"TensorRT int8 mode is not supported now, \"\n\"please use 'trt_fp32' or 'trt_fp16' instead\");\n} else {\n- if (run_mode != \"trt_32\") {\n+ if (run_mode != \"trt_fp32\") {\nprintf(\"run_mode should be 'fluid', 'trt_fp32' or 'trt_fp16'\");\n}\n}\n@@ -56,6 +56,7 @@ void ObjectDetector::LoadModel(const std::string& model_dir,\n}\nconfig.SwitchUseFeedFetchOps(false);\nconfig.SwitchSpecifyInputNames(true);\n+ config.DisableGlogInfo();\n// Memory optimization\nconfig.EnableMemoryOptim();\npredictor_ = std::move(CreatePaddlePredictor(config));\n@@ -155,6 +156,10 @@ void ObjectDetector::Postprocess(\n}\nvoid ObjectDetector::Predict(const cv::Mat& im,\n+ const double threshold,\n+ const int warmup,\n+ const int repeats,\n+ const bool run_benchmark,\nstd::vector<ObjectResult>* result) {\n// Preprocess image\nPreprocess(im);\n@@ -182,6 +187,8 @@ void ObjectDetector::Predict(const cv::Mat& im,\n}\n}\n// Run predictor\n+ for (int i = 0; i < warmup; i++)\n+ {\npredictor_->ZeroCopyRun();\n// Get output tensor\nauto output_names = predictor_->GetOutputNames();\n@@ -198,9 +205,36 @@ void ObjectDetector::Predict(const cv::Mat& im,\n}\noutput_data_.resize(output_size);\nout_tensor->copy_to_cpu(output_data_.data());\n+ }\n+\n+ std::clock_t start = clock();\n+ for (int i = 0; i < repeats; i++)\n+ {\n+ predictor_->ZeroCopyRun();\n+ // Get output tensor\n+ auto output_names = predictor_->GetOutputNames();\n+ auto out_tensor = predictor_->GetOutputTensor(output_names[0]);\n+ std::vector<int> output_shape = out_tensor->shape();\n+ // Calculate output length\n+ int output_size = 1;\n+ for (int j = 0; j < output_shape.size(); ++j) {\n+ output_size *= output_shape[j];\n+ }\n+\n+ if (output_size < 6) {\n+ std::cerr << \"[WARNING] No object detected.\" << std::endl;\n+ }\n+ output_data_.resize(output_size);\n+ out_tensor->copy_to_cpu(output_data_.data());\n+ }\n+ std::clock_t end = clock();\n+ float ms = static_cast<float>(end - start) / CLOCKS_PER_SEC / repeats * 1000.;\n+ printf(\"Inference: %f ms per batch image\\n\", ms);\n// Postprocessing result\n+ if(!run_benchmark) {\nPostprocess(im, result);\n}\n+}\nstd::vector<int> GenerateColorMap(int num_class) {\nauto colormap = std::vector<int>(3 * num_class, 0);\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
modify deploy inference code (#1394) fix compile error in code modify code for inference
499,313
14.09.2020 20:10:13
-28,800
d0a3c56543556baad67ee9a3458a7bb8f240517d
fix ImageMixup with no gt_bbox.
[ { "change_type": "MODIFY", "old_path": "ppdet/data/transform/operators.py", "new_path": "ppdet/data/transform/operators.py", "diff": "@@ -1266,8 +1266,8 @@ class MixupImage(BaseOperator):\nif factor <= 0.0:\nreturn sample['mixup']\nim = self._mixup_img(sample['image'], sample['mixup']['image'], factor)\n- gt_bbox1 = sample['gt_bbox']\n- gt_bbox2 = sample['mixup']['gt_bbox']\n+ gt_bbox1 = sample['gt_bbox'].reshape((-1, 4))\n+ gt_bbox2 = sample['mixup']['gt_bbox'].reshape((-1, 4))\ngt_bbox = np.concatenate((gt_bbox1, gt_bbox2), axis=0)\ngt_class1 = sample['gt_class']\ngt_class2 = sample['mixup']['gt_class']\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix ImageMixup with no gt_bbox. (#1404)
499,395
15.09.2020 15:01:47
-28,800
17f4307d96de08a77212c39ea2f4b66d314d58a4
fix create_inputs of deploy/python/infer.py
[ { "change_type": "MODIFY", "old_path": "deploy/python/infer.py", "new_path": "deploy/python/infer.py", "diff": "@@ -272,7 +272,7 @@ def create_inputs(im, im_info, model_arch='YOLO'):\nif 'YOLO' in model_arch:\nim_size = np.array([origin_shape]).astype('int32')\ninputs['im_size'] = im_size\n- elif 'RetinaNet' or 'EfficientDet' in model_arch:\n+ elif 'RetinaNet' in model_arch or 'EfficientDet' in model_arch:\nscale = scale_x\nim_info = np.array([resize_shape + [scale]]).astype('float32')\ninputs['im_info'] = im_info\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix create_inputs of deploy/python/infer.py (#1411)
499,331
15.09.2020 18:59:55
-28,800
0e5f87c3c29d4fde1d915e653c0b0551546ec8dd
Repalce fruit dataset with roadsign dataset, and update QUICK_STARTED, use PP-YOLO as demo, test=document_fix.
[ { "change_type": "ADD", "old_path": "demo/road554.png", "new_path": "demo/road554.png", "diff": "Binary files /dev/null and b/demo/road554.png differ\n" }, { "change_type": "ADD", "old_path": "docs/images/000000014439.jpg", "new_path": "docs/images/000000014439.jpg", "diff": "Binary files /dev/null and b/docs/images/000000014439.jpg differ\n" }, { "change_type": "DELETE", "old_path": "docs/images/000000014439_640x640.jpg", "new_path": "docs/images/000000014439_640x640.jpg", "diff": "Binary files a/docs/images/000000014439_640x640.jpg and /dev/null differ\n" }, { "change_type": "ADD", "old_path": "docs/images/road554.png", "new_path": "docs/images/road554.png", "diff": "Binary files /dev/null and b/docs/images/road554.png differ\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
Repalce fruit dataset with roadsign dataset, and update QUICK_STARTED, use PP-YOLO as demo, test=document_fix. (#1407)
499,331
16.09.2020 14:55:55
-28,800
915d53706eaf8253158d4c9730ad27732ec62cf6
set use_default_label=False as default
[ { "change_type": "MODIFY", "old_path": "ppdet/data/source/dataset.py", "new_path": "ppdet/data/source/dataset.py", "diff": "@@ -41,7 +41,7 @@ class DataSet(object):\nanno_path=None,\nsample_num=-1,\nwith_background=True,\n- use_default_label=None,\n+ use_default_label=False,\n**kwargs):\nsuper(DataSet, self).__init__()\nself.anno_path = anno_path\n@@ -117,7 +117,7 @@ class ImageFolder(DataSet):\nanno_path=None,\nsample_num=-1,\nwith_background=True,\n- use_default_label=None,\n+ use_default_label=False,\n**kwargs):\nsuper(ImageFolder, self).__init__(dataset_dir, image_dir, anno_path,\nsample_num, with_background,\n" }, { "change_type": "MODIFY", "old_path": "ppdet/data/source/voc.py", "new_path": "ppdet/data/source/voc.py", "diff": "@@ -51,7 +51,7 @@ class VOCDataSet(DataSet):\nimage_dir=None,\nanno_path=None,\nsample_num=-1,\n- use_default_label=True,\n+ use_default_label=False,\nwith_background=True,\nlabel_list='label_list.txt'):\nsuper(VOCDataSet, self).__init__(\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
set use_default_label=False as default (#1409)
499,395
18.09.2020 19:31:20
-28,800
e4f7c2dafae370773c431a269d0ef76071ed1bf1
add usage of tools/anchor_cluster.py in doc
[ { "change_type": "MODIFY", "old_path": "configs/ppyolo/README.md", "new_path": "configs/ppyolo/README.md", "diff": "@@ -82,6 +82,12 @@ Training PP-YOLO on 8 GPUs with following command(all commands should be run und\nCUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python tools/train.py -c configs/ppyolo/ppyolo.yml --eval\n```\n+optional: Run `tools/anchor_cluster.py` to get anchors suitable for your dataset, and modify the anchor setting in `configs/ppyolo/ppyolo.yml`.\n+\n+``` bash\n+python tools/anchor_cluster.py -c configs/ppyolo/ppyolo.yml -n 9 -m v2 -i 1000\n+```\n+\n### 2. Evaluation\nEvaluating PP-YOLO on COCO val2017 dataset in single GPU with following commands:\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
add usage of tools/anchor_cluster.py in doc (#1440)
499,331
19.09.2020 21:03:51
-28,800
593b6b9e3e688953b904087c574cffc37e4e92e2
judge dataset file_path exists
[ { "change_type": "MODIFY", "old_path": "ppdet/utils/download.py", "new_path": "ppdet/utils/download.py", "diff": "@@ -239,13 +239,19 @@ def _dataset_exists(path, annotation, image_dir):\nif annotation:\nannotation_path = osp.join(path, annotation)\n+ if not osp.exists(annotation_path):\n+ logger.error(\"Config dataset_dir {} is not exits!\".format(path))\n+\nif not osp.isfile(annotation_path):\n- logger.debug(\"Config annotation {} is not a \"\n+ logger.warning(\"Config annotation {} is not a \"\n\"file, dataset config is not \"\n\"valid\".format(annotation_path))\nreturn False\nif image_dir:\nimage_path = osp.join(path, image_dir)\n+ if not osp.exists(image_path):\n+ logger.warning(\"Config dataset_dir {} is not exits!\".format(path))\n+\nif not osp.isdir(image_path):\nlogger.warning(\"Config image_dir {} is not a \"\n\"directory, dataset config is not \"\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
judge dataset file_path exists (#1438)
499,385
21.09.2020 11:13:48
-28,800
bfd3a1e1085bba0a40f849855e2ea01658ecec20
Change README to cn
[ { "change_type": "ADD", "old_path": null, "new_path": "README.md", "diff": "+README_cn.md\n\\ No newline at end of file\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
Change README to cn (#1429)
499,395
21.09.2020 11:46:37
-28,800
37f3955c643f12dde3ac9464a14ef9af2dcf47c3
modify doc for anchor cluster
[ { "change_type": "MODIFY", "old_path": "configs/ppyolo/README.md", "new_path": "configs/ppyolo/README.md", "diff": "@@ -85,7 +85,7 @@ CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python tools/train.py -c configs/ppyolo/ppy\noptional: Run `tools/anchor_cluster.py` to get anchors suitable for your dataset, and modify the anchor setting in `configs/ppyolo/ppyolo.yml`.\n``` bash\n-python tools/anchor_cluster.py -c configs/ppyolo/ppyolo.yml -n 9 -m v2 -i 1000\n+python tools/anchor_cluster.py -c configs/ppyolo/ppyolo.yml -n 9 -s 608 -m v2 -i 1000\n```\n### 2. Evaluation\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
modify doc for anchor cluster (#1445)
499,331
21.09.2020 17:14:27
-28,800
4bb142cffaff9a8c0e5231699f74a30c0975ad56
Add PaddleServing demo.
[ { "change_type": "ADD", "old_path": null, "new_path": "deploy/serving/test_client.py", "diff": "+# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+# http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+\n+import sys\n+import numpy as np\n+from paddle_serving_client import Client\n+from paddle_serving_app.reader import *\n+import cv2\n+preprocess = Sequential([\n+ File2Image(), BGR2RGB(), Resize(\n+ (608, 608), interpolation=cv2.INTER_LINEAR), Div(255.0), Transpose(\n+ (2, 0, 1))\n+])\n+\n+postprocess = RCNNPostprocess(\"label_list.txt\", \"output\", [608, 608])\n+client = Client()\n+\n+client.load_client_config(\"serving_client/serving_client_conf.prototxt\")\n+client.connect(['127.0.0.1:9393'])\n+\n+im = preprocess(sys.argv[1])\n+fetch_map = client.predict(\n+ feed={\n+ \"image\": im,\n+ \"im_size\": np.array(list(im.shape[1:])),\n+ },\n+ fetch=[\"multiclass_nms_0.tmp_0\"])\n+fetch_map[\"image\"] = sys.argv[1]\n+postprocess(fetch_map)\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
Add PaddleServing demo. (#1431)
499,385
22.09.2020 14:42:56
-28,800
caf816a212253644f68c00d33934c21236556869
Fix DebugVisibleImage in ppdet/data/transform/operators.py
[ { "change_type": "MODIFY", "old_path": "ppdet/data/transform/operators.py", "new_path": "ppdet/data/transform/operators.py", "diff": "@@ -2551,9 +2551,7 @@ class DebugVisibleImage(BaseOperator):\nx1 = round(keypoint[2 * j]).astype(np.int32)\ny1 = round(keypoint[2 * j + 1]).astype(np.int32)\ndraw.ellipse(\n- (x1, y1, x1 + 5, y1i + 5),\n- fill='green',\n- outline='green')\n+ (x1, y1, x1 + 5, y1 + 5), fill='green', outline='green')\nsave_path = os.path.join(self.output_dir, out_file_name)\nimage.save(save_path, quality=95)\nreturn sample\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
Fix DebugVisibleImage in ppdet/data/transform/operators.py (#1471)
499,330
25.09.2020 17:33:24
-28,800
23d3ea61d9ac4c584be93e3ff7cd33080cfb56e2
add ips for detection models test=develop
[ { "change_type": "MODIFY", "old_path": "tools/train.py", "new_path": "tools/train.py", "diff": "@@ -255,8 +255,9 @@ def main():\ntrain_stats.update(stats)\nlogs = train_stats.log()\nif it % cfg.log_iter == 0 and (not FLAGS.dist or trainer_id == 0):\n- strs = 'iter: {}, lr: {:.6f}, {}, time: {:.3f}, eta: {}'.format(\n- it, np.mean(outs[-1]), logs, time_cost, eta)\n+ ips = float(cfg['TrainReader']['batch_size']) / time_cost\n+ strs = 'iter: {}, lr: {:.6f}, {}, batch_cost: {:.5f} s, eta: {}, ips: {:.5f} images/sec'.format(\n+ it, np.mean(outs[-1]), logs, time_cost, eta, ips)\nlogger.info(strs)\n# NOTE : profiler tools, used for benchmark\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
add ips for detection models (#1507) test=develop
499,330
02.10.2020 10:19:23
-28,800
fcfac7544033678b1644d42b70062c618baa5825
refine benchmark log test=develop
[ { "change_type": "MODIFY", "old_path": "tools/train.py", "new_path": "tools/train.py", "diff": "@@ -258,8 +258,8 @@ def main():\nlogs = train_stats.log()\nif it % cfg.log_iter == 0 and (not FLAGS.dist or trainer_id == 0):\nips = float(cfg['TrainReader']['batch_size']) / time_cost\n- strs = 'iter: {}, lr: {:.6f}, {}, batch_cost: {:.5f} s, eta: {}, ips: {:.5f} images/sec'.format(\n- it, np.mean(outs[-1]), logs, time_cost, eta, ips)\n+ strs = 'iter: {}, lr: {:.6f}, {}, eta: {}, batch_cost: {:.5f} sec, ips: {:.5f} images/sec'.format(\n+ it, np.mean(outs[-1]), logs, eta, time_cost, ips)\nlogger.info(strs)\n# NOTE : profiler tools, used for benchmark\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
refine benchmark log (#1512) test=develop
499,313
10.10.2020 19:54:24
-28,800
a90d8be73027bb81d319104993081f9a9e977940
fix eval in distill_pruned_model
[ { "change_type": "MODIFY", "old_path": "slim/extensions/distill_pruned_model/distill_pruned_model.py", "new_path": "slim/extensions/distill_pruned_model/distill_pruned_model.py", "diff": "@@ -319,7 +319,7 @@ def main():\nos.path.join(save_dir, save_name))\n# eval\nresults = eval_run(exe, compiled_eval_prog, eval_loader, eval_keys,\n- eval_values, eval_cls)\n+ eval_values, eval_cls, cfg)\nresolution = None\nbox_ap_stats = eval_results(results, cfg.metric, cfg.num_classes,\nresolution, is_bbox_normalized,\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix eval in distill_pruned_model (#1551)
499,360
12.10.2020 11:55:23
-28,800
262dfa3e7a65992f359f2c31c1cba9279ce28cb2
fixed max_size for ResizeImage transformation
[ { "change_type": "MODIFY", "old_path": "configs/rcnn_enhance/cascade_rcnn_dcn_r101_vd_fpn_3x_server_side.yml", "new_path": "configs/rcnn_enhance/cascade_rcnn_dcn_r101_vd_fpn_3x_server_side.yml", "diff": "@@ -168,7 +168,7 @@ EvalReader:\nstd: [0.229, 0.224,0.225]\n- !ResizeImage\ninterp: 1\n- max_size: 13330\n+ max_size: 1333\ntarget_size: 800\nuse_cv2: true\n- !Permute\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fixed max_size for ResizeImage transformation (#1549)
499,304
15.10.2020 11:39:47
-28,800
2e33bc591473c039f8ce72468da2ca30f100dbe1
fix error in train_batch_size sync from load_config
[ { "change_type": "MODIFY", "old_path": "ppdet/core/workspace.py", "new_path": "ppdet/core/workspace.py", "diff": "@@ -139,7 +139,7 @@ def merge_config(config, another_cfg=None):\n# batch size config to global, models can get batch size config\n# from global config when building model.\n# batch size in evaluation or inference can also be added here\n- if 'TrainReader' in dct:\n+ if 'TrainReader' in dct and 'batch_size' in dct['TrainReader']:\ndct['train_batch_size'] = dct['TrainReader']['batch_size']\nreturn dct\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix error in train_batch_size sync from load_config (#1567)
499,313
15.10.2020 17:07:25
-28,800
47606f9a330acc21c1e32f7f3937e107ccb1cdbf
add infer_cfg export in slim export_model
[ { "change_type": "ADD", "old_path": null, "new_path": "ppdet/utils/export_utils.py", "diff": "+# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+# http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+\n+from __future__ import absolute_import\n+from __future__ import division\n+from __future__ import print_function\n+\n+import os\n+import yaml\n+import numpy as np\n+from collections import OrderedDict\n+\n+import logging\n+logger = logging.getLogger(__name__)\n+\n+import paddle.fluid as fluid\n+\n+__all__ = ['dump_infer_config', 'save_infer_model']\n+\n+# Global dictionary\n+TRT_MIN_SUBGRAPH = {\n+ 'YOLO': 3,\n+ 'SSD': 3,\n+ 'RCNN': 40,\n+ 'RetinaNet': 40,\n+ 'EfficientDet': 40,\n+ 'Face': 3,\n+ 'TTFNet': 3,\n+ 'FCOS': 3,\n+ 'SOLOv2': 3,\n+}\n+RESIZE_SCALE_SET = {\n+ 'RCNN',\n+ 'RetinaNet',\n+ 'FCOS',\n+ 'SOLOv2',\n+}\n+\n+\n+def parse_reader(reader_cfg, metric, arch):\n+ preprocess_list = []\n+\n+ image_shape = reader_cfg['inputs_def'].get('image_shape', [3, None, None])\n+ has_shape_def = not None in image_shape\n+\n+ dataset = reader_cfg['dataset']\n+ anno_file = dataset.get_anno()\n+ with_background = dataset.with_background\n+ use_default_label = dataset.use_default_label\n+\n+ if metric == 'COCO':\n+ from ppdet.utils.coco_eval import get_category_info\n+ elif metric == \"VOC\":\n+ from ppdet.utils.voc_eval import get_category_info\n+ elif metric == \"WIDERFACE\":\n+ from ppdet.utils.widerface_eval_utils import get_category_info\n+ else:\n+ raise ValueError(\n+ \"metric only supports COCO, VOC, WIDERFACE, but received {}\".format(\n+ metric))\n+ clsid2catid, catid2name = get_category_info(anno_file, with_background,\n+ use_default_label)\n+\n+ label_list = [str(cat) for cat in catid2name.values()]\n+\n+ sample_transforms = reader_cfg['sample_transforms']\n+ for st in sample_transforms[1:]:\n+ method = st.__class__.__name__\n+ p = {'type': method.replace('Image', '')}\n+ params = st.__dict__\n+ params.pop('_id')\n+ if p['type'] == 'Resize' and has_shape_def:\n+ params['target_size'] = min(image_shape[\n+ 1:]) if arch in RESIZE_SCALE_SET else image_shape[1]\n+ params['max_size'] = max(image_shape[\n+ 1:]) if arch in RESIZE_SCALE_SET else 0\n+ params['image_shape'] = image_shape[1:]\n+ if 'target_dim' in params:\n+ params.pop('target_dim')\n+ if p['type'] == 'ResizeAndPad':\n+ assert has_shape_def, \"missing input shape\"\n+ p['type'] = 'Resize'\n+ p['target_size'] = params['target_dim']\n+ p['max_size'] = params['target_dim']\n+ p['interp'] = params['interp']\n+ p['image_shape'] = image_shape[1:]\n+ preprocess_list.append(p)\n+ continue\n+ p.update(params)\n+ preprocess_list.append(p)\n+ batch_transforms = reader_cfg.get('batch_transforms', None)\n+ if batch_transforms:\n+ methods = [bt.__class__.__name__ for bt in batch_transforms]\n+ for bt in batch_transforms:\n+ method = bt.__class__.__name__\n+ if method == 'PadBatch':\n+ preprocess_list.append({'type': 'PadStride'})\n+ params = bt.__dict__\n+ preprocess_list[-1].update({'stride': params['pad_to_stride']})\n+ break\n+\n+ return with_background, preprocess_list, label_list\n+\n+\n+def dump_infer_config(FLAGS, config):\n+ arch_state = 0\n+ cfg_name = os.path.basename(FLAGS.config).split('.')[0]\n+ save_dir = os.path.join(FLAGS.output_dir, cfg_name)\n+ if not os.path.exists(save_dir):\n+ os.makedirs(save_dir)\n+ from ppdet.core.config.yaml_helpers import setup_orderdict\n+ setup_orderdict()\n+ infer_cfg = OrderedDict({\n+ 'use_python_inference': False,\n+ 'mode': 'fluid',\n+ 'draw_threshold': 0.5,\n+ 'metric': config['metric']\n+ })\n+ infer_arch = config['architecture']\n+\n+ for arch, min_subgraph_size in TRT_MIN_SUBGRAPH.items():\n+ if arch in infer_arch:\n+ infer_cfg['arch'] = arch\n+ infer_cfg['min_subgraph_size'] = min_subgraph_size\n+ arch_state = 1\n+ break\n+ if not arch_state:\n+ logger.error(\n+ 'Architecture: {} is not supported for exporting model now'.format(\n+ infer_arch))\n+ os._exit(0)\n+\n+ if 'Mask' in config['architecture']:\n+ infer_cfg['mask_resolution'] = config['MaskHead']['resolution']\n+ infer_cfg['with_background'], infer_cfg['Preprocess'], infer_cfg[\n+ 'label_list'] = parse_reader(config['TestReader'], config['metric'],\n+ infer_cfg['arch'])\n+\n+ yaml.dump(infer_cfg, open(os.path.join(save_dir, 'infer_cfg.yml'), 'w'))\n+ logger.info(\"Export inference config file to {}\".format(\n+ os.path.join(save_dir, 'infer_cfg.yml')))\n+\n+\n+def prune_feed_vars(feeded_var_names, target_vars, prog):\n+ \"\"\"\n+ Filter out feed variables which are not in program,\n+ pruned feed variables are only used in post processing\n+ on model output, which are not used in program, such\n+ as im_id to identify image order, im_shape to clip bbox\n+ in image.\n+ \"\"\"\n+ exist_var_names = []\n+ prog = prog.clone()\n+ prog = prog._prune(targets=target_vars)\n+ global_block = prog.global_block()\n+ for name in feeded_var_names:\n+ try:\n+ v = global_block.var(name)\n+ exist_var_names.append(str(v.name))\n+ except Exception:\n+ logger.info('save_inference_model pruned unused feed '\n+ 'variables {}'.format(name))\n+ pass\n+ return exist_var_names\n+\n+\n+def save_infer_model(FLAGS, exe, feed_vars, test_fetches, infer_prog):\n+ cfg_name = os.path.basename(FLAGS.config).split('.')[0]\n+ save_dir = os.path.join(FLAGS.output_dir, cfg_name)\n+ feed_var_names = [var.name for var in feed_vars.values()]\n+ fetch_list = sorted(test_fetches.items(), key=lambda i: i[0])\n+ target_vars = [var[1] for var in fetch_list]\n+ feed_var_names = prune_feed_vars(feed_var_names, target_vars, infer_prog)\n+ logger.info(\"Export inference model to {}, input: {}, output: \"\n+ \"{}...\".format(save_dir, feed_var_names,\n+ [str(var.name) for var in target_vars]))\n+ fluid.io.save_inference_model(\n+ save_dir,\n+ feeded_var_names=feed_var_names,\n+ target_vars=target_vars,\n+ executor=exe,\n+ main_program=infer_prog,\n+ params_filename=\"__params__\")\n" }, { "change_type": "MODIFY", "old_path": "slim/prune/export_model.py", "new_path": "slim/prune/export_model.py", "diff": "@@ -27,6 +27,7 @@ from paddle import fluid\nfrom ppdet.core.workspace import load_config, merge_config, create\nfrom ppdet.utils.cli import ArgsParser\nimport ppdet.utils.checkpoint as checkpoint\n+from ppdet.utils.export_utils import save_infer_model, dump_infer_config\nfrom ppdet.utils.check import check_config, check_version\nfrom paddleslim.prune import Pruner\nfrom paddleslim.analysis import flops\n@@ -37,47 +38,6 @@ logging.basicConfig(level=logging.INFO, format=FORMAT)\nlogger = logging.getLogger(__name__)\n-def prune_feed_vars(feeded_var_names, target_vars, prog):\n- \"\"\"\n- Filter out feed variables which are not in program,\n- pruned feed variables are only used in post processing\n- on model output, which are not used in program, such\n- as im_id to identify image order, im_shape to clip bbox\n- in image.\n- \"\"\"\n- exist_var_names = []\n- prog = prog.clone()\n- prog = prog._prune(targets=target_vars)\n- global_block = prog.global_block()\n- for name in feeded_var_names:\n- try:\n- v = global_block.var(name)\n- exist_var_names.append(str(v.name))\n- except Exception:\n- logger.info('save_inference_model pruned unused feed '\n- 'variables {}'.format(name))\n- pass\n- return exist_var_names\n-\n-\n-def save_infer_model(FLAGS, exe, feed_vars, test_fetches, infer_prog):\n- cfg_name = os.path.basename(FLAGS.config).split('.')[0]\n- save_dir = os.path.join(FLAGS.output_dir, cfg_name)\n- feed_var_names = [var.name for var in feed_vars.values()]\n- target_vars = list(test_fetches.values())\n- feed_var_names = prune_feed_vars(feed_var_names, target_vars, infer_prog)\n- logger.info(\"Export inference model to {}, input: {}, output: \"\n- \"{}...\".format(save_dir, feed_var_names,\n- [str(var.name) for var in target_vars]))\n- fluid.io.save_inference_model(\n- save_dir,\n- feeded_var_names=feed_var_names,\n- target_vars=target_vars,\n- executor=exe,\n- main_program=infer_prog,\n- params_filename=\"__params__\")\n-\n-\ndef main():\ncfg = load_config(FLAGS.config)\nmerge_config(FLAGS.opt)\n@@ -132,6 +92,7 @@ def main():\nexe.run(startup_prog)\ncheckpoint.load_checkpoint(exe, infer_prog, cfg.weights)\n+ dump_infer_config(FLAGS, cfg)\nsave_infer_model(FLAGS, exe, feed_vars, test_fetches, infer_prog)\n" }, { "change_type": "MODIFY", "old_path": "slim/quantization/export_model.py", "new_path": "slim/quantization/export_model.py", "diff": "@@ -27,6 +27,7 @@ from paddle import fluid\nfrom ppdet.core.workspace import load_config, merge_config, create\nfrom ppdet.utils.cli import ArgsParser\nimport ppdet.utils.checkpoint as checkpoint\n+from ppdet.utils.export_utils import save_infer_model, dump_infer_config\nfrom ppdet.utils.check import check_config, check_version\nfrom tools.export_model import prune_feed_vars\n@@ -37,22 +38,6 @@ logger = logging.getLogger(__name__)\nfrom paddleslim.quant import quant_aware, convert\n-def save_infer_model(save_dir, exe, feed_vars, test_fetches, infer_prog):\n- feed_var_names = [var.name for var in feed_vars.values()]\n- target_vars = list(test_fetches.values())\n- feed_var_names = prune_feed_vars(feed_var_names, target_vars, infer_prog)\n- logger.info(\"Export inference model to {}, input: {}, output: \"\n- \"{}...\".format(save_dir, feed_var_names,\n- [str(var.name) for var in target_vars]))\n- fluid.io.save_inference_model(\n- save_dir,\n- feeded_var_names=feed_var_names,\n- target_vars=target_vars,\n- executor=exe,\n- main_program=infer_prog,\n- params_filename=\"__params__\")\n-\n-\ndef main():\ncfg = load_config(FLAGS.config)\nmerge_config(FLAGS.opt)\n" }, { "change_type": "MODIFY", "old_path": "tools/export_model.py", "new_path": "tools/export_model.py", "diff": "@@ -28,179 +28,13 @@ from paddle import fluid\nfrom ppdet.core.workspace import load_config, merge_config, create\nfrom ppdet.utils.cli import ArgsParser\nimport ppdet.utils.checkpoint as checkpoint\n+from ppdet.utils.export_utils import save_infer_model, dump_infer_config\nfrom ppdet.utils.check import check_config, check_version, check_py_func\n-import yaml\nimport logging\n-from collections import OrderedDict\nFORMAT = '%(asctime)s-%(levelname)s: %(message)s'\nlogging.basicConfig(level=logging.INFO, format=FORMAT)\nlogger = logging.getLogger(__name__)\n-# Global dictionary\n-TRT_MIN_SUBGRAPH = {\n- 'YOLO': 3,\n- 'SSD': 3,\n- 'RCNN': 40,\n- 'RetinaNet': 40,\n- 'EfficientDet': 40,\n- 'Face': 3,\n- 'TTFNet': 3,\n- 'FCOS': 3,\n- 'SOLOv2': 3,\n-}\n-RESIZE_SCALE_SET = {\n- 'RCNN',\n- 'RetinaNet',\n- 'FCOS',\n- 'SOLOv2',\n-}\n-\n-\n-def parse_reader(reader_cfg, metric, arch):\n- preprocess_list = []\n-\n- image_shape = reader_cfg['inputs_def'].get('image_shape', [3, None, None])\n- has_shape_def = not None in image_shape\n-\n- dataset = reader_cfg['dataset']\n- anno_file = dataset.get_anno()\n- with_background = dataset.with_background\n- use_default_label = dataset.use_default_label\n-\n- if metric == 'COCO':\n- from ppdet.utils.coco_eval import get_category_info\n- elif metric == \"VOC\":\n- from ppdet.utils.voc_eval import get_category_info\n- elif metric == \"WIDERFACE\":\n- from ppdet.utils.widerface_eval_utils import get_category_info\n- else:\n- raise ValueError(\n- \"metric only supports COCO, VOC, WIDERFACE, but received {}\".format(\n- metric))\n- clsid2catid, catid2name = get_category_info(anno_file, with_background,\n- use_default_label)\n-\n- label_list = [str(cat) for cat in catid2name.values()]\n-\n- sample_transforms = reader_cfg['sample_transforms']\n- for st in sample_transforms[1:]:\n- method = st.__class__.__name__\n- p = {'type': method.replace('Image', '')}\n- params = st.__dict__\n- params.pop('_id')\n- if p['type'] == 'Resize' and has_shape_def:\n- params['target_size'] = min(image_shape[\n- 1:]) if arch in RESIZE_SCALE_SET else image_shape[1]\n- params['max_size'] = max(image_shape[\n- 1:]) if arch in RESIZE_SCALE_SET else 0\n- params['image_shape'] = image_shape[1:]\n- if 'target_dim' in params:\n- params.pop('target_dim')\n- if p['type'] == 'ResizeAndPad':\n- assert has_shape_def, \"missing input shape\"\n- p['type'] = 'Resize'\n- p['target_size'] = params['target_dim']\n- p['max_size'] = params['target_dim']\n- p['interp'] = params['interp']\n- p['image_shape'] = image_shape[1:]\n- preprocess_list.append(p)\n- continue\n- p.update(params)\n- preprocess_list.append(p)\n- batch_transforms = reader_cfg.get('batch_transforms', None)\n- if batch_transforms:\n- methods = [bt.__class__.__name__ for bt in batch_transforms]\n- for bt in batch_transforms:\n- method = bt.__class__.__name__\n- if method == 'PadBatch':\n- preprocess_list.append({'type': 'PadStride'})\n- params = bt.__dict__\n- preprocess_list[-1].update({'stride': params['pad_to_stride']})\n- break\n-\n- return with_background, preprocess_list, label_list\n-\n-\n-def dump_infer_config(FLAGS, config):\n- arch_state = 0\n- cfg_name = os.path.basename(FLAGS.config).split('.')[0]\n- save_dir = os.path.join(FLAGS.output_dir, cfg_name)\n- if not os.path.exists(save_dir):\n- os.makedirs(save_dir)\n- from ppdet.core.config.yaml_helpers import setup_orderdict\n- setup_orderdict()\n- infer_cfg = OrderedDict({\n- 'use_python_inference': False,\n- 'mode': 'fluid',\n- 'draw_threshold': 0.5,\n- 'metric': config['metric']\n- })\n- infer_arch = config['architecture']\n-\n- for arch, min_subgraph_size in TRT_MIN_SUBGRAPH.items():\n- if arch in infer_arch:\n- infer_cfg['arch'] = arch\n- infer_cfg['min_subgraph_size'] = min_subgraph_size\n- arch_state = 1\n- break\n- if not arch_state:\n- logger.error(\n- 'Architecture: {} is not supported for exporting model now'.format(\n- infer_arch))\n- os._exit(0)\n-\n- if 'Mask' in config['architecture']:\n- infer_cfg['mask_resolution'] = config['MaskHead']['resolution']\n- infer_cfg['with_background'], infer_cfg['Preprocess'], infer_cfg[\n- 'label_list'] = parse_reader(config['TestReader'], config['metric'],\n- infer_cfg['arch'])\n-\n- yaml.dump(infer_cfg, open(os.path.join(save_dir, 'infer_cfg.yml'), 'w'))\n- logger.info(\"Export inference config file to {}\".format(\n- os.path.join(save_dir, 'infer_cfg.yml')))\n-\n-\n-def prune_feed_vars(feeded_var_names, target_vars, prog):\n- \"\"\"\n- Filter out feed variables which are not in program,\n- pruned feed variables are only used in post processing\n- on model output, which are not used in program, such\n- as im_id to identify image order, im_shape to clip bbox\n- in image.\n- \"\"\"\n- exist_var_names = []\n- prog = prog.clone()\n- prog = prog._prune(targets=target_vars)\n- global_block = prog.global_block()\n- for name in feeded_var_names:\n- try:\n- v = global_block.var(name)\n- exist_var_names.append(str(v.name))\n- except Exception:\n- logger.info('save_inference_model pruned unused feed '\n- 'variables {}'.format(name))\n- pass\n- return exist_var_names\n-\n-\n-def save_infer_model(FLAGS, exe, feed_vars, test_fetches, infer_prog):\n- cfg_name = os.path.basename(FLAGS.config).split('.')[0]\n- save_dir = os.path.join(FLAGS.output_dir, cfg_name)\n- feed_var_names = [var.name for var in feed_vars.values()]\n- fetch_list = sorted(test_fetches.items(), key=lambda i: i[0])\n- target_vars = [var[1] for var in fetch_list]\n- feed_var_names = prune_feed_vars(feed_var_names, target_vars, infer_prog)\n- logger.info(\"Export inference model to {}, input: {}, output: \"\n- \"{}...\".format(save_dir, feed_var_names,\n- [str(var.name) for var in target_vars]))\n- fluid.io.save_inference_model(\n- save_dir,\n- feeded_var_names=feed_var_names,\n- target_vars=target_vars,\n- executor=exe,\n- main_program=infer_prog,\n- params_filename=\"__params__\")\n-\ndef main():\ncfg = load_config(FLAGS.config)\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
add infer_cfg export in slim export_model (#1554)
499,304
20.10.2020 12:54:51
-28,800
625c986302e32eafa12b684a054b686b7da1ebdd
update htc_r50_fpn model
[ { "change_type": "MODIFY", "old_path": "configs/htc/README.md", "new_path": "configs/htc/README.md", "diff": "@@ -23,4 +23,4 @@ The results on COCO 2017val are shown in the below table. (results on test-dev a\n| Backbone | Lr schd | Inf time (fps) | box AP | mask AP | Download |\n|:---------:|:-------:|:--------------:|:------:|:-------:|:--------:|\n- | R-50-FPN | 1x | 11 | 42.7 | 36.8 | [model](https://paddlemodels.bj.bcebos.com/object_detection/htc_r50_fpn_1x.pdparams ) |\n+ | R-50-FPN | 1x | 11 | 42.9 | 37.0 | [model](https://paddlemodels.bj.bcebos.com/object_detection/htc_r50_fpn_1x.pdparams ) |\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
update htc_r50_fpn model (#1580)
499,304
21.10.2020 14:36:09
-28,800
fb516ca404829c0a5e361c21d5c24db254439594
delete pact in eval,infer,export_model
[ { "change_type": "ADD", "old_path": null, "new_path": "slim/quantization/pact.py", "diff": "+# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+# http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+\n+import sys\n+import paddle\n+import paddle.fluid as fluid\n+from paddleslim.quant import quant_aware, convert\n+import numpy as np\n+\n+from paddle.fluid.layer_helper import LayerHelper\n+\n+\n+def pact(x, name=None):\n+ helper = LayerHelper(\"pact\", **locals())\n+ dtype = 'float32'\n+ init_thres = 20\n+ u_param_attr = fluid.ParamAttr(\n+ name=x.name + '_pact',\n+ initializer=fluid.initializer.ConstantInitializer(value=init_thres),\n+ regularizer=fluid.regularizer.L2Decay(0.0001),\n+ learning_rate=1)\n+ u_param = helper.create_parameter(attr=u_param_attr, shape=[1], dtype=dtype)\n+ x = fluid.layers.elementwise_sub(\n+ x, fluid.layers.relu(fluid.layers.elementwise_sub(x, u_param)))\n+ x = fluid.layers.elementwise_add(\n+ x, fluid.layers.relu(fluid.layers.elementwise_sub(-u_param, x)))\n+\n+ return x\n+\n+\n+def get_optimizer():\n+ return fluid.optimizer.MomentumOptimizer(0.0001, 0.9)\n" }, { "change_type": "MODIFY", "old_path": "slim/quantization/train.py", "new_path": "slim/quantization/train.py", "diff": "@@ -39,6 +39,7 @@ from ppdet.utils.cli import ArgsParser\nfrom ppdet.utils.check import check_gpu, check_version, check_config\nimport ppdet.utils.checkpoint as checkpoint\nfrom paddleslim.quant import quant_aware, convert\n+from pact import pact, get_optimizer\nimport logging\nFORMAT = '%(asctime)s-%(levelname)s: %(message)s'\nlogging.basicConfig(level=logging.INFO, format=FORMAT)\n@@ -51,14 +52,6 @@ def save_checkpoint(exe, prog, path, train_prog):\nlogger.info('Save model to {}.'.format(path))\nfluid.io.save_persistables(exe, path, main_program=prog)\n- v = train_prog.global_block().var('@LR_DECAY_COUNTER@')\n- fluid.io.save_vars(exe, dirname=path, vars=[v])\n-\n-\n-def load_global_step(exe, prog, path):\n- v = prog.global_block().var('@LR_DECAY_COUNTER@')\n- fluid.io.load_vars(exe, path, prog, [v])\n-\ndef main():\nif FLAGS.eval is False:\n@@ -105,9 +98,10 @@ def main():\nwith fluid.program_guard(train_prog, startup_prog):\nwith fluid.unique_name.guard():\nmodel = create(main_arch)\n-\ninputs_def = cfg['TrainReader']['inputs_def']\nfeed_vars, train_loader = model.build_inputs(**inputs_def)\n+ if FLAGS.use_pact:\n+ feed_vars['image'].stop_gradient = False\ntrain_fetches = model.train(feed_vars)\nloss = train_fetches['loss']\nlr = lr_builder()\n@@ -181,17 +175,30 @@ def main():\nfuse_bn = getattr(model.backbone, 'norm_type', None) == 'affine_channel'\n- if not FLAGS.resume_checkpoint:\nif cfg.pretrain_weights and fuse_bn and not ignore_params:\ncheckpoint.load_and_fusebn(exe, train_prog, cfg.pretrain_weights)\nelif cfg.pretrain_weights:\ncheckpoint.load_params(\n- exe,\n- train_prog,\n- cfg.pretrain_weights,\n- ignore_params=ignore_params)\n+ exe, train_prog, cfg.pretrain_weights, ignore_params=ignore_params)\n+\n+ if FLAGS.use_pact:\n+ act_preprocess_func = pact\n+ optimizer_func = get_optimizer\n+ executor = exe\n+ else:\n+ act_preprocess_func = None\n+ optimizer_func = None\n+ executor = None\n# insert quantize op in train_prog, return type is CompiledProgram\n- train_prog_quant = quant_aware(train_prog, place, config, for_test=False)\n+ train_prog_quant = quant_aware(\n+ train_prog,\n+ place,\n+ config,\n+ scope=None,\n+ act_preprocess_func=act_preprocess_func,\n+ optimizer_func=optimizer_func,\n+ executor=executor,\n+ for_test=False)\ncompiled_train_prog = train_prog_quant.with_data_parallel(\nloss_name=loss.name,\n@@ -200,14 +207,18 @@ def main():\nif FLAGS.eval:\n# insert quantize op in eval_prog\n- eval_prog = quant_aware(eval_prog, place, config, for_test=True)\n+ eval_prog = quant_aware(\n+ eval_prog,\n+ place,\n+ config,\n+ scope=None,\n+ act_preprocess_func=act_preprocess_func,\n+ optimizer_func=optimizer_func,\n+ executor=executor,\n+ for_test=True)\ncompiled_eval_prog = fluid.CompiledProgram(eval_prog)\nstart_iter = 0\n- if FLAGS.resume_checkpoint:\n- checkpoint.load_checkpoint(exe, eval_prog, FLAGS.resume_checkpoint)\n- load_global_step(exe, train_prog, FLAGS.resume_checkpoint)\n- start_iter = checkpoint.global_step()\ntrain_reader = create_reader(cfg.TrainReader,\n(cfg.max_iters - start_iter) * devices_num)\n@@ -253,8 +264,6 @@ def main():\nif (it > 0 and it % cfg.snapshot_iter == 0 or it == cfg.max_iters - 1) \\\nand (not FLAGS.dist or trainer_id == 0):\nsave_name = str(it) if it != cfg.max_iters - 1 else \"model_final\"\n- save_checkpoint(exe, eval_prog,\n- os.path.join(save_dir, save_name), train_prog)\nif FLAGS.eval:\n# evaluation\n@@ -288,12 +297,6 @@ def main():\nif __name__ == '__main__':\nparser = ArgsParser()\n- parser.add_argument(\n- \"-r\",\n- \"--resume_checkpoint\",\n- default=None,\n- type=str,\n- help=\"Checkpoint path for resuming training.\")\nparser.add_argument(\n\"--loss_scale\",\ndefault=8.,\n@@ -315,5 +318,7 @@ if __name__ == '__main__':\ntype=str,\nhelp=\"Layers which name_scope contains string in not_quant_pattern will not be quantized\"\n)\n+ parser.add_argument(\n+ \"--use_pact\", nargs='+', type=bool, help=\"Whether to use PACT or not.\")\nFLAGS = parser.parse_args()\nmain()\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
delete pact in eval,infer,export_model (#1584)
499,395
21.10.2020 16:54:30
-28,800
7fd1f891eaad7c484fcabef9ca2d723e2cc41001
modify MkDir function to fix bugs
[ { "change_type": "MODIFY", "old_path": "deploy/cpp/src/main.cc", "new_path": "deploy/cpp/src/main.cc", "diff": "@@ -54,8 +54,7 @@ static bool PathExists(const std::string& path){\n}\nstatic void MkDir(const std::string& path) {\n- std::string path_error(path);\n- path_error += \" mkdir failed!\";\n+ if (PathExists(path)) return;\nint ret = 0;\n#ifdef _WIN32\nret = _mkdir(path.c_str());\n@@ -63,6 +62,8 @@ static void MkDir(const std::string& path) {\nret = mkdir(path.c_str(), 0755);\n#endif // !_WIN32\nif (ret != 0) {\n+ std::string path_error(path);\n+ path_error += \" mkdir failed!\";\nthrow std::runtime_error(path_error);\n}\n}\n@@ -169,8 +170,13 @@ void PredictImage(const std::string& image_path,\nstd::vector<int> compression_params;\ncompression_params.push_back(CV_IMWRITE_JPEG_QUALITY);\ncompression_params.push_back(95);\n- cv::imwrite(output_dir + OS_PATH_SEP + \"output.jpg\", vis_img, compression_params);\n- printf(\"Visualized output saved as output.jpg\\n\");\n+ std::string output_path(output_dir);\n+ if (output_dir.rfind(OS_PATH_SEP) != output_dir.size() - 1) {\n+ output_path += OS_PATH_SEP;\n+ }\n+ output_path += \"output.jpg\";\n+ cv::imwrite(output_path, vis_img, compression_params);\n+ printf(\"Visualized output saved as %s\\n\", output_path.c_str());\n}\n}\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
modify MkDir function to fix bugs (#1590)
499,333
23.10.2020 00:16:15
-28,800
3a48c5624a140a3892706a9a2e042b001b26731c
fix cascade series models
[ { "change_type": "MODIFY", "old_path": "ppdet/modeling/architectures/cascade_mask_rcnn.py", "new_path": "ppdet/modeling/architectures/cascade_mask_rcnn.py", "diff": "@@ -135,6 +135,7 @@ class CascadeMaskRCNN(object):\nproposals = None\nbbox_pred = None\n+ max_overlap = None\nfor i in range(3):\nif i > 0:\nrefined_bbox = self._decode_box(\n@@ -146,10 +147,14 @@ class CascadeMaskRCNN(object):\nif mode == 'train':\nouts = self.bbox_assigner(\n- input_rois=refined_bbox, feed_vars=feed_vars, curr_stage=i)\n+ input_rois=refined_bbox,\n+ feed_vars=feed_vars,\n+ curr_stage=i,\n+ max_overlap=max_overlap)\nproposals = outs[0]\n- rcnn_target_list.append(outs)\n+ max_overlap = outs[-1]\n+ rcnn_target_list.append(outs[:-1])\nelse:\nproposals = refined_bbox\nproposal_list.append(proposals)\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/architectures/cascade_rcnn.py", "new_path": "ppdet/modeling/architectures/cascade_rcnn.py", "diff": "@@ -128,6 +128,7 @@ class CascadeRCNN(object):\nproposals = None\nbbox_pred = None\n+ max_overlap = None\nfor i in range(3):\nif i > 0:\nrefined_bbox = self._decode_box(\n@@ -139,10 +140,14 @@ class CascadeRCNN(object):\nif mode == 'train':\nouts = self.bbox_assigner(\n- input_rois=refined_bbox, feed_vars=feed_vars, curr_stage=i)\n+ input_rois=refined_bbox,\n+ feed_vars=feed_vars,\n+ curr_stage=i,\n+ max_overlap=max_overlap)\nproposals = outs[0]\n- rcnn_target_list.append(outs)\n+ max_overlap = outs[-1]\n+ rcnn_target_list.append(outs[:-1])\nelse:\nproposals = refined_bbox\nproposal_list.append(proposals)\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/architectures/cascade_rcnn_cls_aware.py", "new_path": "ppdet/modeling/architectures/cascade_rcnn_cls_aware.py", "diff": "@@ -117,6 +117,7 @@ class CascadeRCNNClsAware(object):\nself.cascade_decoded_box = []\nself.cascade_cls_prob = []\n+ max_overlap = None\nfor stage in range(3):\nif stage > 0:\n@@ -126,9 +127,13 @@ class CascadeRCNNClsAware(object):\nif mode == \"train\":\nself.cascade_var_v[stage].stop_gradient = True\nouts = self.bbox_assigner(\n- input_rois=pool_rois, feed_vars=feed_vars, curr_stage=stage)\n+ input_rois=pool_rois,\n+ feed_vars=feed_vars,\n+ curr_stage=stage,\n+ max_overlap=max_overlap)\npool_rois = outs[0]\n- rcnn_target_list.append(outs)\n+ max_overlap = outs[-1]\n+ rcnn_target_list.append(outs[:-1])\n# extract roi features\nroi_feat = self.roi_extractor(body_feats, pool_rois, spatial_scale)\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/architectures/htc.py", "new_path": "ppdet/modeling/architectures/htc.py", "diff": "@@ -158,13 +158,18 @@ class HybridTaskCascade(object):\nbbox_pred = None\nouts = None\nrefined_bbox = rpn_rois\n+ max_overlap = None\nfor i in range(self.num_stage):\n# BBox Branch\nif mode == 'train':\nouts = self.bbox_assigner(\n- input_rois=refined_bbox, feed_vars=feed_vars, curr_stage=i)\n+ input_rois=refined_bbox,\n+ feed_vars=feed_vars,\n+ curr_stage=i,\n+ max_overlap=max_overlap)\nproposals = outs[0]\n- rcnn_target_list.append(outs)\n+ max_overlap = outs[-1]\n+ rcnn_target_list.append(outs[:-1])\nelse:\nproposals = refined_bbox\nproposal_list.append(proposals)\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/target_assigners.py", "new_path": "ppdet/modeling/target_assigners.py", "diff": "@@ -53,7 +53,7 @@ class CascadeBBoxAssigner(object):\nself.use_random = shuffle_before_sample\nself.class_aware = class_aware\n- def __call__(self, input_rois, feed_vars, curr_stage):\n+ def __call__(self, input_rois, feed_vars, curr_stage, max_overlap=None):\ncurr_bbox_reg_w = [\n1. / self.bbox_reg_weights[curr_stage],\n@@ -76,5 +76,7 @@ class CascadeBBoxAssigner(object):\nclass_nums=self.class_nums if self.class_aware else 2,\nis_cls_agnostic=not self.class_aware,\nis_cascade_rcnn=True\n- if curr_stage > 0 and not self.class_aware else False)\n+ if curr_stage > 0 and not self.class_aware else False,\n+ max_overlap=max_overlap,\n+ return_max_overlap=True)\nreturn outs\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix cascade series models (#1588)
499,304
26.10.2020 20:15:53
-28,800
c3c453384ae43229c1371201a59b925e8ef71ebe
fix save_infer_model in quant export_model
[ { "change_type": "MODIFY", "old_path": "slim/quantization/export_model.py", "new_path": "slim/quantization/export_model.py", "diff": "@@ -30,7 +30,6 @@ from ppdet.utils.cli import ArgsParser\nimport ppdet.utils.checkpoint as checkpoint\nfrom ppdet.utils.export_utils import save_infer_model, dump_infer_config\nfrom ppdet.utils.check import check_config, check_version\n-from tools.export_model import prune_feed_vars\nimport logging\nFORMAT = '%(asctime)s-%(levelname)s: %(message)s'\n@@ -81,13 +80,11 @@ def main():\ninfer_prog, int8_program = convert(\ninfer_prog, place, config, save_int8=True)\n- save_infer_model(\n- os.path.join(FLAGS.output_dir, 'float'), exe, feed_vars, test_fetches,\n- infer_prog)\n+ FLAGS.output_dir = os.path.join(FLAGS.output_dir, 'float')\n+ save_infer_model(FLAGS, exe, feed_vars, test_fetches, infer_prog)\n- save_infer_model(\n- os.path.join(FLAGS.output_dir, 'int'), exe, feed_vars, test_fetches,\n- int8_program)\n+ FLAGS.output_dir = os.path.join(FLAGS.output_dir, 'int')\n+ save_infer_model(FLAGS, exe, feed_vars, test_fetches, int8_program)\nif __name__ == '__main__':\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix save_infer_model in quant export_model (#1604)
499,333
29.10.2020 21:27:14
-28,800
6417474551a695da872d4b272a356ca405a1d316
filter invalid segmentation in data source
[ { "change_type": "MODIFY", "old_path": "ppdet/data/source/coco.py", "new_path": "ppdet/data/source/coco.py", "diff": "@@ -137,7 +137,12 @@ class COCODataSet(DataSet):\ny1 = max(0, y)\nx2 = min(im_w - 1, x1 + max(0, box_w - 1))\ny2 = min(im_h - 1, y1 + max(0, box_h - 1))\n- if x2 >= x1 and y2 >= y1:\n+ if 'segmentation' in inst and len(inst[\n+ 'segmentation']) == 0:\n+ logger.warn(\n+ 'Found an empty segmentation in annotations: im_id: {}.'.\n+ format(img_id))\n+ elif x2 >= x1 and y2 >= y1:\ninst['clean_bbox'] = [x1, y1, x2, y2]\nbboxes.append(inst)\nelse:\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
filter invalid segmentation in data source (#1630)
499,333
30.10.2020 13:02:35
-28,800
eb6d119659220fb3409456327e2bfde85a6ecc37
enhance data check
[ { "change_type": "MODIFY", "old_path": "ppdet/data/source/coco.py", "new_path": "ppdet/data/source/coco.py", "diff": "@@ -137,12 +137,14 @@ class COCODataSet(DataSet):\ny1 = max(0, y)\nx2 = min(im_w - 1, x1 + max(0, box_w - 1))\ny2 = min(im_h - 1, y1 + max(0, box_h - 1))\n- if 'segmentation' in inst and len(inst[\n+ if 'segmentation' in inst:\n+ if inst['segmentation'] is None or len(inst[\n'segmentation']) == 0:\nlogger.warn(\n'Found an empty segmentation in annotations: im_id: {}.'.\nformat(img_id))\n- elif x2 >= x1 and y2 >= y1:\n+ continue\n+ if x2 >= x1 and y2 >= y1:\ninst['clean_bbox'] = [x1, y1, x2, y2]\nbboxes.append(inst)\nelse:\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
enhance data check (#1635)
499,304
02.11.2020 16:48:24
-28,800
957b3d13674fd93a2baab0b053944f61dfee4e88
fix quant train TrainReader error
[ { "change_type": "MODIFY", "old_path": "slim/quantization/train.py", "new_path": "slim/quantization/train.py", "diff": "@@ -60,7 +60,10 @@ def main():\n\"Currently only supports `--eval==True` while training in `quantization`.\"\n)\nenv = os.environ\n- FLAGS.dist = 'PADDLE_TRAINER_ID' in env and 'PADDLE_TRAINERS_NUM' in env\n+ FLAGS.dist = 'PADDLE_TRAINER_ID' in env \\\n+ and 'PADDLE_TRAINERS_NUM' in env \\\n+ and int(env['PADDLE_TRAINERS_NUM']) > 1\n+ num_trainers = int(env.get('PADDLE_TRAINERS_NUM', 1))\nif FLAGS.dist:\ntrainer_id = int(env['PADDLE_TRAINER_ID'])\nimport random\n@@ -221,8 +224,11 @@ def main():\nstart_iter = 0\n- train_reader = create_reader(cfg.TrainReader,\n- (cfg.max_iters - start_iter) * devices_num)\n+ train_reader = create_reader(\n+ cfg.TrainReader, (cfg.max_iters - start_iter) * devices_num,\n+ cfg,\n+ devices_num=devices_num,\n+ num_trainers=num_trainers)\n# When iterable mode, set set_sample_list_generator(train_reader, place)\ntrain_loader.set_sample_list_generator(train_reader)\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix quant train TrainReader error (#1638)
499,304
03.11.2020 18:20:03
-28,800
83b7a748fb9aac5ae08c3df4fbd3ddc925b78040
fix some solov2 inference error
[ { "change_type": "MODIFY", "old_path": "configs/solov2/README.md", "new_path": "configs/solov2/README.md", "diff": "@@ -12,17 +12,17 @@ SOLOv2 (Segmenting Objects by Locations) is a fast instance segmentation framewo\n## Model Zoo\n-| Backbone | Multi-scale training | Lr schd | Inf time (V100) | Mask AP | Download | Configs |\n+| Backbone | Multi-scale training | Lr schd | V100 FP32(FPS) | Mask AP | Download | Configs |\n| :---------------------: | :-------------------: | :-----: | :------------: | :-----: | :---------: | :------------------------: |\n-| Mobilenetv3-FPN | True | 3x | 20.0ms | 30.0 | [model](https://paddlemodels.bj.bcebos.com/object_detection/solov2_mobilenetv3_fpn_448_3x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/solov2/solov2_mobilenetv3_fpn_448_3x.yml) |\n-| R50-FPN | False | 1x | 45.7ms | 35.6 | [model](https://paddlemodels.bj.bcebos.com/object_detection/solov2_r50_fpn_1x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/solov2/solov2_r50_fpn_1x.yml) |\n-| R50-FPN | True | 3x | 45.7ms | 37.9 | [model](https://paddlemodels.bj.bcebos.com/object_detection/solov2_r50_fpn_3x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/solov2/solov2_r50_fpn_3x.yml) |\n-| R101-VD-FPN | True | 3x | 82.6ms | 42.6 | [model](https://paddlemodels.bj.bcebos.com/object_detection/solov2_r101_vd_fpn_3x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/solov2/solov2_r101_vd_fpn_3x.yml) |\n+| Mobilenetv3-FPN | True | 3x | 50 | 30.0 | [model](https://paddlemodels.bj.bcebos.com/object_detection/solov2_mobilenetv3_fpn_448_3x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/solov2/solov2_mobilenetv3_fpn_448_3x.yml) |\n+| R50-FPN | False | 1x | 21.9 | 35.6 | [model](https://paddlemodels.bj.bcebos.com/object_detection/solov2_r50_fpn_1x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/solov2/solov2_r50_fpn_1x.yml) |\n+| R50-FPN | True | 3x | 21.9 | 37.9 | [model](https://paddlemodels.bj.bcebos.com/object_detection/solov2_r50_fpn_3x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/solov2/solov2_r50_fpn_3x.yml) |\n+| R101-VD-FPN | True | 3x | 12.1 | 42.6 | [model](https://paddlemodels.bj.bcebos.com/object_detection/solov2_r101_vd_fpn_3x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/solov2/solov2_r101_vd_fpn_3x.yml) |\n## Enhanced model\n-| Backbone | Input size | Lr schd | Inf time (V100) | Mask AP | Download | Configs |\n+| Backbone | Input size | Lr schd | V100 FP32(FPS) | Mask AP | Download | Configs |\n| :---------------------: | :-------------------: | :-----: | :------------: | :-----: | :---------: | :------------------------: |\n-| Light-R50-VD-DCN-FPN | 512 | 3x | 25.9ms | 38.8 | [model](https://paddlemodels.bj.bcebos.com/object_detection/solov2_light_r50_vd_fpn_dcn_512_3x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/solov2/solov2_light_r50_vd_fpn_dcn_512_3x.yml) |\n+| Light-R50-VD-DCN-FPN | 512 | 3x | 38.6 | 38.8 | [model](https://paddlemodels.bj.bcebos.com/object_detection/solov2_light_r50_vd_fpn_dcn_512_3x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/solov2/solov2_light_r50_vd_fpn_dcn_512_3x.yml) |\n## Citations\n```\n" }, { "change_type": "MODIFY", "old_path": "deploy/python/infer.py", "new_path": "deploy/python/infer.py", "diff": "@@ -41,7 +41,7 @@ SUPPORT_MODELS = {\n}\n-class Detector():\n+class Detector(object):\n\"\"\"\nArgs:\nconfig (object): config of model, defined by `Config(model_dir)`\n" }, { "change_type": "MODIFY", "old_path": "ppdet/utils/export_utils.py", "new_path": "ppdet/utils/export_utils.py", "diff": "@@ -38,7 +38,7 @@ TRT_MIN_SUBGRAPH = {\n'Face': 3,\n'TTFNet': 3,\n'FCOS': 3,\n- 'SOLOv2': 3,\n+ 'SOLOv2': 60,\n}\nRESIZE_SCALE_SET = {\n'RCNN',\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix some solov2 inference error (#1648)
499,304
05.11.2020 19:49:36
-28,800
0239a6f10ae5f051aa8391a1ca9f050096e076c6
fix some video inference bug in deploy
[ { "change_type": "MODIFY", "old_path": "deploy/python/infer.py", "new_path": "deploy/python/infer.py", "diff": "@@ -71,10 +71,11 @@ class Detector(object):\ndef preprocess(self, im):\npreprocess_ops = []\nfor op_info in self.config.preprocess_infos:\n- op_type = op_info.pop('type')\n+ new_op_info = op_info.copy()\n+ op_type = new_op_info.pop('type')\nif op_type == 'Resize':\n- op_info['arch'] = self.config.arch\n- preprocess_ops.append(eval(op_type)(**op_info))\n+ new_op_info['arch'] = self.config.arch\n+ preprocess_ops.append(eval(op_type)(**new_op_info))\nim, im_info = preprocess(im, preprocess_ops)\ninputs = create_inputs(im, im_info, self.config.arch)\nreturn inputs, im_info\n@@ -481,7 +482,8 @@ def predict_video(detector, camera_id):\nframe,\nresults,\ndetector.config.labels,\n- mask_resolution=detector.config.mask_resolution)\n+ mask_resolution=detector.config.mask_resolution,\n+ threshold=FLAGS.threshold)\nim = np.array(im)\nwriter.write(im)\nif camera_id != -1:\n" }, { "change_type": "MODIFY", "old_path": "deploy/python/visualize.py", "new_path": "deploy/python/visualize.py", "diff": "@@ -228,9 +228,22 @@ def draw_segm(im,\ncolor_mask = np.array(color_mask)\nim[idx[0], idx[1], :] *= 1.0 - alpha\nim[idx[0], idx[1], :] += alpha * color_mask\n- center_y, center_x = ndimage.measurements.center_of_mass(mask)\n- label_text = \"{}\".format(labels[clsid])\n- vis_pos = (max(int(center_x) - 10, 0), int(center_y))\n- cv2.putText(im, label_text, vis_pos, cv2.FONT_HERSHEY_COMPLEX, 0.3,\n- (255, 255, 255))\n+ sum_x = np.sum(mask, axis=0)\n+ x = np.where(sum_x > 0.5)[0]\n+ sum_y = np.sum(mask, axis=1)\n+ y = np.where(sum_y > 0.5)[0]\n+ x0, x1, y0, y1 = x[0], x[-1], y[0], y[-1]\n+ cv2.rectangle(im, (x0, y0), (x1, y1),\n+ tuple(color_mask.astype('int32').tolist()), 1)\n+ bbox_text = '%s %.2f' % (labels[clsid], score)\n+ t_size = cv2.getTextSize(bbox_text, 0, 0.3, thickness=1)[0]\n+ cv2.rectangle(im, (x0, y0), (x0 + t_size[0], y0 - t_size[1] - 3),\n+ tuple(color_mask.astype('int32').tolist()), -1)\n+ cv2.putText(\n+ im,\n+ bbox_text, (x0, y0 - 2),\n+ cv2.FONT_HERSHEY_SIMPLEX,\n+ 0.3, (0, 0, 0),\n+ 1,\n+ lineType=cv2.LINE_AA)\nreturn Image.fromarray(im.astype('uint8'))\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix some video inference bug in deploy (#1655)
499,313
06.11.2020 17:48:09
-28,800
6f15306d96c58f615dff9ee0be99e4ad16046d8b
update map_fps.png
[ { "change_type": "MODIFY", "old_path": "README_en.md", "new_path": "README_en.md", "diff": "@@ -13,8 +13,8 @@ image object detection, and automatic inspection with its practical features suc\nand multi-platform deployment.\n[PP-YOLO](https://arxiv.org/abs/2007.12099), which is faster and has higer performance than YOLOv4,\n-has been released, it reached mAP(0.5:0.95) as 45.2% on COCO test2019 dataset and 72.9 FPS on single\n-Test V100. Please refer to [PP-YOLO](configs/ppyolo/README.md) for details.\n+has been released, it reached mAP(0.5:0.95) as 45.2%(newest 45.9%) on COCO test2019 dataset and\n+72.9 FPS on single Test V100. Please refer to [PP-YOLO](configs/ppyolo/README.md) for details.\n**Now all models in PaddleDetection require PaddlePaddle version 1.8 or higher, or suitable develop version.**\n" }, { "change_type": "MODIFY", "old_path": "docs/images/map_fps.png", "new_path": "docs/images/map_fps.png", "diff": "Binary files a/docs/images/map_fps.png and b/docs/images/map_fps.png differ\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
update map_fps.png (#1669)
499,304
10.11.2020 13:26:09
-28,800
f8f91d043f910ef67b83de5c5721c48ba6578ba8
remove segmentation field in voc2coco
[ { "change_type": "MODIFY", "old_path": "tools/x2coco.py", "new_path": "tools/x2coco.py", "diff": "@@ -246,7 +246,6 @@ def voc_get_coco_annotation(obj, label2id):\n'bbox': [xmin, ymin, o_width, o_height],\n'category_id': category_id,\n'ignore': 0,\n- 'segmentation': [] # This script is not for segmentation\n}\nreturn anno\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
remove segmentation field in voc2coco (#1667)
499,333
10.11.2020 15:54:19
-28,800
53da7ffdf834eff0fee9edc33fafc0e4f735c1d0
remove segm filter
[ { "change_type": "MODIFY", "old_path": "ppdet/data/source/coco.py", "new_path": "ppdet/data/source/coco.py", "diff": "@@ -137,13 +137,6 @@ class COCODataSet(DataSet):\ny1 = max(0, y)\nx2 = min(im_w - 1, x1 + max(0, box_w - 1))\ny2 = min(im_h - 1, y1 + max(0, box_h - 1))\n- if 'segmentation' in inst:\n- if inst['segmentation'] is None or len(inst[\n- 'segmentation']) == 0:\n- logger.warn(\n- 'Found an empty segmentation in annotations: im_id: {}.'.\n- format(img_id))\n- continue\nif x2 >= x1 and y2 >= y1:\ninst['clean_bbox'] = [x1, y1, x2, y2]\nbboxes.append(inst)\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
remove segm filter (#1682)
499,304
19.11.2020 18:15:16
-28,800
6ffa0c6cf29ccee195a396919a29da24f9322292
set deploy python path
[ { "change_type": "MODIFY", "old_path": "deploy/python/infer.py", "new_path": "deploy/python/infer.py", "diff": "# See the License for the specific language governing permissions and\n# limitations under the License.\n-import os\n+from __future__ import absolute_import\n+from __future__ import division\n+from __future__ import print_function\n+\n+import os, sys\n+# add python path of PadleDetection to sys.path\n+parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3)))\n+if parent_path not in sys.path:\n+ sys.path.append(parent_path)\n+\nimport argparse\nimport time\nimport yaml\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
set deploy python path (#1723)
499,313
19.11.2020 18:57:02
-28,800
3edc7d50718c25cd339c84a5726bd401d993c457
fix remove weights on re-download
[ { "change_type": "MODIFY", "old_path": "ppdet/utils/download.py", "new_path": "ppdet/utils/download.py", "diff": "@@ -213,7 +213,10 @@ def get_path(url, root_dir, md5sum=None, check_exist=True):\nlogger.debug(\"Found {}\".format(fullpath))\nreturn fullpath, True\nelse:\n+ if osp.isdir(fullpath):\nshutil.rmtree(fullpath)\n+ else:\n+ os.remove(fullpath)\nfullname = _download(url, root_dir, md5sum)\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix remove weights on re-download (#1721)
499,304
20.11.2020 19:15:53
-28,800
96f0b94f3fc3b90b86668e344b525eb4b3737c4f
fix htc inference & deploy
[ { "change_type": "MODIFY", "old_path": "configs/htc/htc_r50_fpn_1x.yml", "new_path": "configs/htc/htc_r50_fpn_1x.yml", "diff": "@@ -212,3 +212,14 @@ TestReader:\n- !ResizeImage\ninterp: 1\nmax_size: 1333\n+ target_size: 800\n+ use_cv2: true\n+ - !Permute\n+ channel_first: true\n+ to_bgr: false\n+ batch_transforms:\n+ - !PadBatch\n+ pad_to_stride: 32\n+ use_padded_im_info: false\n+ batch_size: 1\n+ shuffle: false\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/architectures/htc.py", "new_path": "ppdet/modeling/architectures/htc.py", "diff": "@@ -467,5 +467,7 @@ class HybridTaskCascade(object):\nreturn self.build_multi_scale(feed_vars, mask_branch)\nreturn self.build(feed_vars, 'test')\n- def test(self, feed_vars):\n+ def test(self, feed_vars, exclude_nms=False):\n+ assert not exclude_nms, \"exclude_nms for {} is not support currently\".format(\n+ self.__class__.__name__)\nreturn self.build(feed_vars, 'test')\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix htc inference & deploy (#1729)
499,304
24.11.2020 10:20:23
-28,800
19f551fdc467ccf3114414435061dc4a83ad97c2
fix smoe model paddle version check
[ { "change_type": "MODIFY", "old_path": "ppdet/modeling/anchor_heads/solov2_head.py", "new_path": "ppdet/modeling/anchor_heads/solov2_head.py", "diff": "@@ -24,8 +24,6 @@ from paddle.fluid.regularizer import L2Decay\nfrom ppdet.modeling.ops import ConvNorm, DeformConvNorm, MaskMatrixNMS, DropBlock\nfrom ppdet.core.workspace import register\n-from ppdet.utils.check import check_version\n-\nfrom six.moves import zip\nimport numpy as np\n@@ -71,7 +69,6 @@ class SOLOv2Head(object):\nkernel='gaussian',\nsigma=2.0).__dict__,\ndrop_block=False):\n- check_version('2.0.0-rc0')\nself.num_classes = num_classes\nself.seg_num_grids = num_grids\nself.cate_out_channels = self.num_classes - 1\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/anchor_heads/ttf_head.py", "new_path": "ppdet/modeling/anchor_heads/ttf_head.py", "diff": "@@ -348,7 +348,11 @@ class TTFHead(object):\nreturn pred, target, weight\ndef get_loss(self, pred_hm, pred_wh, target_hm, box_target, target_weight):\n+ try:\npred_hm = paddle.clip(fluid.layers.sigmoid(pred_hm), 1e-4, 1 - 1e-4)\n+ except:\n+ pred_hm = paddle.tensor.clamp(\n+ fluid.layers.sigmoid(pred_hm), 1e-4, 1 - 1e-4)\nhm_loss = self.ct_focal_loss(pred_hm, target_hm) * self.hm_weight\nshape = fluid.layers.shape(target_hm)\nshape.stop_gradient = True\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/architectures/cascade_mask_rcnn.py", "new_path": "ppdet/modeling/architectures/cascade_mask_rcnn.py", "diff": "@@ -23,6 +23,7 @@ import paddle.fluid as fluid\nfrom ppdet.experimental import mixed_precision_global_state\nfrom ppdet.core.workspace import register\n+from ppdet.utils.check import check_version\nfrom .input_helper import multiscale_def\n@@ -62,6 +63,7 @@ class CascadeMaskRCNN(object):\nrpn_only=False,\nfpn='FPN'):\nsuper(CascadeMaskRCNN, self).__init__()\n+ check_version('2.0.0-rc0')\nassert fpn is not None, \"cascade RCNN requires FPN\"\nself.backbone = backbone\nself.fpn = fpn\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/architectures/cascade_rcnn.py", "new_path": "ppdet/modeling/architectures/cascade_rcnn.py", "diff": "@@ -23,6 +23,7 @@ import paddle.fluid as fluid\nfrom ppdet.experimental import mixed_precision_global_state\nfrom ppdet.core.workspace import register\n+from ppdet.utils.check import check_version\nfrom .input_helper import multiscale_def\n__all__ = ['CascadeRCNN']\n@@ -57,6 +58,7 @@ class CascadeRCNN(object):\nrpn_only=False,\nfpn='FPN'):\nsuper(CascadeRCNN, self).__init__()\n+ check_version('2.0.0-rc0')\nassert fpn is not None, \"cascade RCNN requires FPN\"\nself.backbone = backbone\nself.fpn = fpn\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/architectures/cascade_rcnn_cls_aware.py", "new_path": "ppdet/modeling/architectures/cascade_rcnn_cls_aware.py", "diff": "@@ -24,6 +24,7 @@ import copy\nimport paddle.fluid as fluid\nfrom ppdet.core.workspace import register\n+from ppdet.utils.check import check_version\nfrom .input_helper import multiscale_def\n__all__ = ['CascadeRCNNClsAware']\n@@ -60,6 +61,7 @@ class CascadeRCNNClsAware(object):\nbbox_assigner='CascadeBBoxAssigner',\nfpn='FPN', ):\nsuper(CascadeRCNNClsAware, self).__init__()\n+ check_version('2.0.0-rc0')\nassert fpn is not None, \"cascade RCNN requires FPN\"\nself.backbone = backbone\nself.fpn = fpn\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/architectures/htc.py", "new_path": "ppdet/modeling/architectures/htc.py", "diff": "@@ -26,6 +26,7 @@ from paddle.fluid.initializer import MSRA\nfrom paddle.fluid.regularizer import L2Decay\nfrom ppdet.experimental import mixed_precision_global_state\nfrom ppdet.core.workspace import register\n+from ppdet.utils.check import check_version\nfrom .input_helper import multiscale_def\n@@ -70,6 +71,7 @@ class HybridTaskCascade(object):\nrpn_only=False,\nfpn='FPN'):\nsuper(HybridTaskCascade, self).__init__()\n+ check_version('2.0.0-rc0')\nassert fpn is not None, \"HTC requires FPN\"\nself.backbone = backbone\nself.fpn = fpn\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/architectures/solov2.py", "new_path": "ppdet/modeling/architectures/solov2.py", "diff": "@@ -22,6 +22,7 @@ from paddle import fluid\nfrom ppdet.experimental import mixed_precision_global_state\nfrom ppdet.core.workspace import register\n+from ppdet.utils.check import check_version\n__all__ = ['SOLOv2']\n@@ -47,6 +48,7 @@ class SOLOv2(object):\nbbox_head='SOLOv2Head',\nmask_head='SOLOv2MaskHead'):\nsuper(SOLOv2, self).__init__()\n+ check_version('2.0.0-rc0')\nself.backbone = backbone\nself.fpn = fpn\nself.bbox_head = bbox_head\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix smoe model paddle version check (#1748)
499,304
25.11.2020 18:05:33
-28,800
0f15fc2019f1f153add2ea051eea4d481bd88bbf
fix misspelled word and image exif_transpose
[ { "change_type": "MODIFY", "old_path": "deploy/python/infer.py", "new_path": "deploy/python/infer.py", "diff": "@@ -341,7 +341,7 @@ class Config():\ndef print_config(self):\nprint('----------- Model Configuration -----------')\nprint('%s: %s' % ('Model Arch', self.arch))\n- print('%s: %s' % ('Use Padddle Executor', self.use_python_inference))\n+ print('%s: %s' % ('Use Paddle Executor', self.use_python_inference))\nprint('%s: ' % ('Transform Order'))\nfor op_info in self.preprocess_infos:\nprint('--%s: %s' % ('transform op', op_info['type']))\n" }, { "change_type": "MODIFY", "old_path": "tools/infer.py", "new_path": "tools/infer.py", "diff": "@@ -25,7 +25,7 @@ if parent_path not in sys.path:\nimport glob\nimport numpy as np\nimport six\n-from PIL import Image\n+from PIL import Image, ImageOps\nimport paddle\nfrom paddle import fluid\n@@ -205,6 +205,7 @@ def main():\nfor im_id in im_ids:\nimage_path = imid2path[int(im_id)]\nimage = Image.open(image_path).convert('RGB')\n+ image = ImageOps.exif_transpose(image)\n# use VisualDL to log original image\nif FLAGS.use_vdl:\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix misspelled word and image exif_transpose (#1754)
499,304
03.12.2020 10:14:39
-28,800
6ef76039013c9a21262f1bb565712386fc8e8d2f
update solov2 model confrontation
[ { "change_type": "MODIFY", "old_path": "configs/solov2/README.md", "new_path": "configs/solov2/README.md", "diff": "@@ -16,12 +16,19 @@ SOLOv2 (Segmenting Objects by Locations) is a fast instance segmentation framewo\n## Model Zoo\n-| Backbone | Multi-scale training | Lr schd | V100 FP32(FPS) | Mask AP<sup>val</sup> | Download | Configs |\n-| :---------------------: | :-------------------: | :-----: | :------------: | :-----: | :---------: | :------------------------: |\n-| Mobilenetv3-FPN | True | 3x | 50 | 30.0 | [model](https://paddlemodels.bj.bcebos.com/object_detection/solov2_mobilenetv3_fpn_448_3x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/solov2/solov2_mobilenetv3_fpn_448_3x.yml) |\n-| R50-FPN | False | 1x | 21.9 | 35.6 | [model](https://paddlemodels.bj.bcebos.com/object_detection/solov2_r50_fpn_1x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/solov2/solov2_r50_fpn_1x.yml) |\n-| R50-FPN | True | 3x | 21.9 | 37.9 | [model](https://paddlemodels.bj.bcebos.com/object_detection/solov2_r50_fpn_3x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/solov2/solov2_r50_fpn_3x.yml) |\n-| R101-VD-FPN | True | 3x | 12.1 | 42.6 | [model](https://paddlemodels.bj.bcebos.com/object_detection/solov2_r101_vd_fpn_3x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/solov2/solov2_r101_vd_fpn_3x.yml) |\n+| Detector | Backbone | Multi-scale training | Lr schd | Mask AP<sup>val</sup> | V100 FP32(FPS) | GPU | Download | Configs |\n+| :-------: | :---------------------: | :-------------------: | :-----: | :--------------------: | :-------------: | :-----: | :---------: | :------------------------: |\n+| YOLACT++ | R50-FPN | False | 80w iter | 34.1 (test-dev) | 33.5 | Xp | - | - |\n+| CenterMask | R50-FPN | True | 2x | 36.4 | 13.9 | Xp | - | - |\n+| CenterMask | V2-99-FPN | True | 3x | 40.2 | 8.9 | Xp | - | - |\n+| PolarMask | R50-FPN | True | 2x | 30.5 | 9.4 | V100 | - | - |\n+| BlendMask | R50-FPN | True | 3x | 37.8 | 13.5 | V100 | - | - |\n+| SOLOv2 (Paper) | R50-FPN | False | 1x | 34.8 | 18.5 | V100 | - | - |\n+| SOLOv2 (Paper) | X101-DCN-FPN | True | 3x | 42.4 | 5.9 | V100 | - | - |\n+| SOLOv2 | Mobilenetv3-FPN | True | 3x | 30.0 | 50 | V100 | [model](https://paddlemodels.bj.bcebos.com/object_detection/solov2_mobilenetv3_fpn_448_3x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/solov2/solov2_mobilenetv3_fpn_448_3x.yml) |\n+| SOLOv2 | R50-FPN | False | 1x | 35.6 | 21.9 | V100 | [model](https://paddlemodels.bj.bcebos.com/object_detection/solov2_r50_fpn_1x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/solov2/solov2_r50_fpn_1x.yml) |\n+| SOLOv2 | R50-FPN | True | 3x | 37.9 | 21.9 | V100 | [model](https://paddlemodels.bj.bcebos.com/object_detection/solov2_r50_fpn_3x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/solov2/solov2_r50_fpn_3x.yml) |\n+| SOLOv2 | R101-VD-FPN | True | 3x | 42.6 | 12.1 | V100 | [model](https://paddlemodels.bj.bcebos.com/object_detection/solov2_r101_vd_fpn_3x.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/solov2/solov2_r101_vd_fpn_3x.yml) |\n## Enhanced model\n| Backbone | Input size | Lr schd | V100 FP32(FPS) | Mask AP<sup>val</sup> | Download | Configs |\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
update solov2 model confrontation (#1798)
499,331
03.12.2020 16:15:02
-28,800
58f7e85b2ee06823f9e3e10ccb0dcf935c754f43
Remove CN comments in roadsign config. * Update QUICK_STARTED_cn.md fix typo * cherry-pick and test=document_fix
[ { "change_type": "ADD", "old_path": "docs/images/000000014439_640x640.jpg", "new_path": "docs/images/000000014439_640x640.jpg", "diff": "Binary files /dev/null and b/docs/images/000000014439_640x640.jpg differ\n" }, { "change_type": "ADD", "old_path": "docs/images/visualdl_roadsign.png", "new_path": "docs/images/visualdl_roadsign.png", "diff": "Binary files /dev/null and b/docs/images/visualdl_roadsign.png differ\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
Remove CN comments in roadsign config. (#1791) * Update QUICK_STARTED_cn.md (#1757) fix typo * cherry-pick #1757 and #1473, test=document_fix
499,331
03.12.2020 23:32:44
-28,800
22b365d2bb76d38c459697c1a398472fc188fa6f
remove stride param in anchor_generator, stride does not work when using FPN
[ { "change_type": "MODIFY", "old_path": "configs/faster_rcnn_r50_fpn_1x.yml", "new_path": "configs/faster_rcnn_r50_fpn_1x.yml", "diff": "@@ -34,7 +34,6 @@ FPNRPNHead:\nanchor_generator:\nanchor_sizes: [32, 64, 128, 256, 512]\naspect_ratios: [0.5, 1.0, 2.0]\n- stride: [16.0, 16.0]\nvariance: [1.0, 1.0, 1.0, 1.0]\nanchor_start_size: 32\nmin_level: 2\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
remove stride param in anchor_generator, stride does not work when using FPN (#1801)
499,304
04.12.2020 13:45:32
-28,800
f0226a1cbec2793f41f40acb40f1b7ed542aff1f
fix ssdlite_ghostnet weights link
[ { "change_type": "MODIFY", "old_path": "docs/MODEL_ZOO.md", "new_path": "docs/MODEL_ZOO.md", "diff": "@@ -202,7 +202,7 @@ results of image size 608/416/320 above. Deformable conv is added on stage 5 of\n| MobileNet_v3 large | 320 | 64 | Cosine decay(40w) | - | 23.3 | [model](https://paddlemodels.bj.bcebos.com/object_detection/mobile_models/ssdlite_mobilenet_v3_large.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/ssd/ssdlite_mobilenet_v3_large.yml) |\n| MobileNet_v3 small w/ FPN | 320 | 64 | Cosine decay(40w) | - | 18.9 | [model](https://paddlemodels.bj.bcebos.com/object_detection/mobile_models/ssdlite_mobilenet_v3_small_fpn.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/ssd/ssdlite_mobilenet_v3_small_fpn.yml) |\n| MobileNet_v3 large w/ FPN | 320 | 64 | Cosine decay(40w) | - | 24.3 | [model](https://paddlemodels.bj.bcebos.com/object_detection/mobile_models/ssdlite_mobilenet_v3_large_fpn.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/ssd/ssdlite_mobilenet_v3_large_fpn.yml) |\n-| GhostNet | 320 | 64 | Cosine decay(40w) | - | 23.3 | [model](htts://paddlemodels.bj.bcebos.com/object_detection/mobile_models/ssdlite_ghostnet.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/ssd/ssdlite_ghostnet.yml) |\n+| GhostNet | 320 | 64 | Cosine decay(40w) | - | 23.3 | [model](https://paddlemodels.bj.bcebos.com/object_detection/mobile_models/ssdlite_ghostnet.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/ssd/ssdlite_ghostnet.yml) |\n**Notes:** `SSDLite` is trained in 8 GPU with total batch size as 512 and uses cosine decay strategy to train.\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix ssdlite_ghostnet weights link (#1813)
499,331
06.12.2020 19:03:53
-28,800
857b17b8991bca3333c67fdf363d5f3c24baf88f
set batch_size=1 when eval, and fix bug of cpp build on winodows
[ { "change_type": "MODIFY", "old_path": "configs/yolov3_mobilenet_v1_roadsign.yml", "new_path": "configs/yolov3_mobilenet_v1_roadsign.yml", "diff": "@@ -144,7 +144,7 @@ EvalReader:\n- !Permute\nto_bgr: false\nchannel_first: True\n- batch_size: 8\n+ batch_size: 1\ndrop_empty: false\nworker_num: 4\nbufsize: 2\n" }, { "change_type": "MODIFY", "old_path": "deploy/cpp/CMakeLists.txt", "new_path": "deploy/cpp/CMakeLists.txt", "diff": "@@ -113,9 +113,8 @@ endif()\nif (NOT WIN32)\nif (WITH_TENSORRT AND WITH_GPU)\n- include_directories(\"${TENSORRT_INC_DIR}/include\")\n- #link_directories(\"${TENSORRT_LIB_DIR}/lib\")\n- link_directories(\"${TENSORRT_LIB_DIR}/\")\n+ include_directories(\"${TENSORRT_INC_DIR}\")\n+ link_directories(\"${TENSORRT_LIB_DIR}\")\nendif()\nendif(NOT WIN32)\n@@ -148,9 +147,13 @@ if(WITH_MKL)\nset(MKLDNN_LIB ${MKLDNN_PATH}/lib/libmkldnn.so.0)\nendif ()\nendif()\n+else()\n+ if (WIN32)\n+ set(MATH_LIB ${PADDLE_DIR}/third_party/install/openblas/lib/openblas${CMAKE_STATIC_LIBRARY_SUFFIX})\nelse()\nset(MATH_LIB ${PADDLE_DIR}/third_party/install/openblas/lib/libopenblas${CMAKE_STATIC_LIBRARY_SUFFIX})\nendif()\n+endif()\nif (WIN32)\nif(EXISTS \"${PADDLE_DIR}/paddle/fluid/inference/libpaddle_fluid${CMAKE_STATIC_LIBRARY_SUFFIX}\")\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
set batch_size=1 when eval, and fix bug of cpp build on winodows (#1822)
499,385
07.12.2020 19:44:53
-28,800
16735ddbc85fefe5c12a2267e2665a6e9ac5abb8
Add SOLOv2 link in README test=document_fix
[ { "change_type": "MODIFY", "old_path": "README_en.md", "new_path": "README_en.md", "diff": "@@ -244,6 +244,8 @@ All these models can be get in [Model Zoo](#ModelZoo)\n- [PP-YOLO](configs/ppyolo/README_cn.md)\n- [676 classes of object detection](docs/featured_model/LARGE_SCALE_DET_MODEL.md)\n- [Two-stage practical PSS-Det](configs/rcnn_enhance/README.md)\n+- Universal instance segmentation\n+ - [SOLOv2](configs/solov2/README.md)\n- Vertical field\n- [Face detection](docs/featured_model/FACE_DETECTION.md)\n- [Pedestrian detection](docs/featured_model/CONTRIB_cn.md)\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
Add SOLOv2 link in README (#1833) test=document_fix
499,333
11.12.2020 10:51:12
-28,800
b6cd99eb82caa49e9d9c124af069fdc59e0830cf
fix condition when segm is empty
[ { "change_type": "MODIFY", "old_path": "ppdet/data/reader.py", "new_path": "ppdet/data/reader.py", "diff": "@@ -346,7 +346,8 @@ class Reader(object):\n# 'drop this sample'.format(\n# sample['im_file'], sample['gt_bbox']))\ncontinue\n- if self._drop_empty and self._fields and 'gt_poly' in sample:\n+ has_mask = 'gt_mask' in self._fields or 'gt_segm' in self._fields\n+ if self._drop_empty and self._fields and has_mask:\nif _has_empty(_segm(sample)):\n#logger.warn('gt_mask is empty or not valid in {}'.format(\n# sample['im_file']))\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix condition when segm is empty (#1864)
499,304
15.12.2020 20:33:33
-28,800
ef65c7e165cd893f04fded82a9200c8e1deb3b5a
adapt keypoint detection for deploy
[ { "change_type": "MODIFY", "old_path": "configs/face_detection/blazeface_keypoint.yml", "new_path": "configs/face_detection/blazeface_keypoint.yml", "diff": "@@ -9,6 +9,7 @@ save_dir: output\nweights: output/blazeface_keypoint/model_final.pdparams\n# 1(label_class) + 1(background)\nnum_classes: 2\n+with_lmk: true\nBlazeFace:\nbackbone: BlazeNet\n@@ -19,7 +20,6 @@ BlazeFace:\nscore_threshold: 0.01\nmin_sizes: [[16.,24.], [32., 48., 64., 80., 96., 128.]]\nuse_density_prior_box: false\n- with_lmk: true\nlmk_loss:\noverlap_threshold: 0.35\nneg_overlap: 0.35\n@@ -103,12 +103,11 @@ EvalReader:\n- !DecodeImage\nto_rgb: true\n- !NormalizeBox {}\n+ - !Permute {}\n- !NormalizeImage\n- is_channel_first: false\nis_scale: false\n- mean: [123, 117, 104]\n+ mean: [104, 117, 123]\nstd: [127.502231, 127.502231, 127.502231]\n- - !Permute {}\nbatch_size: 1\nTestReader:\n@@ -120,10 +119,12 @@ TestReader:\nsample_transforms:\n- !DecodeImage\nto_rgb: true\n+ - !ResizeImage\n+ target_size: 640\n+ interp: 1\n+ - !Permute {}\n- !NormalizeImage\n- is_channel_first: false\nis_scale: false\n- mean: [123, 117, 104]\n+ mean: [104, 117, 123]\nstd: [127.502231, 127.502231, 127.502231]\n- - !Permute {}\nbatch_size: 1\n" }, { "change_type": "MODIFY", "old_path": "deploy/python/infer.py", "new_path": "deploy/python/infer.py", "diff": "@@ -34,8 +34,7 @@ import numpy as np\nimport paddle\nimport paddle.fluid as fluid\nfrom preprocess import preprocess, Resize, Normalize, Permute, PadStride\n-from visualize import visualize_box_mask\n-from ppdet.utils.check import enable_static_mode\n+from visualize import visualize_box_mask, lmk2out\n# Global dictionary\nSUPPORT_MODELS = {\n@@ -90,9 +89,12 @@ class Detector(object):\ninputs = create_inputs(im, im_info, self.config.arch)\nreturn inputs, im_info\n- def postprocess(self, np_boxes, np_masks, im_info, threshold=0.5):\n+ def postprocess(self, np_boxes, np_masks, np_lmk, im_info, threshold=0.5):\n# postprocess output of predictor\nresults = {}\n+ if np_lmk is not None:\n+ results['landmark'] = lmk2out(np_boxes, np_lmk, im_info, threshold)\n+\nif self.config.arch in ['SSD', 'Face']:\nw, h = im_info['origin_shape']\nnp_boxes[:, 2] *= h\n@@ -129,7 +131,7 @@ class Detector(object):\nshape:[N, class_num, mask_resolution, mask_resolution]\n'''\ninputs, im_info = self.preprocess(image)\n- np_boxes, np_masks = None, None\n+ np_boxes, np_masks, np_lmk = None, None, None\nif self.config.use_python_inference:\nfor i in range(warmup):\nouts = self.executor.run(self.program,\n@@ -164,6 +166,17 @@ class Detector(object):\noutput_names[1])\nnp_masks = masks_tensor.copy_to_cpu()\n+ if self.config.with_lmk is not None and self.config.with_lmk == True:\n+ face_index = self.predictor.get_output_tensor(output_names[\n+ 1])\n+ landmark = self.predictor.get_output_tensor(output_names[2])\n+ prior_boxes = self.predictor.get_output_tensor(output_names[\n+ 3])\n+ np_face_index = face_index.copy_to_cpu()\n+ np_prior_boxes = prior_boxes.copy_to_cpu()\n+ np_landmark = landmark.copy_to_cpu()\n+ np_lmk = [np_face_index, np_landmark, np_prior_boxes]\n+\nt1 = time.time()\nfor i in range(repeats):\nself.predictor.zero_copy_run()\n@@ -174,6 +187,17 @@ class Detector(object):\nmasks_tensor = self.predictor.get_output_tensor(\noutput_names[1])\nnp_masks = masks_tensor.copy_to_cpu()\n+\n+ if self.config.with_lmk is not None and self.config.with_lmk == True:\n+ face_index = self.predictor.get_output_tensor(output_names[\n+ 1])\n+ landmark = self.predictor.get_output_tensor(output_names[2])\n+ prior_boxes = self.predictor.get_output_tensor(output_names[\n+ 3])\n+ np_face_index = face_index.copy_to_cpu()\n+ np_prior_boxes = prior_boxes.copy_to_cpu()\n+ np_landmark = landmark.copy_to_cpu()\n+ np_lmk = [np_face_index, np_landmark, np_prior_boxes]\nt2 = time.time()\nms = (t2 - t1) * 1000.0 / repeats\nprint(\"Inference: {} ms per batch image\".format(ms))\n@@ -186,7 +210,7 @@ class Detector(object):\nresults = {'boxes': np.array([])}\nelse:\nresults = self.postprocess(\n- np_boxes, np_masks, im_info, threshold=threshold)\n+ np_boxes, np_masks, np_lmk, im_info, threshold=threshold)\nreturn results\n@@ -325,6 +349,9 @@ class Config():\nself.mask_resolution = None\nif 'mask_resolution' in yml_conf:\nself.mask_resolution = yml_conf['mask_resolution']\n+ self.with_lmk = None\n+ if 'with_lmk' in yml_conf:\n+ self.with_lmk = yml_conf['with_lmk']\nself.print_config()\ndef check_model(self, yml_conf):\n@@ -522,7 +549,10 @@ def main():\nif __name__ == '__main__':\n- enable_static_mode()\n+ try:\n+ paddle.enable_static()\n+ except:\n+ pass\nparser = argparse.ArgumentParser(description=__doc__)\nparser.add_argument(\n\"--model_dir\",\n" }, { "change_type": "MODIFY", "old_path": "deploy/python/visualize.py", "new_path": "deploy/python/visualize.py", "diff": "@@ -56,6 +56,8 @@ def visualize_box_mask(im, results, labels, mask_resolution=14, threshold=0.5):\nresults['score'],\nlabels,\nthreshold=threshold)\n+ if 'landmark' in results:\n+ im = draw_lmk(im, results['landmark'])\nreturn im\n@@ -247,3 +249,50 @@ def draw_segm(im,\n1,\nlineType=cv2.LINE_AA)\nreturn Image.fromarray(im.astype('uint8'))\n+\n+\n+def lmk2out(bboxes, np_lmk, im_info, threshold=0.5, is_bbox_normalized=True):\n+ image_w, image_h = im_info['origin_shape']\n+ scale = im_info['scale']\n+ face_index, landmark, prior_box = np_lmk[:]\n+ xywh_res = []\n+ if bboxes.shape == (1, 1) or bboxes is None:\n+ return np.array([])\n+ prior = np.reshape(prior_box, (-1, 4))\n+ predict_lmk = np.reshape(landmark, (-1, 10))\n+ k = 0\n+ for i in range(bboxes.shape[0]):\n+ score = bboxes[i][1]\n+ if score < threshold:\n+ continue\n+ theindex = face_index[i][0]\n+ me_prior = prior[theindex, :]\n+ lmk_pred = predict_lmk[theindex, :]\n+ prior_h = me_prior[2] - me_prior[0]\n+ prior_w = me_prior[3] - me_prior[1]\n+ prior_h_center = (me_prior[2] + me_prior[0]) / 2\n+ prior_w_center = (me_prior[3] + me_prior[1]) / 2\n+ lmk_decode = np.zeros((10))\n+ for j in [0, 2, 4, 6, 8]:\n+ lmk_decode[j] = lmk_pred[j] * 0.1 * prior_w + prior_h_center\n+ for j in [1, 3, 5, 7, 9]:\n+ lmk_decode[j] = lmk_pred[j] * 0.1 * prior_h + prior_w_center\n+\n+ if is_bbox_normalized:\n+ lmk_decode = lmk_decode * np.array([\n+ image_h, image_w, image_h, image_w, image_h, image_w, image_h,\n+ image_w, image_h, image_w\n+ ])\n+ xywh_res.append(lmk_decode)\n+ return np.asarray(xywh_res)\n+\n+\n+def draw_lmk(image, lmk_results):\n+ draw = ImageDraw.Draw(image)\n+ for lmk_decode in lmk_results:\n+ for j in range(5):\n+ x1 = int(round(lmk_decode[2 * j]))\n+ y1 = int(round(lmk_decode[2 * j + 1]))\n+ draw.ellipse(\n+ (x1 - 2, y1 - 2, x1 + 3, y1 + 3), fill='green', outline='green')\n+ return image\n" }, { "change_type": "MODIFY", "old_path": "ppdet/data/source/widerface.py", "new_path": "ppdet/data/source/widerface.py", "diff": "@@ -109,18 +109,24 @@ class WIDERFaceDataSet(DataSet):\nfile_dict = {}\nnum_class = 0\n+ exts = ['jpg', 'jpeg', 'png', 'bmp']\n+ exts += [ext.upper() for ext in exts]\nfor i in range(len(lines_input_txt)):\nline_txt = lines_input_txt[i].strip('\\n\\t\\r')\n- if '.jpg' in line_txt:\n+ split_str = line_txt.split(' ')\n+ if len(split_str) == 1:\n+ img_file_name = os.path.split(split_str[0])[1]\n+ split_txt = img_file_name.split('.')\n+ if len(split_txt) < 2:\n+ continue\n+ elif split_txt[-1] in exts:\nif i != 0:\nnum_class += 1\n- file_dict[num_class] = []\n- file_dict[num_class].append(line_txt)\n- if '.jpg' not in line_txt:\n+ file_dict[num_class] = [line_txt]\n+ else:\nif len(line_txt) <= 6:\ncontinue\nresult_boxs = []\n- split_str = line_txt.split(' ')\nxmin = float(split_str[0])\nymin = float(split_str[1])\nw = float(split_str[2])\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/architectures/blazeface.py", "new_path": "ppdet/modeling/architectures/blazeface.py", "diff": "@@ -51,7 +51,7 @@ class BlazeFace(object):\n__category__ = 'architecture'\n__inject__ = ['backbone', 'output_decoder']\n- __shared__ = ['num_classes']\n+ __shared__ = ['num_classes', 'with_lmk']\ndef __init__(self,\nbackbone=\"BlazeNet\",\n" }, { "change_type": "MODIFY", "old_path": "ppdet/utils/export_utils.py", "new_path": "ppdet/utils/export_utils.py", "diff": "@@ -141,6 +141,10 @@ def dump_infer_config(FLAGS, config):\ninfer_arch))\nos._exit(0)\n+ # support land mark output\n+ if 'with_lmk' in config and config['with_lmk'] == True:\n+ infer_cfg['with_lmk'] = True\n+\nif 'Mask' in config['architecture']:\ninfer_cfg['mask_resolution'] = config['MaskHead']['resolution']\ninfer_cfg['with_background'], infer_cfg['Preprocess'], infer_cfg[\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
adapt keypoint detection for deploy (#1899)
499,304
17.12.2020 13:08:31
-28,800
83e9e08fbf891d1bc7213a52fa4396061dfff381
fix im_info in solov2 deploy infer
[ { "change_type": "MODIFY", "old_path": "deploy/python/preprocess.py", "new_path": "deploy/python/preprocess.py", "diff": "@@ -86,6 +86,9 @@ class Resize(object):\n\"\"\"\nim_channel = im.shape[2]\nim_scale_x, im_scale_y = self.generate_scale(im)\n+ im_info['resize_shape'] = [\n+ im_scale_x * float(im.shape[0]), im_scale_y * float(im.shape[1])\n+ ]\nif self.use_cv2:\nim = cv2.resize(\nim,\n@@ -115,7 +118,6 @@ class Resize(object):\nim = padding_im\nim_info['scale'] = [im_scale_x, im_scale_y]\n- im_info['resize_shape'] = im.shape[:2]\nreturn im, im_info\ndef generate_scale(self, im):\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix im_info in solov2 deploy infer (#1910)
499,395
19.12.2020 00:10:45
-28,800
490886aee7926b064e186c3609c1a83b73cef9e9
fix problems in export_model, test=dygraph
[ { "change_type": "MODIFY", "old_path": "dygraph/tools/export_model.py", "new_path": "dygraph/tools/export_model.py", "diff": "@@ -57,8 +57,10 @@ def parse_args():\ndef dygraph_to_static(model, save_dir, cfg):\nif not os.path.exists(save_dir):\nos.makedirs(save_dir)\n+ image_shape = None\n+ if 'inputs_def' in cfg['TestReader']:\ninputs_def = cfg['TestReader']['inputs_def']\n- image_shape = inputs_def.get('image_shape')\n+ image_shape = inputs_def.get('image_shape', None)\nif image_shape is None:\nimage_shape = [3, None, None]\n# Save infer cfg\n@@ -102,7 +104,7 @@ def main():\ncfg = load_config(FLAGS.config)\n# TODO: to be refined in the future\n- if cfg.norm_type == 'sync_bn':\n+ if 'norm_type' in cfg and cfg['norm_type'] == 'sync_bn':\nFLAGS.opt['norm_type'] = 'bn'\nmerge_config(FLAGS.opt)\ncheck_config(cfg)\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix problems in export_model, test=dygraph (#1934)
499,304
31.12.2020 14:28:30
-28,800
379b731a6b95dcba4234366eb7f5ab170bda1070
fix record empty error in coco reader
[ { "change_type": "MODIFY", "old_path": "ppdet/data/source/coco.py", "new_path": "ppdet/data/source/coco.py", "diff": "@@ -146,6 +146,8 @@ class COCODataSet(DataSet):\n'x1: {}, y1: {}, x2: {}, y2: {}.'.format(\nimg_id, x1, y1, x2, y2))\nnum_bbox = len(bboxes)\n+ if num_bbox <= 0:\n+ continue\ngt_bbox = np.zeros((num_bbox, 4), dtype=np.float32)\ngt_class = np.zeros((num_bbox, 1), dtype=np.int32)\n@@ -154,6 +156,7 @@ class COCODataSet(DataSet):\ndifficult = np.zeros((num_bbox, 1), dtype=np.int32)\ngt_poly = [None] * num_bbox\n+ has_segmentation = False\nfor i, box in enumerate(bboxes):\ncatid = box['category_id']\ngt_class[i][0] = catid2clsid[catid]\n@@ -161,6 +164,10 @@ class COCODataSet(DataSet):\nis_crowd[i][0] = box['iscrowd']\nif 'segmentation' in box:\ngt_poly[i] = box['segmentation']\n+ has_segmentation = True\n+\n+ if has_segmentation and not any(gt_poly):\n+ continue\ncoco_rec.update({\n'is_crowd': is_crowd,\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix record empty error in coco reader (#1960)
499,395
06.01.2021 18:01:15
-28,800
2e8b4e149f00fa912980510c1964b1c2970e8222
modify coco.py to avoid problem due to string img_id
[ { "change_type": "MODIFY", "old_path": "dygraph/ppdet/data/source/coco.py", "new_path": "dygraph/ppdet/data/source/coco.py", "diff": "@@ -65,7 +65,7 @@ class COCODataSet(DetDataset):\n'and load image information only.'.format(anno_path))\nfor img_id in img_ids:\n- img_anno = coco.loadImgs(img_id)[0]\n+ img_anno = coco.loadImgs([img_id])[0]\nim_fname = img_anno['file_name']\nim_w = float(img_anno['width'])\nim_h = float(img_anno['height'])\n@@ -84,7 +84,7 @@ class COCODataSet(DetDataset):\ncontinue\nif not self.load_image_only:\n- ins_anno_ids = coco.getAnnIds(imgIds=img_id, iscrowd=False)\n+ ins_anno_ids = coco.getAnnIds(imgIds=[img_id], iscrowd=False)\ninstances = coco.loadAnns(ins_anno_ids)\nbboxes = []\n" }, { "change_type": "MODIFY", "old_path": "ppdet/data/source/coco.py", "new_path": "ppdet/data/source/coco.py", "diff": "@@ -101,7 +101,7 @@ class COCODataSet(DataSet):\n'and load image information only.'.format(anno_path))\nfor img_id in img_ids:\n- img_anno = coco.loadImgs(img_id)[0]\n+ img_anno = coco.loadImgs([img_id])[0]\nim_fname = img_anno['file_name']\nim_w = float(img_anno['width'])\nim_h = float(img_anno['height'])\n@@ -127,7 +127,7 @@ class COCODataSet(DataSet):\n}\nif not self.load_image_only:\n- ins_anno_ids = coco.getAnnIds(imgIds=img_id, iscrowd=False)\n+ ins_anno_ids = coco.getAnnIds(imgIds=[img_id], iscrowd=False)\ninstances = coco.loadAnns(ins_anno_ids)\nbboxes = []\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
modify coco.py to avoid problem due to string img_id (#2008)
499,333
07.01.2021 13:36:49
-28,800
f0d695317e4bce2957776dcfc2aaf54eabddf59b
fix mask_fpn coverge, test=dygraph
[ { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/architectures/mask_rcnn.py", "new_path": "dygraph/ppdet/modeling/architectures/mask_rcnn.py", "diff": "@@ -87,7 +87,7 @@ class MaskRCNN(BaseArch):\n# compute targets here when training\nrois = self.proposal(self.inputs, self.rpn_head_out, self.anchor_out)\n# BBox Head\n- bbox_feat, self.bbox_head_out, self.bbox_head_feat_func = self.bbox_head(\n+ bbox_feat, self.bbox_head_out, bbox_head_feat_func = self.bbox_head(\nbody_feats, rois, spatial_scale)\nrois_has_mask_int32 = None\n@@ -108,7 +108,7 @@ class MaskRCNN(BaseArch):\n# Mask Head\nself.mask_head_out = self.mask_head(\nself.inputs, body_feats, self.bboxes, bbox_feat,\n- rois_has_mask_int32, spatial_scale, self.bbox_head_feat_func)\n+ rois_has_mask_int32, spatial_scale, bbox_head_feat_func)\ndef get_loss(self, ):\nloss = {}\n" }, { "change_type": "MODIFY", "old_path": "dygraph/tools/train.py", "new_path": "dygraph/tools/train.py", "diff": "@@ -128,6 +128,16 @@ def run(FLAGS, cfg, place):\n# if sync_bn:\n# model = paddle.nn.SyncBatchNorm.convert_sync_batchnorm(model)\n+ # The parameter filter is temporary fix for training because of #28997\n+ # in Paddle.\n+ def no_grad(param):\n+ if param.name.startswith(\"conv1_\") or param.name.startswith(\"res2a_\") \\\n+ or param.name.startswith(\"res2b_\") or param.name.startswith(\"res2c_\"):\n+ return True\n+\n+ for param in filter(no_grad, model.parameters()):\n+ param.stop_gradient = True\n+\n# Parallel Model\nif ParallelEnv().nranks > 1:\nmodel = paddle.DataParallel(model)\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix mask_fpn coverge, test=dygraph (#2015)
499,304
07.01.2021 16:24:06
-28,800
4511b8793f1343d5f1d22143f63d53449409c005
fix hrnet comment
[ { "change_type": "MODIFY", "old_path": "ppdet/modeling/backbones/hrnet.py", "new_path": "ppdet/modeling/backbones/hrnet.py", "diff": "@@ -39,12 +39,12 @@ class HRNet(object):\n\"\"\"\nHRNet, see https://arxiv.org/abs/1908.07919\nArgs:\n- depth (int): ResNet depth, should be 18, 34, 50, 101, 152.\n+ width (int): network width, should be 18, 30, 32, 40, 44, 48, 60 or 64\n+ has_se (bool): whether contain squeeze_excitation(SE) block or not\nfreeze_at (int): freeze the backbone at which stage\n- norm_type (str): normalization type, 'bn'/'sync_bn'/'affine_channel'\n+ norm_type (str): normalization type, 'bn'/'sync_bn'\nfreeze_norm (bool): freeze normalization layers\nnorm_decay (float): weight decay for normalization layer weights\n- variant (str): ResNet variant, supports 'a', 'b', 'c', 'd' currently\nfeature_maps (list): index of stages whose feature maps are returned\n\"\"\"\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix hrnet comment (#2020)
499,304
11.01.2021 09:51:56
-28,800
7042801c7d7dc1f8425bdf729e477bcc15ad3631
fix save_model bug and remove inputs[mode] in rcnn
[ { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/architectures/cascade_rcnn.py", "new_path": "dygraph/ppdet/modeling/architectures/cascade_rcnn.py", "diff": "@@ -99,6 +99,7 @@ class CascadeRCNN(BaseArch):\nself.inputs,\nself.rpn_head_out,\nself.anchor_out,\n+ self.training,\ni,\nrois,\nbbox_head_out,\n@@ -110,7 +111,7 @@ class CascadeRCNN(BaseArch):\nspatial_scale, i)\nself.bbox_head_list.append(bbox_head_out)\n- if self.inputs['mode'] == 'infer':\n+ if not self.training:\nbbox_pred, bboxes = self.bbox_head.get_cascade_prediction(\nself.bbox_head_list, rois_list)\nself.bboxes = self.bbox_post_process(bbox_pred, bboxes,\n@@ -120,7 +121,7 @@ class CascadeRCNN(BaseArch):\nif self.with_mask:\nrois = rois_list[-1]\nrois_has_mask_int32 = None\n- if self.inputs['mode'] == 'train':\n+ if self.training:\nbbox_targets = self.proposal.get_targets()[-1]\nself.bboxes, rois_has_mask_int32 = self.mask(self.inputs, rois,\nbbox_targets)\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/architectures/faster_rcnn.py", "new_path": "dygraph/ppdet/modeling/architectures/faster_rcnn.py", "diff": "@@ -57,12 +57,13 @@ class FasterRCNN(BaseArch):\n# Proposal RoI\n# compute targets here when training\n- rois = self.proposal(self.inputs, self.rpn_head_out, self.anchor_out)\n+ rois = self.proposal(self.inputs, self.rpn_head_out, self.anchor_out,\n+ self.training)\n# BBox Head\nbbox_feat, self.bbox_head_out, self.bbox_head_feat_func = self.bbox_head(\nbody_feats, rois, spatial_scale)\n- if self.inputs['mode'] == 'infer':\n+ if not self.training:\nbbox_pred, bboxes = self.bbox_head.get_prediction(\nself.bbox_head_out, rois)\n# Refine bbox by the output from bbox_head at test stage\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/architectures/mask_rcnn.py", "new_path": "dygraph/ppdet/modeling/architectures/mask_rcnn.py", "diff": "@@ -85,13 +85,14 @@ class MaskRCNN(BaseArch):\n# Proposal RoI\n# compute targets here when training\n- rois = self.proposal(self.inputs, self.rpn_head_out, self.anchor_out)\n+ rois = self.proposal(self.inputs, self.rpn_head_out, self.anchor_out,\n+ self.training)\n# BBox Head\nbbox_feat, self.bbox_head_out, bbox_head_feat_func = self.bbox_head(\nbody_feats, rois, spatial_scale)\nrois_has_mask_int32 = None\n- if self.inputs['mode'] == 'infer':\n+ if not self.training:\nbbox_pred, bboxes = self.bbox_head.get_prediction(\nself.bbox_head_out, rois)\n# Refine bbox by the output from bbox_head at test stage\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/architectures/meta_arch.py", "new_path": "dygraph/ppdet/modeling/architectures/meta_arch.py", "diff": "@@ -15,18 +15,14 @@ class BaseArch(nn.Layer):\ndef __init__(self):\nsuper(BaseArch, self).__init__()\n- def forward(self, inputs, mode='infer'):\n+ def forward(self, inputs):\nself.inputs = inputs\n- self.inputs['mode'] = mode\nself.model_arch()\n- if mode == 'train':\n+ if self.training:\nout = self.get_loss()\n- elif mode == 'infer':\n- out = self.get_pred()\nelse:\n- out = None\n- raise \"Now, only support train and infer mode!\"\n+ out = self.get_pred()\nreturn out\ndef build_inputs(self, data, input_def):\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/bbox.py", "new_path": "dygraph/ppdet/modeling/bbox.py", "diff": "@@ -79,7 +79,7 @@ class Proposal(object):\nself.proposal_generator = proposal_generator\nself.proposal_target_generator = proposal_target_generator\n- def generate_proposal(self, inputs, rpn_head_out, anchor_out):\n+ def generate_proposal(self, inputs, rpn_head_out, anchor_out, is_train):\n# TODO: delete im_info\ntry:\nim_shape = inputs['im_info']\n@@ -97,7 +97,7 @@ class Proposal(object):\nanchors=anchor,\nvariances=var,\nim_shape=im_shape,\n- mode=inputs['mode'])\n+ is_train=is_train)\nif len(rpn_head_out) == 1:\nreturn rpn_rois, rpn_rois_num\nrpn_rois_list.append(rpn_rois)\n@@ -164,13 +164,14 @@ class Proposal(object):\ninputs,\nrpn_head_out,\nanchor_out,\n+ is_train=False,\nstage=0,\nproposal_out=None,\nbbox_head_out=None,\nmax_overlap=None):\nif stage == 0:\nroi, rois_num = self.generate_proposal(inputs, rpn_head_out,\n- anchor_out)\n+ anchor_out, is_train)\nself.targets_list = []\nself.max_overlap = None\n@@ -178,7 +179,7 @@ class Proposal(object):\nbbox_delta = bbox_head_out[1]\nroi = self.refine_bbox(proposal_out[0], bbox_delta, stage)\nrois_num = proposal_out[1]\n- if inputs['mode'] == 'train':\n+ if is_train:\nroi, rois_num, targets, self.max_overlap = self.generate_proposal_target(\ninputs, roi, rois_num, stage, self.max_overlap)\nself.targets_list.append(targets)\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/heads/mask_head.py", "new_path": "dygraph/ppdet/modeling/heads/mask_head.py", "diff": "@@ -83,14 +83,13 @@ class MaskFeat(Layer):\nmask_index,\nspatial_scale,\nstage=0,\n- bbox_head_feat_func=None,\n- mode='train'):\n+ bbox_head_feat_func=None):\nif self.share_bbox_feat and mask_index is not None:\nrois_feat = paddle.gather(bbox_feat, mask_index)\nelse:\nrois_feat = self.mask_roi_extractor(body_feats, bboxes,\nspatial_scale)\n- if self.share_bbox_feat and bbox_head_feat_func is not None and mode == 'infer':\n+ if self.share_bbox_feat and bbox_head_feat_func is not None and not self.training:\nrois_feat = bbox_head_feat_func(rois_feat)\n# upsample\n@@ -136,14 +135,8 @@ class MaskHead(Layer):\nspatial_scale,\nstage=0):\n# feat\n- mask_feat = self.mask_feat(\n- body_feats,\n- bboxes,\n- bbox_feat,\n- mask_index,\n- spatial_scale,\n- stage,\n- mode='train')\n+ mask_feat = self.mask_feat(body_feats, bboxes, bbox_feat, mask_index,\n+ spatial_scale, stage)\n# logits\nmask_head_out = self.mask_fcn_logits[stage](mask_feat)\nreturn mask_head_out\n@@ -174,15 +167,9 @@ class MaskHead(Layer):\nscale_factor_list = paddle.reshape(scale_factor_list, shape=[-1, 1])\nscaled_bbox = paddle.multiply(bbox[:, 2:], scale_factor_list)\nscaled_bboxes = (scaled_bbox, bbox_num)\n- mask_feat = self.mask_feat(\n- body_feats,\n- scaled_bboxes,\n- bbox_feat,\n- mask_index,\n- spatial_scale,\n- stage,\n- bbox_head_feat_func,\n- mode='infer')\n+ mask_feat = self.mask_feat(body_feats, scaled_bboxes, bbox_feat,\n+ mask_index, spatial_scale, stage,\n+ bbox_head_feat_func)\nmask_logit = self.mask_fcn_logits[stage](mask_feat)\nmask_head_out = F.sigmoid(mask_logit)\nreturn mask_head_out\n@@ -196,7 +183,7 @@ class MaskHead(Layer):\nspatial_scale,\nbbox_head_feat_func=None,\nstage=0):\n- if inputs['mode'] == 'train':\n+ if self.training:\nmask_head_out = self.forward_train(body_feats, bboxes, bbox_feat,\nmask_index, spatial_scale, stage)\nelse:\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/layers.py", "new_path": "dygraph/ppdet/modeling/layers.py", "diff": "@@ -189,9 +189,9 @@ class ProposalGenerator(object):\nanchors,\nvariances,\nim_shape,\n- mode='train'):\n- pre_nms_top_n = self.train_pre_nms_top_n if mode == 'train' else self.infer_pre_nms_top_n\n- post_nms_top_n = self.train_post_nms_top_n if mode == 'train' else self.infer_post_nms_top_n\n+ is_train=False):\n+ pre_nms_top_n = self.train_pre_nms_top_n if is_train else self.infer_pre_nms_top_n\n+ post_nms_top_n = self.train_post_nms_top_n if is_train else self.infer_post_nms_top_n\n# TODO delete im_info\nif im_shape.shape[1] > 2:\nimport paddle.fluid as fluid\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/utils/checkpoint.py", "new_path": "dygraph/ppdet/utils/checkpoint.py", "diff": "@@ -159,6 +159,8 @@ def save_model(model, optimizer, save_dir, save_name, last_epoch):\nsave_name (str): the path to be saved.\nlast_epoch (int): the epoch index.\n\"\"\"\n+ if paddle.distributed.get_rank() != 0:\n+ return\nif not os.path.exists(save_dir):\nos.makedirs(save_dir)\nsave_path = os.path.join(save_dir, save_name)\n" }, { "change_type": "MODIFY", "old_path": "dygraph/tools/eval.py", "new_path": "dygraph/tools/eval.py", "diff": "@@ -81,7 +81,7 @@ def run(FLAGS, cfg, place):\nfor iter_id, data in enumerate(eval_loader):\n# forward\nmodel.eval()\n- outs = model(data, mode='infer')\n+ outs = model(data)\nfor key in extra_key:\nouts[key] = data[key]\nfor key, value in outs.items():\n" }, { "change_type": "MODIFY", "old_path": "dygraph/tools/infer.py", "new_path": "dygraph/tools/infer.py", "diff": "@@ -153,7 +153,7 @@ def run(FLAGS, cfg, place):\nfor iter_id, data in enumerate(test_loader):\n# forward\nmodel.eval()\n- outs = model(data, mode='infer')\n+ outs = model(data)\nfor key in extra_key:\nouts[key] = data[key]\nfor key, value in outs.items():\n" }, { "change_type": "MODIFY", "old_path": "dygraph/tools/train.py", "new_path": "dygraph/tools/train.py", "diff": "@@ -164,7 +164,7 @@ def run(FLAGS, cfg, place):\ndata_time.update(time.time() - end_time)\n# Model Forward\nmodel.train()\n- outputs = model(data, mode='train')\n+ outputs = model(data)\nloss = outputs['loss']\n# Model Backward\nloss.backward()\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix save_model bug and remove inputs[mode] in rcnn (#2031)
499,304
11.01.2021 15:12:34
-28,800
11a059c90c63c4ff269b49ad6727b501a21577d9
fix dygraph to static model error, test=dygraph
[ { "change_type": "MODIFY", "old_path": "dygraph/ppdet/engine/export_utils.py", "new_path": "dygraph/ppdet/engine/export_utils.py", "diff": "@@ -99,7 +99,8 @@ def _dump_infer_config(config, path, image_shape, model):\n'Architecture: {} is not supported for exporting model now'.format(\ninfer_arch))\nos._exit(0)\n- if getattr(model.__dict__, 'mask_post_process', None):\n+ if 'mask_post_process' in model.__dict__ and model.__dict__[\n+ 'mask_post_process']:\ninfer_cfg['mask_resolution'] = model.mask_post_process.mask_resolution\ninfer_cfg['with_background'], infer_cfg['Preprocess'], infer_cfg[\n'label_list'], image_shape = _parse_reader(\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/engine/trainer.py", "new_path": "dygraph/ppdet/engine/trainer.py", "diff": "@@ -297,6 +297,7 @@ class Trainer(object):\nreturn os.path.join(output_dir, \"{}\".format(name)) + ext\ndef export(self, output_dir='output_inference'):\n+ self.model.eval()\nmodel_name = os.path.splitext(os.path.split(self.cfg.filename)[-1])[0]\nsave_dir = os.path.join(output_dir, model_name)\nif not os.path.exists(save_dir):\n" }, { "change_type": "MODIFY", "old_path": "dygraph/tools/export_model.py", "new_path": "dygraph/tools/export_model.py", "diff": "@@ -30,7 +30,7 @@ import paddle\nfrom ppdet.core.workspace import load_config, merge_config\nfrom ppdet.utils.check import check_gpu, check_version, check_config\nfrom ppdet.utils.cli import ArgsParser\n-from ppdet.engine import Detector\n+from ppdet.engine import Trainer\nfrom ppdet.utils.logger import setup_logger\nlogger = setup_logger('export_model')\n@@ -49,13 +49,13 @@ def parse_args():\ndef run(FLAGS, cfg):\n# build detector\n- detector = Detector(cfg, mode='test')\n+ trainer = Trainer(cfg, mode='test')\n# load weights\n- detector.load_weights(cfg.weights, 'resume')\n+ trainer.load_weights(cfg.weights, 'resume')\n# export model\n- detector.export(FLAGS.output_dir)\n+ trainer.export(FLAGS.output_dir)\ndef main():\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix dygraph to static model error, test=dygraph (#2037)
499,304
12.01.2021 22:29:59
-28,800
8dfbd86a4e0cb8a9892b9a25994a04491416d154
fix condition of coco segmention
[ { "change_type": "MODIFY", "old_path": "dygraph/ppdet/data/source/coco.py", "new_path": "dygraph/ppdet/data/source/coco.py", "diff": "@@ -128,7 +128,7 @@ class COCODataSet(DetDataset):\n# check RLE format\nif 'segmentation' in box and box['iscrowd'] == 1:\ngt_poly[i] = [[0.0, 0.0], ]\n- elif 'segmentation' in box:\n+ elif 'segmentation' in box and box['segmentation']:\ngt_poly[i] = box['segmentation']\nhas_segmentation = True\n" }, { "change_type": "MODIFY", "old_path": "ppdet/data/source/coco.py", "new_path": "ppdet/data/source/coco.py", "diff": "@@ -162,7 +162,7 @@ class COCODataSet(DataSet):\ngt_class[i][0] = catid2clsid[catid]\ngt_bbox[i, :] = box['clean_bbox']\nis_crowd[i][0] = box['iscrowd']\n- if 'segmentation' in box:\n+ if 'segmentation' in box and box['segmentation']:\ngt_poly[i] = box['segmentation']\nhas_segmentation = True\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix condition of coco segmention (#2046)
499,304
13.01.2021 17:39:35
-28,800
5afa83e570e61eb14686d98b03f3acb567bd5623
fix framework warning in solov2
[ { "change_type": "MODIFY", "old_path": "ppdet/core/workspace.py", "new_path": "ppdet/core/workspace.py", "diff": "@@ -24,6 +24,11 @@ import yaml\nimport copy\nimport collections\n+try:\n+ collectionsAbc = collections.abc\n+except AttributeError:\n+ collectionsAbc = collections\n+\nfrom .config.schema import SchemaDict, SharedConfig, extract_schema\nfrom .config.yaml_helpers import serializable\n@@ -115,7 +120,7 @@ def dict_merge(dct, merge_dct):\n\"\"\"\nfor k, v in merge_dct.items():\nif (k in dct and isinstance(dct[k], dict) and\n- isinstance(merge_dct[k], collections.Mapping)):\n+ isinstance(merge_dct[k], collectionsAbc.Mapping)):\ndict_merge(dct[k], merge_dct[k])\nelse:\ndct[k] = merge_dct[k]\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/anchor_heads/solov2_head.py", "new_path": "ppdet/modeling/anchor_heads/solov2_head.py", "diff": "@@ -132,8 +132,9 @@ class SOLOv2Head(object):\ndef _points_nms(self, heat, kernel=2):\nhmax = fluid.layers.pool2d(\ninput=heat, pool_size=kernel, pool_type='max', pool_padding=1)\n- keep = fluid.layers.cast((hmax[:, :, :-1, :-1] == heat), 'float32')\n- return heat * keep\n+ keep = fluid.layers.cast(\n+ paddle.equal(hmax[:, :, :-1, :-1], heat), 'float32')\n+ return paddle.multiply(heat, keep)\ndef _split_feats(self, feats):\nreturn (paddle.nn.functional.interpolate(\n@@ -376,7 +377,7 @@ class SOLOv2Head(object):\nstrides.append(\nfluid.layers.fill_constant(\nshape=[int(size_trans[_ind])],\n- dtype=\"int32\",\n+ dtype=\"float32\",\nvalue=self.segm_strides[_ind]))\nstrides = fluid.layers.concat(strides)\nstrides = fluid.layers.gather(strides, index=inds[:, 0])\n@@ -389,7 +390,7 @@ class SOLOv2Head(object):\nseg_masks = fluid.layers.cast(seg_masks, 'float32')\nsum_masks = fluid.layers.reduce_sum(seg_masks, dim=[1, 2])\n- keep = fluid.layers.where(sum_masks > strides)\n+ keep = fluid.layers.where(paddle.greater_than(sum_masks, strides))\nkeep = fluid.layers.squeeze(keep, axes=[1])\n# Prevent empty and increase fake data\nkeep_other = fluid.layers.concat([\n@@ -409,9 +410,10 @@ class SOLOv2Head(object):\ncate_scores = fluid.layers.gather(cate_scores, index=keep_scores)\n# mask scoring.\n- seg_mul = fluid.layers.cast(seg_preds * seg_masks, 'float32')\n- seg_scores = fluid.layers.reduce_sum(seg_mul, dim=[1, 2]) / sum_masks\n- cate_scores *= seg_scores\n+ seg_mul = fluid.layers.cast(\n+ paddle.multiply(seg_preds, seg_masks), 'float32')\n+ seg_scores = paddle.divide(paddle.sum(seg_mul, axis=[1, 2]), sum_masks)\n+ cate_scores = paddle.multiply(cate_scores, seg_scores)\n# Matrix NMS\nseg_preds, cate_scores, cate_labels = self.mask_nms(\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/backbones/fpn.py", "new_path": "ppdet/modeling/backbones/fpn.py", "diff": "@@ -18,6 +18,7 @@ from __future__ import print_function\nfrom collections import OrderedDict\nimport copy\n+import paddle\nfrom paddle import fluid\nfrom paddle.fluid.param_attr import ParamAttr\nfrom paddle.fluid.initializer import Xavier\n@@ -105,7 +106,7 @@ class FPN(object):\nout_shape=[body_input.shape[2], body_input.shape[3]],\nname=topdown_name)\n- return lateral + topdown\n+ return paddle.add(lateral, topdown)\ndef get_output(self, body_dict):\n\"\"\"\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/losses/solov2_loss.py", "new_path": "ppdet/modeling/losses/solov2_loss.py", "diff": "@@ -48,10 +48,12 @@ class SOLOv2Loss(object):\ntarget = fluid.layers.reshape(\ntarget, shape=(fluid.layers.shape(target)[0], -1))\ntarget = fluid.layers.cast(target, 'float32')\n- a = fluid.layers.reduce_sum(input * target, dim=1)\n- b = fluid.layers.reduce_sum(input * input, dim=1) + 0.001\n- c = fluid.layers.reduce_sum(target * target, dim=1) + 0.001\n- d = (2 * a) / (b + c)\n+ a = fluid.layers.reduce_sum(paddle.multiply(input, target), dim=1)\n+ b = fluid.layers.reduce_sum(\n+ paddle.multiply(input, input), dim=1) + 0.001\n+ c = fluid.layers.reduce_sum(\n+ paddle.multiply(target, target), dim=1) + 0.001\n+ d = paddle.divide((2 * a), paddle.add(b, c))\nreturn 1 - d\ndef __call__(self, ins_pred_list, ins_label_list, cate_preds, cate_labels,\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/ops.py", "new_path": "ppdet/modeling/ops.py", "diff": "@@ -1642,8 +1642,12 @@ class MaskMatrixNMS(object):\nsum_masks, expand_times=[n_samples]),\nshape=[n_samples, n_samples])\n# iou.\n- iou_matrix = (inter_matrix / (sum_masks_x + fluid.layers.transpose(\n- sum_masks_x, [1, 0]) - inter_matrix))\n+ iou_matrix = paddle.divide(inter_matrix,\n+ paddle.subtract(\n+ paddle.add(sum_masks_x,\n+ fluid.layers.transpose(\n+ sum_masks_x, [1, 0])),\n+ inter_matrix))\niou_matrix = paddle.triu(iou_matrix, diagonal=1)\n# label_specific matrix.\ncate_labels_x = fluid.layers.reshape(\n@@ -1651,12 +1655,14 @@ class MaskMatrixNMS(object):\ncate_labels, expand_times=[n_samples]),\nshape=[n_samples, n_samples])\nlabel_matrix = fluid.layers.cast(\n- (cate_labels_x == fluid.layers.transpose(cate_labels_x, [1, 0])),\n+ paddle.equal(cate_labels_x,\n+ fluid.layers.transpose(cate_labels_x, [1, 0])),\n'float32')\nlabel_matrix = paddle.triu(label_matrix, diagonal=1)\n# IoU compensation\n- compensate_iou = paddle.max((iou_matrix * label_matrix), axis=0)\n+ compensate_iou = paddle.max(paddle.multiply(iou_matrix, label_matrix),\n+ axis=0)\ncompensate_iou = fluid.layers.reshape(\nfluid.layers.expand(\ncompensate_iou, expand_times=[n_samples]),\n@@ -1664,15 +1670,15 @@ class MaskMatrixNMS(object):\ncompensate_iou = fluid.layers.transpose(compensate_iou, [1, 0])\n# IoU decay\n- decay_iou = iou_matrix * label_matrix\n+ decay_iou = paddle.multiply(iou_matrix, label_matrix)\n# matrix nms\nif self.kernel == 'gaussian':\ndecay_matrix = fluid.layers.exp(-1 * self.sigma * (decay_iou**2))\ncompensate_matrix = fluid.layers.exp(-1 * self.sigma *\n(compensate_iou**2))\n- decay_coefficient = paddle.min(decay_matrix / compensate_matrix,\n- axis=0)\n+ decay_coefficient = paddle.min(\n+ paddle.divide(decay_matrix, compensate_matrix), axis=0)\nelif self.kernel == 'linear':\ndecay_matrix = (1 - decay_iou) / (1 - compensate_iou)\ndecay_coefficient = paddle.min(decay_matrix, axis=0)\n@@ -1680,7 +1686,7 @@ class MaskMatrixNMS(object):\nraise NotImplementedError\n# update the score.\n- cate_scores = cate_scores * decay_coefficient\n+ cate_scores = paddle.multiply(cate_scores, decay_coefficient)\nkeep = fluid.layers.where(cate_scores >= self.update_threshold)\nkeep = fluid.layers.squeeze(keep, axes=[1])\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix framework warning in solov2 (#2052)
499,304
13.01.2021 21:48:49
-28,800
b5f0e5b52a43c1793fbf6359e5d46e9355c0cc2f
fix framework warning
[ { "change_type": "MODIFY", "old_path": "ppdet/modeling/backbones/fpn.py", "new_path": "ppdet/modeling/backbones/fpn.py", "diff": "@@ -18,7 +18,6 @@ from __future__ import print_function\nfrom collections import OrderedDict\nimport copy\n-import paddle\nfrom paddle import fluid\nfrom paddle.fluid.param_attr import ParamAttr\nfrom paddle.fluid.initializer import Xavier\n@@ -106,7 +105,7 @@ class FPN(object):\nout_shape=[body_input.shape[2], body_input.shape[3]],\nname=topdown_name)\n- return paddle.add(lateral, topdown)\n+ return fluid.layers.elementwise_add(lateral, topdown)\ndef get_output(self, body_dict):\n\"\"\"\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/backbones/mobilenet_v3.py", "new_path": "ppdet/modeling/backbones/mobilenet_v3.py", "diff": "@@ -225,7 +225,7 @@ class MobileNetV3(object):\nreturn out\ndef _hard_swish(self, x):\n- return x * fluid.layers.relu6(x + 3) / 6.\n+ return fluid.layers.elementwise_mul(x, fluid.layers.relu6(x + 3) / 6.)\ndef _se_block(self, input, num_out_filter, ratio=4, name=None):\nlr_idx = self.curr_stage // 3\n" }, { "change_type": "MODIFY", "old_path": "ppdet/modeling/ops.py", "new_path": "ppdet/modeling/ops.py", "diff": "@@ -325,7 +325,8 @@ def DropBlock(input, block_size, keep_prob, is_test):\nelem_sum_m = fluid.layers.cast(elem_sum, dtype=\"float32\")\nelem_sum_m.stop_gradient = True\n- output = input * mask * elem_numel_m / elem_sum_m\n+ output = fluid.layers.elementwise_mul(input,\n+ mask) * elem_numel_m / elem_sum_m\nreturn output\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix framework warning (#2058)
499,304
14.01.2021 14:11:10
-28,800
49b6a0ec43d6eb97a136063a868bbf0f857e2d99
fix hard_sigmoid api
[ { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/backbones/mobilenet_v3.py", "new_path": "dygraph/ppdet/modeling/backbones/mobilenet_v3.py", "diff": "@@ -20,7 +20,6 @@ import paddle\nimport paddle.nn as nn\nimport paddle.nn.functional as F\nfrom paddle import ParamAttr\n-from paddle.nn.functional.activation import hard_sigmoid\nfrom paddle.regularizer import L2Decay\nfrom ppdet.core.workspace import register, serializable\nfrom numbers import Integral\n@@ -217,7 +216,7 @@ class SEModule(nn.Layer):\noutputs = self.conv1(outputs)\noutputs = F.relu(outputs)\noutputs = self.conv2(outputs)\n- outputs = hard_sigmoid(outputs)\n+ outputs = F.hardsigmoid(outputs, slope=0.2, offset=0.5)\nreturn paddle.multiply(x=inputs, y=outputs)\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix hard_sigmoid api (#2065)
499,331
15.01.2021 16:42:57
-28,800
6a46b3c4211d3d67429d88d63199f1eba41e8f3a
fix build error when using paddle_inference_lib 2.0rc1 on windows in dygraph mode
[ { "change_type": "MODIFY", "old_path": "dygraph/deploy/cpp/CMakeLists.txt", "new_path": "dygraph/deploy/cpp/CMakeLists.txt", "diff": "@@ -3,8 +3,10 @@ project(PaddleObjectDetector CXX C)\noption(WITH_MKL \"Compile demo with MKL/OpenBlas support,defaultuseMKL.\" ON)\noption(WITH_GPU \"Compile demo with GPU/CPU, default use CPU.\" ON)\n-option(WITH_STATIC_LIB \"Compile demo with static/shared library, default use static.\" ON)\n+option(WITH_STATIC_LIB \"Compile demo with static/shared library, default use shared.\" OFF)\noption(WITH_TENSORRT \"Compile demo with TensorRT.\" OFF)\n+option(USE_PADDLE_20RC1 \"Compile demo with paddle_inference_lib 2.0rc1\" ON)\n+\nSET(PADDLE_DIR \"\" CACHE PATH \"Location of libraries\")\nSET(OPENCV_DIR \"\" CACHE PATH \"Location of libraries\")\n@@ -36,6 +38,7 @@ endif()\nif (NOT DEFINED PADDLE_DIR OR ${PADDLE_DIR} STREQUAL \"\")\nmessage(FATAL_ERROR \"please set PADDLE_DIR with -DPADDLE_DIR=/path/paddle_influence_dir\")\nendif()\n+message(\"PADDLE_DIR IS:\"${PADDLE_DIR})\nif (NOT DEFINED OPENCV_DIR OR ${OPENCV_DIR} STREQUAL \"\")\nmessage(FATAL_ERROR \"please set OPENCV_DIR with -DOPENCV_DIR=/path/opencv\")\n@@ -70,6 +73,8 @@ link_directories(\"${PADDLE_DIR}/third_party/install/xxhash/lib\")\nlink_directories(\"${PADDLE_DIR}/paddle/lib/\")\nlink_directories(\"${CMAKE_CURRENT_BINARY_DIR}\")\n+\n+\nif (WIN32)\ninclude_directories(\"${PADDLE_DIR}/paddle/fluid/inference\")\ninclude_directories(\"${PADDLE_DIR}/paddle/include\")\n@@ -151,7 +156,19 @@ else()\nset(MATH_LIB ${PADDLE_DIR}/third_party/install/openblas/lib/libopenblas${CMAKE_STATIC_LIBRARY_SUFFIX})\nendif()\n+\nif (WIN32)\n+ if (USE_PADDLE_20RC1)\n+ # 2.0rc1 win32 shared lib name is paddle_fluid.dll and paddle_fluid.lib\n+ if(EXISTS \"${PADDLE_DIR}/paddle/fluid/inference/paddle_fluid${CMAKE_STATIC_LIBRARY_SUFFIX}\")\n+ set(DEPS\n+ ${PADDLE_DIR}/paddle/fluid/inference/paddle_fluid${CMAKE_STATIC_LIBRARY_SUFFIX})\n+ else()\n+ set(DEPS\n+ ${PADDLE_DIR}/paddle/lib/paddle_fluid${CMAKE_STATIC_LIBRARY_SUFFIX})\n+ endif()\n+ else()\n+ # before 2.0rc1 win32 shared lib name is libpaddle_fluid.dll and libpaddle_fluid.lib\nif(EXISTS \"${PADDLE_DIR}/paddle/fluid/inference/libpaddle_fluid${CMAKE_STATIC_LIBRARY_SUFFIX}\")\nset(DEPS\n${PADDLE_DIR}/paddle/fluid/inference/libpaddle_fluid${CMAKE_STATIC_LIBRARY_SUFFIX})\n@@ -160,15 +177,41 @@ if (WIN32)\n${PADDLE_DIR}/paddle/lib/libpaddle_fluid${CMAKE_STATIC_LIBRARY_SUFFIX})\nendif()\nendif()\n+endif()\n+\n+\n+if (WITH_STATIC_LIB)\n+ if (WIN32 AND USE_PADDLE_20RC1)\n+ message(\"This situation is actually in dynamic build mode\")\n+ set(DEPS ${PADDLE_LIB}/paddle/lib/addle_fluid${CMAKE_STATIC_LIBRARY_SUFFIX})\n+ else()\n+ set(DEPS ${PADDLE_LIB}/paddle/lib/libpaddle_fluid${CMAKE_STATIC_LIBRARY_SUFFIX})\n+ endif()\n+else()\n+ if (WIN32)\n+ if (USE_PADDLE_20RC1)\n+ # 2.0rc1 win32 shared lib name is paddle_fluid.dll and paddle_fluid.lib\n+ set(DEPS ${PADDLE_LIB}/paddle/lib/paddle_fluid${CMAKE_STATIC_LIBRARY_SUFFIX})\n+ else()\n+ # before 2.0rc1 win32 shared lib name is libpaddle_fluid.dll and libpaddle_fluid.lib\n+ set(DEPS ${PADDLE_LIB}/paddle/lib/libpaddle_fluid${CMAKE_STATIC_LIBRARY_SUFFIX})\n+ endif()\n+ else()\n+ # linux shared lib name is libpaddle_fluid.so\n+ set(DEPS ${PADDLE_LIB}/paddle/lib/libpaddle_fluid${CMAKE_SHARED_LIBRARY_SUFFIX})\n+ endif()\n+endif()\n+\nif(WITH_STATIC_LIB)\nset(DEPS\n${PADDLE_DIR}/paddle/lib/libpaddle_fluid${CMAKE_STATIC_LIBRARY_SUFFIX})\nelse()\nset(DEPS\n- ${PADDLE_DIR}/paddle/lib/libpaddle_fluid${CMAKE_SHARED_LIBRARY_SUFFIX})\n+ ${PADDLE_DIR}/paddle/lib/${WIN32_PADDLE_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})\nendif()\n+\nif (NOT WIN32)\nset(DEPS ${DEPS}\n${MATH_LIB} ${MKLDNN_LIB}\n@@ -228,3 +271,10 @@ if (WIN32 AND WITH_MKL)\nCOMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_DIR}/third_party/install/mkldnn/lib/mkldnn.dll ./release/mkldnn.dll\n)\nendif()\n+\n+\n+if (WIN32 AND USE_PADDLE_20RC1)\n+ add_custom_command(TARGET main POST_BUILD\n+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_DIR}/paddle/lib/paddle_fluid.dll ./release/paddle_fluid.dll\n+ )\n+endif()\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix build error when using paddle_inference_lib 2.0rc1 on windows in dygraph mode (#2042)
499,333
18.01.2021 14:53:58
-28,800
99ad5a84ae1f63881a9a6e1cc2bfa5b30494eac2
fix_eval, test=dygraph
[ { "change_type": "MODIFY", "old_path": "dygraph/ppdet/engine/trainer.py", "new_path": "dygraph/ppdet/engine/trainer.py", "diff": "@@ -97,8 +97,8 @@ class Trainer(object):\ndef _init_metrics(self):\nif self.mode == 'eval':\nif self.cfg.metric == 'COCO':\n- mask_resolution = self.model.mask_post_process.mask_resolution if hasattr(\n- self.model, 'mask_post_process') else None\n+ mask_resolution = self.model.mask_post_process.mask_resolution if getattr(\n+ self.model, 'mask_post_process', None) else None\nself._metrics = [\nCOCOMetric(\nanno_file=self.dataset.get_anno(),\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix_eval, test=dygraph (#2082)
499,304
18.01.2021 19:08:18
-28,800
e7dbeb06b4972995920e9a2c3f563f67544ca5a3
fix dygraph solov2 configs, test=dygraph
[ { "change_type": "MODIFY", "old_path": "dygraph/configs/solov2/solov2_r50_fpn_1x_coco.yml", "new_path": "dygraph/configs/solov2/solov2_r50_fpn_1x_coco.yml", "diff": "_BASE_: [\n- '../_base_/datasets/coco_instance.yml',\n- '../_base_/runtime.yml',\n+ '../datasets/coco_instance.yml',\n+ '../runtime.yml',\n'_base_/solov2_r50_fpn.yml',\n'_base_/optimizer_1x.yml',\n'_base_/solov2_reader.yml',\n" }, { "change_type": "MODIFY", "old_path": "dygraph/configs/solov2/solov2_r50_fpn_3x_coco.yml", "new_path": "dygraph/configs/solov2/solov2_r50_fpn_3x_coco.yml", "diff": "_BASE_: [\n- '../_base_/datasets/coco_instance.yml',\n- '../_base_/runtime.yml',\n+ '../datasets/coco_instance.yml',\n+ '../runtime.yml',\n'_base_/solov2_r50_fpn.yml',\n'_base_/optimizer_1x.yml',\n'_base_/solov2_reader.yml',\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/layers.py", "new_path": "dygraph/ppdet/modeling/layers.py", "diff": "@@ -900,6 +900,8 @@ class FCOSBox(object):\nreturn pred_boxes, pred_scores\n+@register\n+@serializable\nclass MaskMatrixNMS(object):\n\"\"\"\nMatrix NMS for multi-class masks.\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix dygraph solov2 configs, test=dygraph (#2086)
499,304
18.01.2021 20:07:56
-28,800
2bdb9a862a12eb1e2d043236ef13c01278f6adaa
fix dygraph re5_head bug, test=dygraph
[ { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/backbones/resnet.py", "new_path": "dygraph/ppdet/modeling/backbones/resnet.py", "diff": "@@ -530,14 +530,15 @@ class ResNet(nn.Layer):\n@register\nclass Res5Head(nn.Layer):\n- def __init__(self, feat_in=1024, feat_out=512):\n+ def __init__(self, depth=50, feat_in=1024, feat_out=512):\nsuper(Res5Head, self).__init__()\nna = NameAdapter(self)\nself.res5_conv = []\nself.res5 = self.add_sublayer(\n'res5_roi_feat',\nBlocks(\n- feat_in, feat_out, count=3, name_adapter=na, stage_num=5))\n+ depth, feat_in, feat_out, count=3, name_adapter=na,\n+ stage_num=5))\nself.feat_out = feat_out * 4\ndef forward(self, roi_feat, stage=0):\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix dygraph re5_head bug, test=dygraph (#2088)
499,304
19.01.2021 11:18:29
-28,800
05e4883b46f71c4f546051001a150f636f61edef
fix paddle.shape in export model
[ { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/layers.py", "new_path": "dygraph/ppdet/modeling/layers.py", "diff": "@@ -536,7 +536,7 @@ class RCNNBox(object):\n# TODO: Updata box_clip\norigin_h = paddle.unsqueeze(origin_shape[:, 0] - 1, axis=1)\norigin_w = paddle.unsqueeze(origin_shape[:, 1] - 1, axis=1)\n- zeros = paddle.zeros(origin_h.shape, 'float32')\n+ zeros = paddle.zeros(paddle.shape(origin_h), 'float32')\nx1 = paddle.maximum(paddle.minimum(bbox[:, :, 0], origin_w), zeros)\ny1 = paddle.maximum(paddle.minimum(bbox[:, :, 1], origin_h), zeros)\nx2 = paddle.maximum(paddle.minimum(bbox[:, :, 2], origin_w), zeros)\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix paddle.shape in export model (#2091)
499,304
26.01.2021 20:20:33
-28,800
13f0b561ae243eb98eb73119a77035c5afa6fdf8
fix background_label in nms
[ { "change_type": "MODIFY", "old_path": "dygraph/configs/fcos/_base_/fcos_r50_fpn.yml", "new_path": "dygraph/configs/fcos/_base_/fcos_r50_fpn.yml", "diff": "@@ -57,4 +57,3 @@ FCOSPostProcess:\nkeep_top_k: 100\nscore_threshold: 0.025\nnms_threshold: 0.6\n- background_label: -1\n" }, { "change_type": "MODIFY", "old_path": "dygraph/configs/ppyolo/_base_/ppyolo_r50vd_dcn.yml", "new_path": "dygraph/configs/ppyolo/_base_/ppyolo_r50vd_dcn.yml", "diff": "@@ -67,4 +67,3 @@ BBoxPostProcess:\npost_threshold: 0.01\nnms_top_k: -1\nnormalized: false\n- background_label: -1\n" }, { "change_type": "MODIFY", "old_path": "dygraph/configs/yolov3/_base_/yolov3_darknet53.yml", "new_path": "dygraph/configs/yolov3/_base_/yolov3_darknet53.yml", "diff": "@@ -42,4 +42,3 @@ BBoxPostProcess:\nnms_threshold: 0.45\nnms_top_k: 1000\nnormalized: false\n- background_label: -1\n" }, { "change_type": "MODIFY", "old_path": "dygraph/configs/yolov3/_base_/yolov3_mobilenet_v1.yml", "new_path": "dygraph/configs/yolov3/_base_/yolov3_mobilenet_v1.yml", "diff": "@@ -43,4 +43,3 @@ BBoxPostProcess:\nnms_threshold: 0.45\nnms_top_k: 1000\nnormalized: false\n- background_label: -1\n" }, { "change_type": "MODIFY", "old_path": "dygraph/configs/yolov3/_base_/yolov3_mobilenet_v3_large.yml", "new_path": "dygraph/configs/yolov3/_base_/yolov3_mobilenet_v3_large.yml", "diff": "@@ -44,4 +44,3 @@ BBoxPostProcess:\nnms_threshold: 0.45\nnms_top_k: 1000\nnormalized: false\n- background_label: -1\n" }, { "change_type": "MODIFY", "old_path": "dygraph/configs/yolov3/_base_/yolov3_mobilenet_v3_small.yml", "new_path": "dygraph/configs/yolov3/_base_/yolov3_mobilenet_v3_small.yml", "diff": "@@ -44,4 +44,3 @@ BBoxPostProcess:\nnms_threshold: 0.45\nnms_top_k: 1000\nnormalized: false\n- background_label: -1\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/engine/trainer.py", "new_path": "dygraph/ppdet/engine/trainer.py", "diff": "@@ -54,7 +54,7 @@ class Trainer(object):\nself.model = create(cfg.architecture)\n# model slim build\n- if cfg.slim:\n+ if 'slim' in cfg and cfg.slim:\nif self.mode == 'train':\nself.load_weights(cfg.pretrain_weights, cfg.weight_type)\nslim = create(cfg.slim)\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix background_label in nms (#2125)
499,304
27.01.2021 16:06:57
-28,800
52438b300c597d46a43ea5227a67b610b4c71f2d
fix dygraph getting_started doc
[ { "change_type": "MODIFY", "old_path": "dygraph/requirements.txt", "new_path": "dygraph/requirements.txt", "diff": "@@ -4,5 +4,3 @@ visualdl>=2.0.0b\nopencv-python\nPyYAML\nshapely\n-llvmlite==0.33\n-numba==0.50\n" }, { "change_type": "MODIFY", "old_path": "dygraph/tools/eval.py", "new_path": "dygraph/tools/eval.py", "diff": "@@ -22,7 +22,7 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2)))\nif parent_path not in sys.path:\nsys.path.append(parent_path)\n-# ignore numba warning\n+# ignore warning log\nimport warnings\nwarnings.filterwarnings('ignore')\n@@ -55,9 +55,6 @@ def parse_args():\ntype=str,\nhelp=\"Configuration file of slim method.\")\n- parser.add_argument(\n- '--use_gpu', action='store_true', default=False, help='')\n-\nargs = parser.parse_args()\nreturn args\n" }, { "change_type": "MODIFY", "old_path": "dygraph/tools/export_model.py", "new_path": "dygraph/tools/export_model.py", "diff": "@@ -21,7 +21,7 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2)))\nif parent_path not in sys.path:\nsys.path.append(parent_path)\n-# ignore numba warning\n+# ignore warning log\nimport warnings\nwarnings.filterwarnings('ignore')\n" }, { "change_type": "MODIFY", "old_path": "dygraph/tools/infer.py", "new_path": "dygraph/tools/infer.py", "diff": "@@ -21,7 +21,7 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2)))\nif parent_path not in sys.path:\nsys.path.append(parent_path)\n-# ignore numba warning\n+# ignore warning log\nimport warnings\nwarnings.filterwarnings('ignore')\nimport glob\n" }, { "change_type": "MODIFY", "old_path": "dygraph/tools/train.py", "new_path": "dygraph/tools/train.py", "diff": "@@ -22,7 +22,7 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2)))\nif parent_path not in sys.path:\nsys.path.append(parent_path)\n-# ignore numba warning\n+# ignore warning log\nimport warnings\nwarnings.filterwarnings('ignore')\nimport random\n@@ -49,16 +49,6 @@ def parse_args():\ntype=str,\nhelp=\"Loading Checkpoints only support 'pretrain', 'finetune', 'resume'.\"\n)\n- parser.add_argument(\n- \"--fp16\",\n- action='store_true',\n- default=False,\n- help=\"Enable mixed precision training.\")\n- parser.add_argument(\n- \"--loss_scale\",\n- default=8.,\n- type=float,\n- help=\"Mixed precision training loss scale.\")\nparser.add_argument(\n\"--eval\",\naction='store_true',\n@@ -75,8 +65,6 @@ def parse_args():\ndefault=False,\nhelp=\"If set True, enable continuous evaluation job.\"\n\"This flag is only used for internal test.\")\n- parser.add_argument(\n- \"--use_gpu\", action='store_true', default=False, help=\"data parallel\")\nargs = parser.parse_args()\nreturn args\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix dygraph getting_started doc (#2128)
499,298
29.01.2021 11:07:36
-28,800
d48b3ff7b8f86663b0f1c8c0cc720eeeeb246f85
fit for fcos
[ { "change_type": "MODIFY", "old_path": "dygraph/configs/fcos/_base_/fcos_r50_fpn.yml", "new_path": "dygraph/configs/fcos/_base_/fcos_r50_fpn.yml", "diff": "@@ -17,11 +17,9 @@ ResNet:\nnum_stages: 4\nFPN:\n- in_channels: [256, 512, 1024, 2048]\nout_channel: 256\n- min_level: 1\n- max_level: 5\n- spatial_scale: [0.125, 0.0625, 0.03125]\n+ spatial_scales: [0.125, 0.0625, 0.03125]\n+ extra_stage: 2\nhas_extra_convs: true\nuse_c5: false\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/architectures/fcos.py", "new_path": "dygraph/ppdet/modeling/architectures/fcos.py", "diff": "@@ -17,7 +17,7 @@ from __future__ import division\nfrom __future__ import print_function\nimport paddle\n-from ppdet.core.workspace import register\n+from ppdet.core.workspace import register, create\nfrom .meta_arch import BaseArch\n__all__ = ['FCOS']\n@@ -26,12 +26,7 @@ __all__ = ['FCOS']\n@register\nclass FCOS(BaseArch):\n__category__ = 'architecture'\n- __inject__ = [\n- 'backbone',\n- 'neck',\n- 'fcos_head',\n- 'fcos_post_process',\n- ]\n+ __inject__ = ['fcos_post_process']\ndef __init__(self,\nbackbone,\n@@ -44,16 +39,32 @@ class FCOS(BaseArch):\nself.fcos_head = fcos_head\nself.fcos_post_process = fcos_post_process\n- def model_arch(self, ):\n- body_feats = self.backbone(self.inputs)\n+ @classmethod\n+ def from_config(cls, cfg, *args, **kwargs):\n+ backbone = create(cfg['backbone'])\n+\n+ kwargs = {'input_shape': backbone.out_shape}\n+ neck = create(cfg['neck'], **kwargs)\n- fpn_feats, spatial_scale = self.neck(body_feats)\n+ kwargs = {'input_shape': neck.out_shape}\n+ fcos_head = create(cfg['fcos_head'], **kwargs)\n- self.fcos_head_outs = self.fcos_head(fpn_feats, self.training)\n+ return {\n+ 'backbone': backbone,\n+ 'neck': neck,\n+ \"fcos_head\": fcos_head,\n+ }\n+ def _forward(self):\n+ body_feats = self.backbone(self.inputs)\n+ fpn_feats = self.neck(body_feats)\n+ fcos_head_outs = self.fcos_head(fpn_feats, self.training)\nif not self.training:\n- self.bboxes = self.fcos_post_process(self.fcos_head_outs,\n- self.inputs['scale_factor'])\n+ scale_factor = self.inputs['scale_factor']\n+ bboxes = self.fcos_post_process(fcos_head_outs, scale_factor)\n+ return bboxes\n+ else:\n+ return fcos_head_outs\ndef get_loss(self, ):\nloss = {}\n@@ -70,7 +81,8 @@ class FCOS(BaseArch):\nif k_ctn in self.inputs:\ntag_centerness.append(self.inputs[k_ctn])\n- loss_fcos = self.fcos_head.get_loss(self.fcos_head_outs, tag_labels,\n+ fcos_head_outs = self._forward()\n+ loss_fcos = self.fcos_head.get_loss(fcos_head_outs, tag_labels,\ntag_bboxes, tag_centerness)\nloss.update(loss_fcos)\ntotal_loss = paddle.add_n(list(loss.values()))\n@@ -78,9 +90,14 @@ class FCOS(BaseArch):\nreturn loss\ndef get_pred(self):\n- bbox, bbox_num = self.bboxes\n+ bboxes, bbox_num = self._forward()\n+ label = bboxes[:, 0]\n+ score = bboxes[:, 1]\n+ bbox = bboxes[:, 2:]\noutput = {\n'bbox': bbox,\n- 'bbox_num': bbox_num,\n+ 'score': score,\n+ 'label': label,\n+ 'bbox_num': bbox_num\n}\nreturn output\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/necks/fpn.py", "new_path": "dygraph/ppdet/modeling/necks/fpn.py", "diff": "@@ -52,12 +52,16 @@ class FPN(Layer):\nself.fpn_convs = []\nfan = out_channel * 3 * 3\n- for i in range(len(in_channels)):\n+ # stage index 0,1,2,3 stands for res2,res3,res4,res5 on ResNet Backbone\n+ # 0 <= st_stage < ed_stage <= 3\n+ st_stage = 4 - len(in_channels)\n+ ed_stage = st_stage + len(in_channels) - 1\n+ for i in range(st_stage, ed_stage + 1):\nif i == 3:\nlateral_name = 'fpn_inner_res5_sum'\nelse:\nlateral_name = 'fpn_inner_res{}_sum_lateral'.format(i + 2)\n- in_c = in_channels[i]\n+ in_c = in_channels[i - st_stage]\nlateral = self.add_sublayer(\nlateral_name,\nConv2D(\n@@ -82,8 +86,9 @@ class FPN(Layer):\n# add extra conv levels for RetinaNet(use_c5)/FCOS(use_p5)\nif self.has_extra_convs:\n- for lvl in range(self.extra_stage): # P6 P7 ...\n- if lvl == 0 and self.use_c5:\n+ for i in range(self.extra_stage):\n+ lvl = ed_stage + 1 + i\n+ if i == 0 and self.use_c5:\nin_c = in_channels[-1]\nelse:\nin_c = out_channel\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fit for fcos (#2133)
499,333
30.01.2021 11:24:37
-28,800
3cd9e8571aecbfa36ff765f432a2998652eb24b3
fix batch size > 1, test=dygraph
[ { "change_type": "MODIFY", "old_path": "dygraph/ppdet/data/transform/batch_operator.py", "new_path": "dygraph/ppdet/data/transform/batch_operator.py", "diff": "@@ -115,8 +115,8 @@ class PadBatchOp(BaseOperator):\ngt_num_max = max(gt_num)\nfor i, data in enumerate(samples):\n- gt_box_data = np.zeros([gt_num_max, 4], dtype=np.float32)\n- gt_class_data = np.zeros([gt_num_max], dtype=np.int32)\n+ gt_box_data = -np.ones([gt_num_max, 4], dtype=np.float32)\n+ gt_class_data = -np.ones([gt_num_max], dtype=np.int32)\nis_crowd_data = np.ones([gt_num_max], dtype=np.int32)\nif pad_mask:\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/proposal_generator/target.py", "new_path": "dygraph/ppdet/modeling/proposal_generator/target.py", "diff": "@@ -69,16 +69,15 @@ def label_box(anchors, gt_boxes, positive_overlap, negative_overlap,\nreturn default_matches, default_match_labels\nmatched_vals, matches = paddle.topk(iou, k=1, axis=0)\nmatch_labels = paddle.full(matches.shape, -1, dtype='int32')\n-\nmatch_labels = paddle.where(matched_vals < negative_overlap,\npaddle.zeros_like(match_labels), match_labels)\nmatch_labels = paddle.where(matched_vals >= positive_overlap,\npaddle.ones_like(match_labels), match_labels)\nif allow_low_quality:\nhighest_quality_foreach_gt = iou.max(axis=1, keepdim=True)\n- pred_inds_with_highest_quality = (\n- iou == highest_quality_foreach_gt).cast('int32').sum(0,\n- keepdim=True)\n+ pred_inds_with_highest_quality = paddle.logical_and(\n+ iou > 0, iou == highest_quality_foreach_gt).cast('int32').sum(\n+ 0, keepdim=True)\nmatch_labels = paddle.where(pred_inds_with_highest_quality > 0,\npaddle.ones_like(match_labels),\nmatch_labels)\n@@ -151,7 +150,7 @@ def generate_proposal_target(rpn_rois,\nfor i, rpn_roi in enumerate(rpn_rois):\nmax_overlap = max_overlaps[i] if is_cascade_rcnn else None\ngt_bbox = gt_boxes[i]\n- gt_classes = gt_classes[i]\n+ gt_class = gt_classes[i]\nif is_cascade_rcnn:\nrpn_roi = filter_roi(rpn_roi, max_overlap)\nbbox = paddle.concat([rpn_roi, gt_bbox])\n@@ -161,7 +160,7 @@ def generate_proposal_target(rpn_rois,\nbbox, gt_bbox, fg_thresh, bg_thresh, False)\n# Step2: sample bbox\nsampled_inds, sampled_gt_classes = sample_bbox(\n- matches, match_labels, gt_classes, batch_size_per_im, fg_fraction,\n+ matches, match_labels, gt_class, batch_size_per_im, fg_fraction,\nnum_classes, use_random)\n# Step3: make output\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix batch size > 1, test=dygraph (#2141)
499,395
30.01.2021 13:13:40
-28,800
c466de67fc381947f9b7e4411cb13d9a8240c87b
fix bug while training in single gpu
[ { "change_type": "MODIFY", "old_path": "dygraph/ppdet/engine/trainer.py", "new_path": "dygraph/ppdet/engine/trainer.py", "diff": "@@ -167,6 +167,8 @@ class Trainer(object):\nif self._nranks > 1:\nmodel = paddle.DataParallel(self.model)\n+ else:\n+ model = self.model\nself.status.update({\n'epoch_id': self.start_epoch,\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix bug while training in single gpu (#2140)
499,298
30.01.2021 19:14:41
-28,800
6d92ef310233184690ed5db2e1a52f0271618568
fix res5head config
[ { "change_type": "MODIFY", "old_path": "dygraph/configs/faster_rcnn/faster_rcnn_r101_1x_coco.yml", "new_path": "dygraph/configs/faster_rcnn/faster_rcnn_r101_1x_coco.yml", "diff": "@@ -10,5 +10,5 @@ ResNet:\ndepth: 101\nnorm_type: bn\nfreeze_at: 0\n- return_idx: [0,1,2,3]\n- num_stages: 4\n+ return_idx: [2]\n+ num_stages: 3\n" }, { "change_type": "MODIFY", "old_path": "dygraph/configs/faster_rcnn/faster_rcnn_r50_vd_1x_coco.yml", "new_path": "dygraph/configs/faster_rcnn/faster_rcnn_r50_vd_1x_coco.yml", "diff": "@@ -10,5 +10,5 @@ ResNet:\nvariant: d\nnorm_type: bn\nfreeze_at: 0\n- return_idx: [0,1,2,3]\n- num_stages: 4\n+ return_idx: [2]\n+ num_stages: 3\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix res5head config (#2138)
499,313
30.01.2021 20:32:56
-28,800
bf700a8e700b69149c65d849cf942ba2959b19ab
fix ssd background to last
[ { "change_type": "MODIFY", "old_path": "dygraph/ppdet/engine/trainer.py", "new_path": "dygraph/ppdet/engine/trainer.py", "diff": "@@ -165,6 +165,7 @@ class Trainer(object):\nif not self._weights_loaded:\nself.load_weights(self.cfg.pretrain_weights)\n+ model = self.model\nif self._nranks > 1:\nmodel = paddle.DataParallel(self.model)\nelse:\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/metrics/map_utils.py", "new_path": "dygraph/ppdet/metrics/map_utils.py", "diff": "@@ -102,7 +102,7 @@ class DetectionMAP(object):\nself.evaluate_difficult = evaluate_difficult\nself.reset()\n- def update(self, bbox, gt_box, gt_label, difficult=None):\n+ def update(self, bbox, score, label, gt_box, gt_label, difficult=None):\n\"\"\"\nUpdate metric statics from given prediction and ground\ntruth infomations.\n@@ -117,13 +117,13 @@ class DetectionMAP(object):\n# record class score positive\nvisited = [False] * len(gt_label)\n- for b in bbox:\n- label, score, xmin, ymin, xmax, ymax = b.tolist()\n+ for b, s, l in zip(bbox, score, label):\n+ xmin, ymin, xmax, ymax = b.tolist()\npred = [xmin, ymin, xmax, ymax]\nmax_idx = -1\nmax_overlap = -1.0\nfor i, gl in enumerate(gt_label):\n- if int(gl) == int(label):\n+ if int(gl) == int(l):\noverlap = jaccard_overlap(pred, gt_box[i],\nself.is_bbox_normalized)\nif overlap > max_overlap:\n@@ -134,12 +134,12 @@ class DetectionMAP(object):\nif self.evaluate_difficult or \\\nint(np.array(difficult[max_idx])) == 0:\nif not visited[max_idx]:\n- self.class_score_poss[int(label)].append([score, 1.0])\n+ self.class_score_poss[int(l)].append([s, 1.0])\nvisited[max_idx] = True\nelse:\n- self.class_score_poss[int(label)].append([score, 0.0])\n+ self.class_score_poss[int(l)].append([s, 0.0])\nelse:\n- self.class_score_poss[int(label)].append([score, 0.0])\n+ self.class_score_poss[int(l)].append([s, 0.0])\ndef reset(self):\n\"\"\"\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/metrics/metrics.py", "new_path": "dygraph/ppdet/metrics/metrics.py", "diff": "@@ -148,6 +148,8 @@ class VOCMetric(Metric):\ndef update(self, inputs, outputs):\nbboxes = outputs['bbox'].numpy()\n+ scores = outputs['score'].numpy()\n+ labels = outputs['label'].numpy()\nbbox_lengths = outputs['bbox_num'].numpy()\nif bboxes.shape == (1, 1) or bboxes is None:\n@@ -171,9 +173,12 @@ class VOCMetric(Metric):\nelse difficults[i]\nbbox_num = bbox_lengths[i]\nbbox = bboxes[bbox_idx:bbox_idx + bbox_num]\n+ score = scores[bbox_idx:bbox_idx + bbox_num]\n+ label = labels[bbox_idx:bbox_idx + bbox_num]\ngt_box, gt_label, difficult = prune_zero_padding(gt_box, gt_label,\ndifficult)\n- self.detection_map.update(bbox, gt_box, gt_label, difficult)\n+ self.detection_map.update(bbox, score, label, gt_box, gt_label,\n+ difficult)\nbbox_idx += bbox_num\ndef accumulate(self):\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/architectures/ssd.py", "new_path": "dygraph/ppdet/modeling/architectures/ssd.py", "diff": "@@ -54,4 +54,14 @@ class SSD(BaseArch):\nreturn {\"loss\": self._forward()}\ndef get_pred(self):\n- return dict(zip(['bbox', 'bbox_num'], self._forward()))\n+ bbox_pred, bbox_num = self._forward()\n+ label = bbox_pred[:, 0]\n+ score = bbox_pred[:, 1]\n+ bbox = bbox_pred[:, 2:]\n+ output = {\n+ 'bbox': bbox,\n+ 'score': score,\n+ 'label': label,\n+ 'bbox_num': bbox_num\n+ }\n+ return output\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/heads/ssd_head.py", "new_path": "dygraph/ppdet/modeling/heads/ssd_head.py", "diff": "@@ -58,7 +58,7 @@ class SSDHead(nn.Layer):\n__inject__ = ['anchor_generator', 'loss']\ndef __init__(self,\n- num_classes=81,\n+ num_classes=80,\nin_channels=(512, 1024, 512, 256, 256, 256),\nanchor_generator=AnchorGeneratorSSD().__dict__,\nkernel_size=3,\n@@ -67,7 +67,8 @@ class SSDHead(nn.Layer):\nconv_decay=0.,\nloss='SSDLoss'):\nsuper(SSDHead, self).__init__()\n- self.num_classes = num_classes\n+ # add background class\n+ self.num_classes = num_classes + 1\nself.in_channels = in_channels\nself.anchor_generator = anchor_generator\nself.loss = loss\n@@ -106,7 +107,7 @@ class SSDHead(nn.Layer):\nscore_conv_name,\nnn.Conv2D(\nin_channels=in_channels[i],\n- out_channels=num_prior * num_classes,\n+ out_channels=num_prior * self.num_classes,\nkernel_size=kernel_size,\npadding=padding))\nelse:\n@@ -114,7 +115,7 @@ class SSDHead(nn.Layer):\nscore_conv_name,\nSepConvLayer(\nin_channels=in_channels[i],\n- out_channels=num_prior * num_classes,\n+ out_channels=num_prior * self.num_classes,\nkernel_size=kernel_size,\npadding=padding,\nconv_decay=conv_decay,\n@@ -129,8 +130,8 @@ class SSDHead(nn.Layer):\nbox_preds = []\ncls_scores = []\nprior_boxes = []\n- for feat, box_conv, score_conv in zip(feats, self.box_convs,\n- self.score_convs):\n+ for i, (feat, box_conv, score_conv\n+ ) in enumerate(zip(feats, self.box_convs, self.score_convs)):\nbox_pred = box_conv(feat)\nbox_pred = paddle.transpose(box_pred, [0, 2, 3, 1])\nbox_pred = paddle.reshape(box_pred, [0, -1, 4])\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/losses/ssd_loss.py", "new_path": "dygraph/ppdet/modeling/losses/ssd_loss.py", "diff": "@@ -114,7 +114,8 @@ class SSDLoss(nn.Layer):\nscores = paddle.concat(scores, axis=1)\nprior_boxes = paddle.concat(anchors, axis=0)\ngt_label = gt_class.unsqueeze(-1)\n- batch_size, num_priors, num_classes = scores.shape\n+ batch_size, num_priors = scores.shape[:2]\n+ num_classes = scores.shape[-1] - 1\ndef _reshape_to_2d(x):\nreturn paddle.flatten(x, start_axis=2)\n@@ -137,7 +138,8 @@ class SSDLoss(nn.Layer):\n# 2. Compute confidence for mining hard examples\n# 2.1. Get the target label based on matched indices\n- target_label, _ = self._label_target_assign(gt_label, matched_indices)\n+ target_label, _ = self._label_target_assign(\n+ gt_label, matched_indices, mismatch_value=num_classes)\nconfidence = _reshape_to_2d(scores)\n# 2.2. Compute confidence loss.\n# Reshape confidence to 2D tensor.\n@@ -173,7 +175,10 @@ class SSDLoss(nn.Layer):\nencoded_bbox, matched_indices)\n# 4.3. Assign classification targets\ntarget_label, target_conf_weight = self._label_target_assign(\n- gt_label, matched_indices, neg_mask=neg_mask)\n+ gt_label,\n+ matched_indices,\n+ neg_mask=neg_mask,\n+ mismatch_value=num_classes)\n# 5. Compute loss.\n# 5.1 Compute confidence loss.\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix ssd background to last (#2145)
499,304
01.02.2021 16:46:44
-28,800
83f11ba02da50dc12d4ceef91be4968fea31fd5e
fix init_metrics and prune
[ { "change_type": "MODIFY", "old_path": "dygraph/ppdet/engine/trainer.py", "new_path": "dygraph/ppdet/engine/trainer.py", "diff": "@@ -110,6 +110,9 @@ class Trainer(object):\nself._compose_callback = None\ndef _init_metrics(self):\n+ if self.mode == 'test':\n+ self._metrics = []\n+ return\nif self.cfg.metric == 'COCO':\nself._metrics = [COCOMetric(anno_file=self.dataset.get_anno())]\nelif self.cfg.metric == 'VOC':\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/slim/prune.py", "new_path": "dygraph/ppdet/slim/prune.py", "diff": "@@ -49,6 +49,9 @@ class Pruner(object):\nself.print_params = print_params\ndef __call__(self, model):\n+ # FIXME: adapt to network graph when Training and inference are\n+ # inconsistent, now only supports prune inference network graph.\n+ model.eval()\npaddleslim = try_import('paddleslim')\nfrom paddleslim.analysis import dygraph_flops as flops\ninput_spec = [{\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix init_metrics and prune (#2153)
499,395
02.02.2021 15:37:13
-28,800
524f56f96a11133e0f55fb76bc3d556d37e805a0
fix bias problem while training
[ { "change_type": "MODIFY", "old_path": "dygraph/ppdet/engine/trainer.py", "new_path": "dygraph/ppdet/engine/trainer.py", "diff": "@@ -115,9 +115,10 @@ class Trainer(object):\nreturn\nif self.cfg.metric == 'COCO':\n# TODO: bias should be unified\n+ bias = 1 if 'bias' in self.cfg else 0\nself._metrics = [\nCOCOMetric(\n- anno_file=self.dataset.get_anno(), bias=self.cfg.bias)\n+ anno_file=self.dataset.get_anno(), bias=bias)\n]\nelif self.cfg.metric == 'VOC':\nself._metrics = [\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix bias problem while training (#2161)
499,333
02.02.2021 16:26:28
-28,800
bfbffe698653d93be26c183f6cf64556ccc743eb
update check_version
[ { "change_type": "MODIFY", "old_path": "ppdet/utils/check.py", "new_path": "ppdet/utils/check.py", "diff": "@@ -94,6 +94,8 @@ def check_version(version='1.7.0'):\nfor i in six.moves.range(length):\nif version_installed[i] > version_split[i]:\nreturn\n+ if len(version_installed[i]) == 1 and len(version_split[i]) > 1:\n+ return\nif version_installed[i] < version_split[i]:\nraise Exception(err)\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
update check_version (#2157)
499,395
05.02.2021 14:06:00
-28,800
9a4fae6d49c8e49e7c3168d69d94d77dfbb41785
fix hard code bias in eval
[ { "change_type": "MODIFY", "old_path": "dygraph/ppdet/engine/trainer.py", "new_path": "dygraph/ppdet/engine/trainer.py", "diff": "@@ -115,7 +115,7 @@ class Trainer(object):\nreturn\nif self.cfg.metric == 'COCO':\n# TODO: bias should be unified\n- bias = 1 if 'bias' in self.cfg else 0\n+ bias = self.cfg['bias'] if 'bias' in self.cfg else 0\nself._metrics = [\nCOCOMetric(\nanno_file=self.dataset.get_anno(), bias=bias)\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix hard code bias in eval (#2186)
499,313
06.02.2021 15:38:21
-28,800
2686dce87376d2e04ee857f28e626a4a454a203f
fix ssd export
[ { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/architectures/ssd.py", "new_path": "dygraph/ppdet/modeling/architectures/ssd.py", "diff": "@@ -43,9 +43,8 @@ class SSD(BaseArch):\nself.inputs['gt_bbox'],\nself.inputs['gt_class'])\nelse:\n- boxes, scores, anchors = self.ssd_head(body_feats,\n- self.inputs['image'])\n- bbox, bbox_num = self.post_process((boxes, scores), anchors,\n+ preds, anchors = self.ssd_head(body_feats, self.inputs['image'])\n+ bbox, bbox_num = self.post_process(preds, anchors,\nself.inputs['im_shape'],\nself.inputs['scale_factor'])\nreturn bbox, bbox_num\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/heads/ssd_head.py", "new_path": "dygraph/ppdet/modeling/heads/ssd_head.py", "diff": "@@ -130,8 +130,8 @@ class SSDHead(nn.Layer):\nbox_preds = []\ncls_scores = []\nprior_boxes = []\n- for i, (feat, box_conv, score_conv\n- ) in enumerate(zip(feats, self.box_convs, self.score_convs)):\n+ for feat, box_conv, score_conv in zip(feats, self.box_convs,\n+ self.score_convs):\nbox_pred = box_conv(feat)\nbox_pred = paddle.transpose(box_pred, [0, 2, 3, 1])\nbox_pred = paddle.reshape(box_pred, [0, -1, 4])\n@@ -148,7 +148,7 @@ class SSDHead(nn.Layer):\nreturn self.get_loss(box_preds, cls_scores, gt_bbox, gt_class,\nprior_boxes)\nelse:\n- return box_preds, cls_scores, prior_boxes\n+ return (box_preds, cls_scores), prior_boxes\ndef get_loss(self, boxes, scores, gt_bbox, gt_class, prior_boxes):\nreturn self.loss(boxes, scores, gt_bbox, gt_class, prior_boxes)\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix ssd export (#2176)
499,298
07.02.2021 16:12:31
-28,800
bda64b5d7244be5d986b6848b7c116418a8f9c9c
fix bs and voc_metrics, test=dygraph
[ { "change_type": "MODIFY", "old_path": "dygraph/ppdet/metrics/metrics.py", "new_path": "dygraph/ppdet/metrics/metrics.py", "diff": "@@ -149,9 +149,9 @@ class VOCMetric(Metric):\nself.detection_map.reset()\ndef update(self, inputs, outputs):\n- bboxes = outputs['bbox'].numpy()\n- scores = outputs['score'].numpy()\n- labels = outputs['label'].numpy()\n+ bboxes = outputs['bbox'][:, 2:].numpy()\n+ scores = outputs['bbox'][:, 1].numpy()\n+ labels = outputs['bbox'][:, 0].numpy()\nbbox_lengths = outputs['bbox_num'].numpy()\nif bboxes.shape == (1, 1) or bboxes is None:\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/proposal_generator/rpn_head.py", "new_path": "dygraph/ppdet/modeling/proposal_generator/rpn_head.py", "diff": "@@ -110,7 +110,7 @@ class RPNHead(nn.Layer):\n# TODO: Fix batch_size > 1 when testing.\nif self.training:\n- batch_size = im_shape.shape[0]\n+ batch_size = inputs['im_shape'].shape[0]\nelse:\nbatch_size = 1\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix bs and voc_metrics, test=dygraph (#2195)
499,333
10.02.2021 15:23:06
-28,800
ed6b5e9972f17de7fda5641cfb267bc4f966527b
fix mask rcnn, test=dygraph
[ { "change_type": "MODIFY", "old_path": "dygraph/configs/faster_rcnn/_base_/faster_rcnn_r50.yml", "new_path": "dygraph/configs/faster_rcnn/_base_/faster_rcnn_r50.yml", "diff": "@@ -34,7 +34,7 @@ RPNHead:\nnms_thresh: 0.7\npre_nms_top_n: 12000\npost_nms_top_n: 2000\n- topk_after_collect: True\n+ topk_after_collect: False\ntest_proposal:\nmin_size: 0.0\nnms_thresh: 0.7\n" }, { "change_type": "MODIFY", "old_path": "dygraph/configs/mask_rcnn/_base_/mask_rcnn_r50.yml", "new_path": "dygraph/configs/mask_rcnn/_base_/mask_rcnn_r50.yml", "diff": "@@ -35,7 +35,7 @@ RPNHead:\nnms_thresh: 0.7\npre_nms_top_n: 12000\npost_nms_top_n: 2000\n- topk_after_collect: True\n+ topk_after_collect: False\ntest_proposal:\nmin_size: 0.0\nnms_thresh: 0.7\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/backbones/resnet.py", "new_path": "dygraph/ppdet/modeling/backbones/resnet.py", "diff": "@@ -555,7 +555,7 @@ class Res5Head(nn.Layer):\ndef out_shape(self):\nreturn [ShapeSpec(\nchannels=self.feat_out,\n- stride=32, )]\n+ stride=16, )]\ndef forward(self, roi_feat, stage=0):\ny = self.res5(roi_feat)\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/bbox_utils.py", "new_path": "dygraph/ppdet/modeling/bbox_utils.py", "diff": "@@ -50,7 +50,7 @@ def delta2bbox(deltas, boxes, weights):\ndy = deltas[:, 1::4] / wy\ndw = deltas[:, 2::4] / ww\ndh = deltas[:, 3::4] / wh\n- # Prevent sending too large values into np.exp()\n+ # Prevent sending too large values into paddle.exp()\ndw = paddle.clip(dw, max=clip_scale)\ndh = paddle.clip(dh, max=clip_scale)\n@@ -64,7 +64,7 @@ def delta2bbox(deltas, boxes, weights):\npred_boxes.append(pred_ctr_y - 0.5 * pred_h)\npred_boxes.append(pred_ctr_x + 0.5 * pred_w)\npred_boxes.append(pred_ctr_y + 0.5 * pred_h)\n- pred_boxes = paddle.concat(pred_boxes, axis=-1)\n+ pred_boxes = paddle.stack(pred_boxes, axis=-1)\nreturn pred_boxes\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/heads/bbox_head.py", "new_path": "dygraph/ppdet/modeling/heads/bbox_head.py", "diff": "@@ -128,7 +128,7 @@ class BBoxHead(nn.Layer):\ndef forward(self, body_feats=None, rois=None, rois_num=None, inputs=None):\n\"\"\"\nbody_feats (list[Tensor]): Feature maps from backbone\n- rois (Tensor): RoIs generated from RPN module\n+ rois (list[Tensor]): RoIs generated from RPN module\nrois_num (Tensor): The number of RoIs in each image\ninputs (dict{Tensor}): The ground-truth of image\n\"\"\"\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/heads/cascade_head.py", "new_path": "dygraph/ppdet/modeling/heads/cascade_head.py", "diff": "@@ -187,6 +187,7 @@ class CascadeHead(BBoxHead):\npred_proposals = paddle.concat(proposals) if len(\nproposals) > 1 else proposals[0]\npred_bbox = delta2bbox(deltas, pred_proposals, weights)\n+ pred_bbox = paddle.reshape(pred_bbox, [-1, deltas.shape[-1]])\nnum_prop = [p.shape[0] for p in proposals]\nreturn pred_bbox.split(num_prop)\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/proposal_generator/rpn_head.py", "new_path": "dygraph/ppdet/modeling/proposal_generator/rpn_head.py", "diff": "@@ -116,7 +116,6 @@ class RPNHead(nn.Layer):\nrois, rois_num = self._gen_proposal(scores, deltas, anchors, inputs,\nbatch_size)\n-\nif self.training:\nloss = self.get_loss(scores, deltas, anchors, inputs)\nreturn rois, rois_num, loss\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/py_op/post_process.py", "new_path": "dygraph/ppdet/py_op/post_process.py", "diff": "@@ -55,6 +55,8 @@ def get_seg_res(masks, bboxes, mask_nums, image_id, label_to_cat_id_map):\nscore = float(bboxes[k][1])\nlabel = int(bboxes[k][0])\nk = k + 1\n+ if label == -1:\n+ continue\ncat_id = label_to_cat_id_map[label]\nrle = mask_util.encode(\nnp.array(\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix mask rcnn, test=dygraph (#2208)
499,304
11.02.2021 14:32:37
-28,800
609db8baec85d61fbdad17f5965cab27c0ffa5be
fix solov2 with_background & from_config
[ { "change_type": "MODIFY", "old_path": "dygraph/configs/solov2/_base_/solov2_r50_fpn.yml", "new_path": "dygraph/configs/solov2/_base_/solov2_r50_fpn.yml", "diff": "@@ -9,7 +9,6 @@ SOLOv2:\nmask_head: SOLOv2MaskHead\nResNet:\n- # index 0 stands for res2\ndepth: 50\nnorm_type: bn\nfreeze_at: 0\n@@ -17,11 +16,7 @@ ResNet:\nnum_stages: 4\nFPN:\n- in_channels: [256, 512, 1024, 2048]\nout_channel: 256\n- min_level: 0\n- max_level: 4\n- spatial_scale: [0.25, 0.125, 0.0625, 0.03125]\nSOLOv2Head:\nseg_feat_channels: 512\n@@ -32,7 +27,6 @@ SOLOv2Head:\nmask_nms: MaskMatrixNMS\nSOLOv2MaskHead:\n- in_channels: 256\nmid_channels: 128\nout_channels: 256\nstart_level: 0\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/data/transform/batch_operator.py", "new_path": "dygraph/ppdet/data/transform/batch_operator.py", "diff": "@@ -644,7 +644,7 @@ class Gt2Solov2TargetOp(BaseOperator):\nmax_ins_num = [0] * len(self.num_grids)\nfor sample in samples:\ngt_bboxes_raw = sample['gt_bbox']\n- gt_labels_raw = sample['gt_class']\n+ gt_labels_raw = sample['gt_class'] + 1\nim_c, im_h, im_w = sample['image'].shape[:]\ngt_masks_raw = sample['gt_segm'].astype(np.uint8)\nmask_feat_size = [\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/architectures/solov2.py", "new_path": "dygraph/ppdet/modeling/architectures/solov2.py", "diff": "@@ -18,7 +18,7 @@ from __future__ import print_function\nimport paddle\n-from ppdet.core.workspace import register\n+from ppdet.core.workspace import register, create\nfrom .meta_arch import BaseArch\n__all__ = ['SOLOv2']\n@@ -37,7 +37,6 @@ class SOLOv2(BaseArch):\n\"\"\"\n__category__ = 'architecture'\n- __inject__ = ['backbone', 'neck', 'solov2_head', 'mask_head']\ndef __init__(self, backbone, solov2_head, mask_head, neck=None):\nsuper(SOLOv2, self).__init__()\n@@ -46,11 +45,28 @@ class SOLOv2(BaseArch):\nself.solov2_head = solov2_head\nself.mask_head = mask_head\n+ @classmethod\n+ def from_config(cls, cfg, *args, **kwargs):\n+ backbone = create(cfg['backbone'])\n+\n+ kwargs = {'input_shape': backbone.out_shape}\n+ neck = create(cfg['neck'], **kwargs)\n+\n+ kwargs = {'input_shape': neck.out_shape}\n+ solov2_head = create(cfg['solov2_head'], **kwargs)\n+ mask_head = create(cfg['mask_head'], **kwargs)\n+\n+ return {\n+ 'backbone': backbone,\n+ 'neck': neck,\n+ 'solov2_head': solov2_head,\n+ 'mask_head': mask_head,\n+ }\n+\ndef model_arch(self):\nbody_feats = self.backbone(self.inputs)\n- if self.neck is not None:\n- body_feats, spatial_scale = self.neck(body_feats)\n+ body_feats = self.neck(body_feats)\nself.seg_pred = self.mask_head(body_feats)\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/modeling/heads/solov2_head.py", "new_path": "dygraph/ppdet/modeling/heads/solov2_head.py", "diff": "@@ -190,7 +190,7 @@ class SOLOv2Head(nn.Layer):\nself.num_classes = num_classes\nself.in_channels = in_channels\nself.seg_num_grids = num_grids\n- self.cate_out_channels = self.num_classes - 1\n+ self.cate_out_channels = self.num_classes\nself.seg_feat_channels = seg_feat_channels\nself.stacked_convs = stacked_convs\nself.kernel_out_channels = kernel_out_channels\n" }, { "change_type": "MODIFY", "old_path": "dygraph/ppdet/py_op/post_process.py", "new_path": "dygraph/ppdet/py_op/post_process.py", "diff": "@@ -87,7 +87,7 @@ def get_solov2_segm_res(results, image_id, num_id_to_cat_id_map):\nreturn None\n# for each sample\nfor i in range(lengths - 1):\n- clsid = int(clsid_labels[i]) + 1\n+ clsid = int(clsid_labels[i])\ncatid = num_id_to_cat_id_map[clsid]\nscore = float(clsid_scores[i])\nmask = segms[i]\n" } ]
Python
Apache License 2.0
paddlepaddle/paddledetection
fix solov2 with_background & from_config (#2205)