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,333 | 03.01.2020 13:41:39 | -28,800 | 1e6090d8910beb569dd1ed5baa45c8ab59feec7d | refine doc | [
{
"change_type": "MODIFY",
"old_path": "tools/cpp_demo.yml",
"new_path": "tools/cpp_demo.yml",
"diff": "-# demo for tensorrt_infer.py\n+# demo for cpp_infer.py\nmode: trt_fp32 # trt_fp32, trt_fp16, trt_int8, fluid\narch: RCNN # YOLO, SSD, RCNN, RetinaNet\nmin_subgraph_size: 20 # need 3 for YOLO arch\nuse_python_inference: False # whether to use python inference\n-# visulize the predicted image\n+# visualize the predicted image\nmetric: COCO # COCO, VOC\ndraw_threshold: 0.5\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | refine doc (#163) |
499,313 | 07.01.2020 13:08:02 | -28,800 | 779cdeb76fab5025b7e15230c528a761276fae40 | fix use_fine_grained_loss eval in train | [
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/architectures/yolov3.py",
"new_path": "ppdet/modeling/architectures/yolov3.py",
"diff": "@@ -135,7 +135,10 @@ class YOLOv3(object):\nuse_dataloader=True,\niterable=False):\ninputs_def = self._inputs_def(image_shape, num_max_boxes)\n- if self.use_fine_grained_loss:\n+ # if fields has im_size, this is in eval/infer mode, fine grained loss\n+ # will be disabled for YOLOv3 architecture do not calculate loss in\n+ # eval/infer mode.\n+ if 'im_size' not in fields and self.use_fine_grained_loss:\nfields.extend(['target0', 'target1', 'target2'])\nfeed_vars = OrderedDict([(key, fluid.data(\nname=key,\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix use_fine_grained_loss eval in train (#167) |
499,333 | 09.01.2020 14:38:50 | -28,800 | 256c2c9c063d5ae1370ab8aad8f643c0d862962b | fix feed type in cpp_infer.py | [
{
"change_type": "MODIFY",
"old_path": "tools/cpp_infer.py",
"new_path": "tools/cpp_infer.py",
"diff": "@@ -220,7 +220,7 @@ def infer():\nfor i in range(10):\nif conf['use_python_inference']:\nouts = exe.run(infer_prog,\n- feed=[data_dict],\n+ feed=data_dict,\nfetch_list=fetch_targets,\nreturn_numpy=False)\nelse:\n@@ -232,7 +232,7 @@ def infer():\nfor i in range(cnt):\nif conf['use_python_inference']:\nouts = exe.run(infer_prog,\n- feed=[data_dict],\n+ feed=data_dict,\nfetch_list=fetch_targets,\nreturn_numpy=False)\nelse:\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix feed type in cpp_infer.py (#170) |
499,313 | 15.01.2020 13:01:00 | -28,800 | 1e395f8abdcf9c3d13e87de0258583def32c9f8b | disable multiprocess on Windows | [
{
"change_type": "MODIFY",
"old_path": "ppdet/data/parallel_map.py",
"new_path": "ppdet/data/parallel_map.py",
"diff": "@@ -65,6 +65,10 @@ class ParallelMap(object):\nself._worker_num = worker_num\nself._bufsize = bufsize\nself._use_process = use_process\n+ if self._use_process and sys.platform == \"win32\":\n+ logger.info(\"Use multi-thread reader instead of \"\n+ \"multi-process reader on Windows.\")\n+ self._use_process = False\nif self._use_process and type(memsize) is str:\nassert memsize[-1].lower() == 'g', \\\n\"invalid param for memsize[%s], should be ended with 'G' or 'g'\" % (memsize)\n@@ -86,10 +90,6 @@ class ParallelMap(object):\ndef _setup(self):\n\"\"\"setup input/output queues and workers \"\"\"\nuse_process = self._use_process\n- if use_process and sys.platform == \"win32\":\n- logger.info(\"Use multi-thread reader instead of \"\n- \"multi-process reader on Windows.\")\n- use_process = False\nbufsize = self._bufsize\nif use_process:\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | disable multiprocess on Windows (#181) |
499,385 | 20.01.2020 11:25:22 | -28,800 | cf872f91b4c9f94f3f0d3959764db6ee79a0111b | Remove the un-used code | [
{
"change_type": "DELETE",
"old_path": "configs2/faster_rcnn_r50_1x.yml",
"new_path": null,
"diff": "-architecture: FasterRCNN\n-use_gpu: true\n-max_iters: 180000\n-log_smooth_window: 20\n-save_dir: output\n-snapshot_iter: 10000\n-pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar\n-metric: COCO\n-weights: output/faster_rcnn_r50_1x/model_final\n-num_classes: 81\n-\n-FasterRCNN:\n- backbone: ResNet\n- rpn_head: RPNHead\n- roi_extractor: RoIAlign\n- bbox_head: BBoxHead\n- bbox_assigner: BBoxAssigner\n-\n-ResNet:\n- norm_type: affine_channel\n- depth: 50\n- feature_maps: 4\n- freeze_at: 2\n-\n-ResNetC5:\n- depth: 50\n- norm_type: affine_channel\n-\n-RPNHead:\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- rpn_target_assign:\n- rpn_batch_size_per_im: 256\n- rpn_fg_fraction: 0.5\n- rpn_negative_overlap: 0.3\n- rpn_positive_overlap: 0.7\n- rpn_straddle_thresh: 0.0\n- use_random: true\n- train_proposal:\n- min_size: 0.0\n- nms_thresh: 0.7\n- pre_nms_top_n: 12000\n- post_nms_top_n: 2000\n- test_proposal:\n- min_size: 0.0\n- nms_thresh: 0.7\n- pre_nms_top_n: 6000\n- post_nms_top_n: 1000\n-\n-RoIAlign:\n- resolution: 14\n- sampling_ratio: 0\n- spatial_scale: 0.0625\n-\n-BBoxAssigner:\n- batch_size_per_im: 512\n- bbox_reg_weights: [0.1, 0.1, 0.2, 0.2]\n- bg_thresh_hi: 0.5\n- bg_thresh_lo: 0.0\n- fg_fraction: 0.25\n- fg_thresh: 0.5\n-\n-BBoxHead:\n- head: ResNetC5\n- nms:\n- keep_top_k: 100\n- nms_threshold: 0.5\n- score_threshold: 0.05\n-\n-LearningRate:\n- base_lr: 0.01\n- schedulers:\n- - !PiecewiseDecay\n- gamma: 0.1\n- milestones: [120000, 160000]\n- - !LinearWarmup\n- start_factor: 0.3333333333333333\n- steps: 500\n-\n-OptimizerBuilder:\n- optimizer:\n- momentum: 0.9\n- type: Momentum\n- regularizer:\n- factor: 0.0001\n- type: L2\n-\n-_LOADER_: 'faster_reader.yml'\n-TrainLoader:\n- inputs_def:\n- image_shape: [3,800,800]\n- fields: ['image', 'im_info', 'im_id', 'gt_bbox', 'gt_class', 'is_crowd']\n- batch_size: 3\n"
},
{
"change_type": "DELETE",
"old_path": "configs2/faster_reader.yml",
"new_path": null,
"diff": "-TrainReader:\n- inputs_def:\n- image_shape: [3,NULL,NULL]\n- fields: ['image', 'im_info', 'im_id', 'gt_bbox', 'gt_class', 'is_crowd']\n- dataset:\n- !COCODataSet\n- image_dir: val2017\n- anno_path: annotations/instances_val2017.json\n- dataset_dir: dataset/coco\n- sample_transforms:\n- - !DecodeImage\n- to_rgb: true\n- - !RandomFlipImage\n- prob: 0.5\n- - !NormalizeImage\n- is_channel_first: false\n- is_scale: true\n- mean: [0.485,0.456,0.406]\n- std: [0.229, 0.224,0.225]\n- - !ResizeImage\n- target_size: 800\n- max_size: 1333\n- interp: 1\n- use_cv2: true\n- - !Permute\n- to_bgr: false\n- channel_first: true\n- batch_transforms:\n- - !PadBatch\n- pad_to_stride: 32\n- use_padded_im_info: false\n- batch_size: 1\n- shuffle: true\n- worker_num: 2\n- drop_last: false\n- use_multi_process: false\n-\n-EvalReader:\n- inputs_def:\n- image_shape: [3,800,1333]\n- fields: ['image', 'im_info', 'im_id', 'im_shape']\n- # for voc\n- #fields: ['image', 'im_info', 'im_id', 'gt_bbox', 'gt_class', 'is_difficult']\n- dataset:\n- !COCODataSet\n- image_dir: val2017\n- anno_path: annotations/instances_val2017.json\n- dataset_dir: dataset/coco\n- #sample_num: 100\n- sample_transforms:\n- - !DecodeImage\n- to_rgb: true\n- with_mixup: false\n- - !NormalizeImage\n- is_channel_first: false\n- is_scale: true\n- mean: [0.485,0.456,0.406]\n- std: [0.229, 0.224,0.225]\n- - !ResizeImage\n- interp: 1\n- max_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: true\n- batch_size: 1\n- shuffle: false\n- drop_last: false\n-# worker_num: 2\n-\n-TestReader:\n- inputs_def:\n- image_shape: [3,800,1333]\n- fields: ['image', 'im_info', '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- with_mixup: false\n- - !NormalizeImage\n- is_channel_first: false\n- is_scale: true\n- mean: [0.485,0.456,0.406]\n- std: [0.229, 0.224,0.225]\n- - !ResizeImage\n- interp: 1\n- max_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: true\n- batch_size: 1\n- shuffle: false\n- drop_last: false\n"
},
{
"change_type": "DELETE",
"old_path": "slim/eval.py",
"new_path": null,
"diff": "-# Copyright (c) 2019 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 time\n-import multiprocessing\n-import numpy as np\n-import datetime\n-from collections import deque\n-import sys\n-sys.path.append(\"../../\")\n-from paddle.fluid.contrib.slim import Compressor\n-from paddle.fluid.framework import IrGraph\n-from paddle.fluid import core\n-from paddle.fluid.contrib.slim.quantization import QuantizationTransformPass\n-from paddle.fluid.contrib.slim.quantization import QuantizationFreezePass\n-from paddle.fluid.contrib.slim.quantization import ConvertToInt8Pass\n-from paddle.fluid.contrib.slim.quantization import TransformForMobilePass\n-\n-\n-def set_paddle_flags(**kwargs):\n- for key, value in kwargs.items():\n- if os.environ.get(key, None) is None:\n- os.environ[key] = str(value)\n-\n-\n-# NOTE(paddle-dev): All of these flags should be set before\n-# `import paddle`. Otherwise, it would not take any effect.\n-set_paddle_flags(\n- FLAGS_eager_delete_tensor_gb=0, # enable GC to save memory\n-)\n-\n-from paddle import fluid\n-\n-from ppdet.core.workspace import load_config, merge_config, create\n-from ppdet.data.data_feed import create_reader\n-\n-from ppdet.utils.eval_utils import parse_fetches, eval_results\n-from ppdet.utils.stats import TrainingStats\n-from ppdet.utils.cli import ArgsParser\n-from ppdet.utils.check import check_gpu\n-import ppdet.utils.checkpoint as checkpoint\n-from ppdet.modeling.model_input import create_feed\n-\n-import logging\n-FORMAT = '%(asctime)s-%(levelname)s: %(message)s'\n-logging.basicConfig(level=logging.INFO, format=FORMAT)\n-logger = logging.getLogger(__name__)\n-\n-\n-def eval_run(exe, compile_program, reader, keys, values, cls, test_feed):\n- \"\"\"\n- Run evaluation program, return program outputs.\n- \"\"\"\n- iter_id = 0\n- results = []\n-\n- images_num = 0\n- start_time = time.time()\n- has_bbox = 'bbox' in keys\n- for data in reader():\n- data = test_feed.feed(data)\n- feed_data = {'image': data['image'], 'im_size': data['im_size']}\n- outs = exe.run(compile_program,\n- feed=feed_data,\n- fetch_list=values[0],\n- return_numpy=False)\n- outs.append(data['gt_box'])\n- outs.append(data['gt_label'])\n- outs.append(data['is_difficult'])\n- res = {\n- k: (np.array(v), v.recursive_sequence_lengths())\n- for k, v in zip(keys, outs)\n- }\n- results.append(res)\n- if iter_id % 100 == 0:\n- logger.info('Test iter {}'.format(iter_id))\n- iter_id += 1\n- images_num += len(res['bbox'][1][0]) if has_bbox else 1\n- logger.info('Test finish iter {}'.format(iter_id))\n-\n- end_time = time.time()\n- fps = images_num / (end_time - start_time)\n- if has_bbox:\n- logger.info('Total number of images: {}, inference time: {} fps.'.\n- format(images_num, fps))\n- else:\n- logger.info('Total iteration: {}, inference time: {} batch/s.'.format(\n- images_num, fps))\n-\n- return results\n-\n-\n-def main():\n- cfg = load_config(FLAGS.config)\n- if 'architecture' in cfg:\n- main_arch = cfg.architecture\n- else:\n- raise ValueError(\"'architecture' not specified in config file.\")\n-\n- merge_config(FLAGS.opt)\n- if 'log_iter' not in cfg:\n- cfg.log_iter = 20\n-\n- # check if set use_gpu=True in paddlepaddle cpu version\n- check_gpu(cfg.use_gpu)\n-\n- if cfg.use_gpu:\n- devices_num = fluid.core.get_cuda_device_count()\n- else:\n- devices_num = int(\n- os.environ.get('CPU_NUM', multiprocessing.cpu_count()))\n-\n- if 'eval_feed' not in cfg:\n- eval_feed = create(main_arch + 'EvalFeed')\n- else:\n- eval_feed = create(cfg.eval_feed)\n-\n- place = fluid.CUDAPlace(0) if cfg.use_gpu else fluid.CPUPlace()\n- exe = fluid.Executor(place)\n-\n- _, test_feed_vars = create_feed(eval_feed, False)\n-\n- eval_reader = create_reader(eval_feed, args_path=FLAGS.dataset_dir)\n- #eval_pyreader.decorate_sample_list_generator(eval_reader, place)\n- test_data_feed = fluid.DataFeeder(test_feed_vars.values(), place)\n-\n- assert os.path.exists(FLAGS.model_path)\n- infer_prog, feed_names, fetch_targets = fluid.io.load_inference_model(\n- dirname=FLAGS.model_path,\n- executor=exe,\n- model_filename=FLAGS.model_name,\n- params_filename=FLAGS.params_name)\n-\n- eval_keys = ['bbox', 'gt_box', 'gt_label', 'is_difficult']\n- eval_values = [\n- 'multiclass_nms_0.tmp_0', 'gt_box', 'gt_label', 'is_difficult'\n- ]\n- eval_cls = []\n- eval_values[0] = fetch_targets[0]\n-\n- results = eval_run(exe, infer_prog, eval_reader, eval_keys, eval_values,\n- eval_cls, test_data_feed)\n-\n- resolution = None\n- if 'mask' in results[0]:\n- resolution = model.mask_head.resolution\n- eval_results(results, eval_feed, cfg.metric, cfg.num_classes, resolution,\n- False, FLAGS.output_eval)\n-\n-\n-if __name__ == '__main__':\n- parser = ArgsParser()\n- parser.add_argument(\n- \"-m\", \"--model_path\", default=None, type=str, help=\"path of checkpoint\")\n- parser.add_argument(\n- \"--output_eval\",\n- default=None,\n- type=str,\n- help=\"Evaluation directory, default is current directory.\")\n- parser.add_argument(\n- \"-d\",\n- \"--dataset_dir\",\n- default=None,\n- type=str,\n- help=\"Dataset path, same as DataFeed.dataset.dataset_dir\")\n- parser.add_argument(\n- \"--model_name\",\n- default='model',\n- type=str,\n- help=\"model file name to load_inference_model\")\n- parser.add_argument(\n- \"--params_name\",\n- default='params',\n- type=str,\n- help=\"params file name to load_inference_model\")\n-\n- FLAGS = parser.parse_args()\n- main()\n"
},
{
"change_type": "DELETE",
"old_path": "slim/infer.py",
"new_path": null,
"diff": "-# Copyright (c) 2019 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 sys\n-import glob\n-import time\n-\n-import numpy as np\n-from PIL import Image\n-sys.path.append(\"../../\")\n-\n-\n-def set_paddle_flags(**kwargs):\n- for key, value in kwargs.items():\n- if os.environ.get(key, None) is None:\n- os.environ[key] = str(value)\n-\n-\n-# NOTE(paddle-dev): All of these flags should be set before\n-# `import paddle`. Otherwise, it would not take any effect.\n-set_paddle_flags(\n- FLAGS_eager_delete_tensor_gb=0, # enable GC to save memory\n-)\n-\n-from paddle import fluid\n-from ppdet.utils.cli import print_total_cfg\n-from ppdet.core.workspace import load_config, merge_config, create\n-from ppdet.modeling.model_input import create_feed\n-from ppdet.data.data_feed import create_reader\n-\n-from ppdet.utils.eval_utils import parse_fetches\n-from ppdet.utils.cli import ArgsParser\n-from ppdet.utils.check import check_gpu\n-from ppdet.utils.visualizer import visualize_results\n-import ppdet.utils.checkpoint as checkpoint\n-\n-import logging\n-FORMAT = '%(asctime)s-%(levelname)s: %(message)s'\n-logging.basicConfig(level=logging.INFO, format=FORMAT)\n-logger = logging.getLogger(__name__)\n-\n-\n-def get_save_image_name(output_dir, image_path):\n- \"\"\"\n- Get save image name from source image path.\n- \"\"\"\n- if not os.path.exists(output_dir):\n- os.makedirs(output_dir)\n- image_name = os.path.split(image_path)[-1]\n- name, ext = os.path.splitext(image_name)\n- return os.path.join(output_dir, \"{}\".format(name)) + ext\n-\n-\n-def get_test_images(infer_dir, infer_img):\n- \"\"\"\n- Get image path list in TEST mode\n- \"\"\"\n- assert infer_img is not None or infer_dir is not None, \\\n- \"--infer_img or --infer_dir should be set\"\n- assert infer_img is None or os.path.isfile(infer_img), \\\n- \"{} is not a file\".format(infer_img)\n- assert infer_dir is None or os.path.isdir(infer_dir), \\\n- \"{} is not a directory\".format(infer_dir)\n- images = []\n-\n- # infer_img has a higher priority\n- if infer_img and os.path.isfile(infer_img):\n- images.append(infer_img)\n- return images\n-\n- infer_dir = os.path.abspath(infer_dir)\n- assert os.path.isdir(infer_dir), \\\n- \"infer_dir {} is not a directory\".format(infer_dir)\n- exts = ['jpg', 'jpeg', 'png', 'bmp']\n- exts += [ext.upper() for ext in exts]\n- for ext in exts:\n- images.extend(glob.glob('{}/*.{}'.format(infer_dir, ext)))\n-\n- assert len(images) > 0, \"no image found in {}\".format(infer_dir)\n- logger.info(\"Found {} inference images in total.\".format(len(images)))\n-\n- return images\n-\n-\n-def main():\n- cfg = load_config(FLAGS.config)\n-\n- if 'architecture' in cfg:\n- main_arch = cfg.architecture\n- else:\n- raise ValueError(\"'architecture' not specified in config file.\")\n-\n- merge_config(FLAGS.opt)\n-\n- # check if set use_gpu=True in paddlepaddle cpu version\n- check_gpu(cfg.use_gpu)\n- # print_total_cfg(cfg)\n-\n- if 'test_feed' not in cfg:\n- test_feed = create(main_arch + 'TestFeed')\n- else:\n- test_feed = create(cfg.test_feed)\n-\n- test_images = get_test_images(FLAGS.infer_dir, FLAGS.infer_img)\n- test_feed.dataset.add_images(test_images)\n-\n- place = fluid.CUDAPlace(0) if cfg.use_gpu else fluid.CPUPlace()\n- exe = fluid.Executor(place)\n-\n- infer_prog, feed_var_names, fetch_list = fluid.io.load_inference_model(\n- dirname=FLAGS.model_path,\n- model_filename=FLAGS.model_name,\n- params_filename=FLAGS.params_name,\n- executor=exe)\n-\n- reader = create_reader(test_feed)\n- feeder = fluid.DataFeeder(\n- place=place, feed_list=feed_var_names, program=infer_prog)\n-\n- # parse infer fetches\n- assert cfg.metric in ['COCO', 'VOC'], \\\n- \"unknown metric type {}\".format(cfg.metric)\n- extra_keys = []\n- if cfg['metric'] == 'COCO':\n- extra_keys = ['im_info', 'im_id', 'im_shape']\n- if cfg['metric'] == 'VOC':\n- extra_keys = ['im_id', 'im_shape']\n- keys, values, _ = parse_fetches({\n- 'bbox': fetch_list\n- }, infer_prog, extra_keys)\n-\n- # parse dataset category\n- if cfg.metric == 'COCO':\n- from ppdet.utils.coco_eval import bbox2out, mask2out, get_category_info\n- if cfg.metric == \"VOC\":\n- from ppdet.utils.voc_eval import bbox2out, get_category_info\n-\n- anno_file = getattr(test_feed.dataset, 'annotation', None)\n- with_background = getattr(test_feed, 'with_background', True)\n- use_default_label = getattr(test_feed, 'use_default_label', False)\n- clsid2catid, catid2name = get_category_info(anno_file, with_background,\n- use_default_label)\n-\n- # whether output bbox is normalized in model output layer\n- is_bbox_normalized = False\n-\n- # use tb-paddle to log image\n- if FLAGS.use_tb:\n- from tb_paddle import SummaryWriter\n- tb_writer = SummaryWriter(FLAGS.tb_log_dir)\n- tb_image_step = 0\n- tb_image_frame = 0 # each frame can display ten pictures at most.\n-\n- imid2path = reader.imid2path\n- keys = ['bbox']\n- infer_time = True\n- compile_prog = fluid.compiler.CompiledProgram(infer_prog)\n-\n- for iter_id, data in enumerate(reader()):\n- feed_data = [[d[0], d[1]] for d in data]\n- # for infer time\n- if infer_time:\n- warmup_times = 10\n- repeats_time = 100\n- feed_data_dict = feeder.feed(feed_data)\n- for i in range(warmup_times):\n- exe.run(compile_prog,\n- feed=feed_data_dict,\n- fetch_list=fetch_list,\n- return_numpy=False)\n- start_time = time.time()\n- for i in range(repeats_time):\n- exe.run(compile_prog,\n- feed=feed_data_dict,\n- fetch_list=fetch_list,\n- return_numpy=False)\n-\n- print(\"infer time: {} ms/sample\".format((time.time() - start_time) *\n- 1000 / repeats_time))\n- infer_time = False\n-\n- outs = exe.run(compile_prog,\n- feed=feeder.feed(feed_data),\n- fetch_list=fetch_list,\n- return_numpy=False)\n- res = {\n- k: (np.array(v), v.recursive_sequence_lengths())\n- for k, v in zip(keys, outs)\n- }\n- res['im_id'] = [[d[2] for d in data]]\n- logger.info('Infer iter {}'.format(iter_id))\n-\n- bbox_results = None\n- mask_results = None\n- if 'bbox' in res:\n- bbox_results = bbox2out([res], clsid2catid, is_bbox_normalized)\n- if 'mask' in res:\n- mask_results = mask2out([res], clsid2catid,\n- model.mask_head.resolution)\n-\n- # visualize result\n- im_ids = res['im_id'][0]\n- for im_id in im_ids:\n- image_path = imid2path[int(im_id)]\n- image = Image.open(image_path).convert('RGB')\n-\n- # use tb-paddle to log original image\n- if FLAGS.use_tb:\n- original_image_np = np.array(image)\n- tb_writer.add_image(\n- \"original/frame_{}\".format(tb_image_frame),\n- original_image_np,\n- tb_image_step,\n- dataformats='HWC')\n-\n- image = visualize_results(image,\n- int(im_id), catid2name,\n- FLAGS.draw_threshold, bbox_results,\n- mask_results)\n-\n- # use tb-paddle to log image with bbox\n- if FLAGS.use_tb:\n- infer_image_np = np.array(image)\n- tb_writer.add_image(\n- \"bbox/frame_{}\".format(tb_image_frame),\n- infer_image_np,\n- tb_image_step,\n- dataformats='HWC')\n- tb_image_step += 1\n- if tb_image_step % 10 == 0:\n- tb_image_step = 0\n- tb_image_frame += 1\n-\n- save_name = get_save_image_name(FLAGS.output_dir, image_path)\n- logger.info(\"Detection bbox results save in {}\".format(save_name))\n- image.save(save_name, quality=95)\n-\n-\n-if __name__ == '__main__':\n- parser = ArgsParser()\n- parser.add_argument(\n- \"--infer_dir\",\n- type=str,\n- default=None,\n- help=\"Directory for images to perform inference on.\")\n- parser.add_argument(\n- \"--infer_img\",\n- type=str,\n- default=None,\n- help=\"Image path, has higher priority over --infer_dir\")\n- parser.add_argument(\n- \"--output_dir\",\n- type=str,\n- default=\"output\",\n- help=\"Directory for storing the output visualization files.\")\n- parser.add_argument(\n- \"--draw_threshold\",\n- type=float,\n- default=0.5,\n- help=\"Threshold to reserve the result for visualization.\")\n- parser.add_argument(\n- \"--use_tb\",\n- type=bool,\n- default=False,\n- help=\"whether to record the data to Tensorboard.\")\n- parser.add_argument(\n- '--tb_log_dir',\n- type=str,\n- default=\"tb_log_dir/image\",\n- help='Tensorboard logging directory for image.')\n- parser.add_argument(\n- '--model_path', type=str, default=None, help=\"inference model path\")\n- parser.add_argument(\n- '--model_name',\n- type=str,\n- default='__model__.infer',\n- help=\"model filename for inference model\")\n- parser.add_argument(\n- '--params_name',\n- type=str,\n- default='__params__',\n- help=\"params filename for inference model\")\n- FLAGS = parser.parse_args()\n- main()\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Remove the un-used code (#194) |
499,313 | 06.02.2020 17:37:17 | -28,800 | fcfdbd2e191a9e16953b10e88ce0b87e4df4aaef | fix test_architectures.py | [
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/tests/test_architectures.py",
"new_path": "ppdet/modeling/tests/test_architectures.py",
"diff": "@@ -23,7 +23,6 @@ import paddle.fluid as fluid\nfrom ppdet.modeling.tests.decorator_helper import prog_scope\nfrom ppdet.core.workspace import load_config, merge_config, create\n-from ppdet.modeling.model_input import create_feed\nclass TestFasterRCNN(unittest.TestCase):\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix test_architectures.py (#213) |
499,385 | 10.02.2020 11:49:39 | -28,800 | 4d096b4f06b8825812af892b09bb1cea2cd632c3 | Remove is_difficult field in SSD config for COCO dataset | [
{
"change_type": "MODIFY",
"old_path": "configs/ssd/ssd_vgg16_300.yml",
"new_path": "configs/ssd/ssd_vgg16_300.yml",
"diff": "@@ -100,7 +100,7 @@ TrainReader:\nEvalReader:\ninputs_def:\nimage_shape: [3, 300, 300]\n- fields: ['image', 'gt_bbox', 'gt_class', 'im_shape', 'im_id', 'is_difficult']\n+ fields: ['image', 'gt_bbox', 'gt_class', 'im_shape', 'im_id']\ndataset:\n!COCODataSet\nimage_dir: val2017\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/ssd/ssd_vgg16_512.yml",
"new_path": "configs/ssd/ssd_vgg16_512.yml",
"diff": "@@ -102,7 +102,7 @@ TrainReader:\nEvalReader:\ninputs_def:\nimage_shape: [3,512,512]\n- fields: ['image', 'gt_bbox', 'gt_class', 'im_shape', 'im_id', 'is_difficult']\n+ fields: ['image', 'gt_bbox', 'gt_class', 'im_shape', 'im_id']\ndataset:\n!COCODataSet\nimage_dir: val2017\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Remove is_difficult field in SSD config for COCO dataset (#221) |
499,385 | 10.02.2020 18:02:45 | -28,800 | 8dae8b5e6189b83210f601851ace3fb8c94859fb | Change min_subgraph_size to 40 in tools/cpp_demo.yml | [
{
"change_type": "MODIFY",
"old_path": "tools/cpp_demo.yml",
"new_path": "tools/cpp_demo.yml",
"diff": "mode: trt_fp32 # trt_fp32, trt_fp16, trt_int8, fluid\narch: RCNN # YOLO, SSD, RCNN, RetinaNet\n-min_subgraph_size: 20 # need 3 for YOLO arch\n+min_subgraph_size: 40 # need 3 for YOLO arch\nuse_python_inference: False # whether to use python inference\n# visualize the predicted image\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Change min_subgraph_size to 40 in tools/cpp_demo.yml (#222) |
499,313 | 11.02.2020 17:07:00 | -28,800 | 211aaf02d53f9dee21e70ebf001525f002ebf517 | fix prune resume | [
{
"change_type": "MODIFY",
"old_path": "slim/prune/prune.py",
"new_path": "slim/prune/prune.py",
"diff": "@@ -171,10 +171,7 @@ def main():\nfuse_bn = getattr(model.backbone, 'norm_type', None) == 'affine_channel'\nstart_iter = 0\n- if FLAGS.resume_checkpoint:\n- checkpoint.load_checkpoint(exe, train_prog, FLAGS.resume_checkpoint)\n- start_iter = checkpoint.global_step()\n- elif cfg.pretrain_weights:\n+ if cfg.pretrain_weights:\ncheckpoint.load_params(exe, train_prog, cfg.pretrain_weights)\npruned_params = FLAGS.pruned_params\n@@ -220,6 +217,10 @@ def main():\npruned_flops))\ncompiled_eval_prog = fluid.compiler.CompiledProgram(eval_prog)\n+ if FLAGS.resume_checkpoint:\n+ checkpoint.load_checkpoint(exe, train_prog, FLAGS.resume_checkpoint)\n+ start_iter = checkpoint.global_step()\n+\ntrain_reader = create_reader(cfg.TrainReader, (cfg.max_iters - start_iter) *\ndevices_num, cfg)\ntrain_loader.set_sample_list_generator(train_reader, place)\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix prune resume (#223) |
499,385 | 11.02.2020 22:52:30 | -28,800 | 34250821cea03b5261436d109224767cdaf4cba2 | Fix class_num in cascade_rcnn_dcnv2_se154_vd_fpn_gn_cas.yml | [
{
"change_type": "MODIFY",
"old_path": "configs/obj365/cascade_rcnn_dcnv2_se154_vd_fpn_gn_cas.yml",
"new_path": "configs/obj365/cascade_rcnn_dcnv2_se154_vd_fpn_gn_cas.yml",
"diff": "@@ -8,7 +8,7 @@ save_dir: output\npretrain_weights: https://paddlemodels.bj.bcebos.com/object_detection/cascade_mask_rcnn_dcnv2_se154_vd_fpn_gn_coco_pretrained.tar\nweights: output/cascade_rcnn_dcnv2_se154_vd_fpn_gn_cas/model_final\nmetric: COCO\n-num_classes: 501\n+num_classes: 366\nCascadeRCNN:\nbackbone: SENet\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Fix class_num in cascade_rcnn_dcnv2_se154_vd_fpn_gn_cas.yml (#224) |
499,333 | 13.02.2020 15:17:11 | -28,800 | 59b704957426a2e87148c64d0bbef7154224afae | fix cpp_infer in SSD | [
{
"change_type": "MODIFY",
"old_path": "tools/cpp_infer.py",
"new_path": "tools/cpp_infer.py",
"diff": "@@ -78,7 +78,9 @@ def get_extra_info(im, arch, shape, scale):\nlogger.info('Extra info: im_size')\ninfo.append(im_size)\nelif 'SSD' in arch:\n- pass\n+ im_shape = np.array([shape[:2]]).astype('int32')\n+ logger.info('Extra info: im_shape')\n+ info.append([im_shape])\nelif 'RetinaNet' in arch:\ninput_shape.extend(im.shape[2:])\nim_info = np.array([input_shape + [scale]]).astype('float32')\n@@ -190,6 +192,7 @@ def Preprocess(img_path, arch, config):\ndef infer():\nmodel_path = FLAGS.model_path\nconfig_path = FLAGS.config_path\n+ res = {}\nassert model_path is not None, \"Model path: {} does not exist!\".format(\nmodel_path)\nassert config_path is not None, \"Config path: {} does not exist!\".format(\n@@ -198,6 +201,9 @@ def infer():\nconf = yaml.safe_load(f)\nimg_data = Preprocess(FLAGS.infer_img, conf['arch'], conf['Preprocess'])\n+ if 'SSD' in conf['arch']:\n+ img_data, res['im_shape'] = img_data\n+ img_data = [img_data]\nif conf['use_python_inference']:\nplace = fluid.CUDAPlace(0)\n@@ -253,7 +259,6 @@ def infer():\nis_bbox_normalized = True if 'SSD' in conf['arch'] else False\nout = outs[-1]\n- res = {}\nlod = out.lod() if conf['use_python_inference'] else out.lod\nlengths = offset_to_lengths(lod)\nnp_data = np.array(out) if conf[\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix cpp_infer in SSD (#231) |
499,300 | 13.02.2020 15:23:08 | -28,800 | 2835d5ad5649bcfbbaf5269ea60d02613de4c51a | Upgrade paddle API used in mixed precision training | [
{
"change_type": "MODIFY",
"old_path": "ppdet/experimental/mixed_precision.py",
"new_path": "ppdet/experimental/mixed_precision.py",
"diff": "@@ -129,30 +129,27 @@ class DynamicLossScale(LossScale):\ndef increment(self):\nenough_steps = layers.less_than(self.increment_every,\nself.good_steps + 1)\n- with layers.Switch() as switch:\n- with switch.case(enough_steps):\n+\n+ def increment_step():\n+ layers.increment(self.good_steps)\n+\n+ def maybe_update():\nnew_scale = self.scale * self.factor\nscale_valid = layers.isfinite(new_scale)\n- with layers.Switch() as switch2:\n- with switch2.case(scale_valid):\n+\n+ def update_scale_and_step():\nlayers.assign(new_scale, self.scale)\nlayers.assign(\nlayers.zeros_like(self.good_steps), self.good_steps)\n- with switch2.default():\n- layers.increment(self.good_steps)\n- with switch.default():\n- layers.increment(self.good_steps)\n+\n+ layers.cond(scale_valid, update_scale_and_step)\n+\n+ layers.cond(enough_steps, maybe_update, increment_step)\ndef decrement(self):\nnew_scale = self.scale / self.factor\none = layers.fill_constant(shape=[1], dtype='float32', value=1.0)\n- less_than_one = layers.less_than(new_scale, one)\n- with layers.Switch() as switch:\n- with switch.case(less_than_one):\n- layers.assign(one, self.scale)\n- with switch.default():\n- layers.assign(new_scale, self.scale)\n-\n+ layers.assign(layers.elementwise_max(new_scale, one), self.scale)\nlayers.assign(layers.zeros_like(self.good_steps), self.good_steps)\n@@ -275,12 +272,13 @@ def scale_gradient(block, context):\nfwd_var = block._var_recursive(context[name])\nif not isinstance(fwd_var, Parameter):\ncontinue # TODO verify all use cases\n- clip_op_desc = block.desc.append_op()\n- clip_op_desc.set_type(\"elementwise_div\")\n- clip_op_desc.set_input(\"X\", [name])\n- clip_op_desc.set_input(\"Y\", [scale.name])\n- clip_op_desc.set_output(\"Out\", [name])\n- clip_op_desc._set_attr(op_role_attr_name, bwd_role)\n+ scale_op_desc = block.desc.append_op()\n+ scale_op_desc.set_type(\"elementwise_div\")\n+ scale_op_desc.set_input(\"X\", [name])\n+ scale_op_desc.set_input(\"Y\", [scale.name])\n+ scale_op_desc.set_output(\"Out\", [name])\n+ scale_op_desc._set_attr(\"axis\", -1)\n+ scale_op_desc._set_attr(op_role_attr_name, bwd_role)\ndef update_loss_scale(grads):\n@@ -289,12 +287,8 @@ def update_loss_scale(grads):\nreturn\nper_grad_check = layers.stack([layers.reduce_sum(g) for g in grads])\ngrad_valid = layers.isfinite(per_grad_check)\n-\n- with layers.Switch() as switch:\n- with switch.case(grad_valid):\n- state.increment()\n- with switch.default():\n- state.decrement()\n+ layers.cond(grad_valid, lambda: state.increment(),\n+ lambda: state.decrement())\nreturn grad_valid\n@@ -309,15 +303,15 @@ def backward(self, loss, **kwargs):\nelse:\nkwargs['callbacks'] = callbacks\nparam_grads = self._backward(loss, **kwargs)\n+\n+ def zero_grad():\n+ for _, g in param_grads:\n+ layers.assign(layers.zeros_like(g), g)\n+\nif state is not None:\ngrad_valid = update_loss_scale(v for k, v in param_grads)\nif state.dynamic_scaling:\n- with layers.Switch() as switch:\n- with switch.case(grad_valid):\n- pass\n- with switch.default():\n- for _, g in param_grads:\n- layers.assign(layers.zeros_like(g), g)\n+ layers.cond(grad_valid, None, zero_grad)\nreturn param_grads\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Upgrade paddle API used in mixed precision training (#227) |
499,300 | 13.02.2020 15:23:37 | -28,800 | 1a30667dec205696e0b04d2614710e63faaaef67 | Clean up pyreader vestiges | [
{
"change_type": "MODIFY",
"old_path": "demo/mask_rcnn_demo.ipynb",
"new_path": "demo/mask_rcnn_demo.ipynb",
"diff": "\"with fluid.program_guard(infer_prog, startup_prog):\\n\",\n\" with fluid.unique_name.guard():\\n\",\n\" feed_vars = {\\n\",\n- \" var['name']: fluid.layers.data(\\n\",\n+ \" var['name']: fluid.data(\\n\",\n\" name=var['name'],\\n\",\n\" shape=var['shape'],\\n\",\n\" dtype='float32',\\n\",\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/architectures/cascade_mask_rcnn.py",
"new_path": "ppdet/modeling/architectures/cascade_mask_rcnn.py",
"diff": "@@ -411,7 +411,7 @@ class CascadeMaskRCNN(object):\n'lod_level': 1\n}\nfields += box_fields\n- feed_vars = OrderedDict([(key, fluid.layers.data(\n+ feed_vars = OrderedDict([(key, fluid.data(\nname=key,\nshape=inputs_def[key]['shape'],\ndtype=inputs_def[key]['dtype'],\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/architectures/cascade_rcnn.py",
"new_path": "ppdet/modeling/architectures/cascade_rcnn.py",
"diff": "@@ -312,7 +312,7 @@ class CascadeRCNN(object):\nfields += ms_fields\nself.im_info_names = ['image', 'im_info'] + ms_fields\n- feed_vars = OrderedDict([(key, fluid.layers.data(\n+ feed_vars = OrderedDict([(key, fluid.data(\nname=key,\nshape=inputs_def[key]['shape'],\ndtype=inputs_def[key]['dtype'],\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": "@@ -195,7 +195,7 @@ class CascadeRCNNClsAware(object):\nuse_dataloader=True,\niterable=False):\ninputs_def = self._inputs_def(image_shape)\n- feed_vars = OrderedDict([(key, fluid.layers.data(\n+ feed_vars = OrderedDict([(key, fluid.data(\nname=key,\nshape=inputs_def[key]['shape'],\ndtype=inputs_def[key]['dtype'],\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/architectures/faster_rcnn.py",
"new_path": "ppdet/modeling/architectures/faster_rcnn.py",
"diff": "@@ -224,7 +224,7 @@ class FasterRCNN(object):\nfields += ms_fields\nself.im_info_names = ['image', 'im_info'] + ms_fields\n- feed_vars = OrderedDict([(key, fluid.layers.data(\n+ feed_vars = OrderedDict([(key, fluid.data(\nname=key,\nshape=inputs_def[key]['shape'],\ndtype=inputs_def[key]['dtype'],\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/architectures/mask_rcnn.py",
"new_path": "ppdet/modeling/architectures/mask_rcnn.py",
"diff": "@@ -314,7 +314,7 @@ class MaskRCNN(object):\n'lod_level': 1\n}\nfields += box_fields\n- feed_vars = OrderedDict([(key, fluid.layers.data(\n+ feed_vars = OrderedDict([(key, fluid.data(\nname=key,\nshape=inputs_def[key]['shape'],\ndtype=inputs_def[key]['dtype'],\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/architectures/retinanet.py",
"new_path": "ppdet/modeling/architectures/retinanet.py",
"diff": "@@ -107,7 +107,7 @@ class RetinaNet(object):\nuse_dataloader=True,\niterable=False):\ninputs_def = self._inputs_def(image_shape)\n- feed_vars = OrderedDict([(key, fluid.layers.data(\n+ feed_vars = OrderedDict([(key, fluid.data(\nname=key,\nshape=inputs_def[key]['shape'],\ndtype=inputs_def[key]['dtype'],\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Clean up pyreader vestiges (#228) |
499,306 | 13.02.2020 17:02:05 | -28,800 | b70a0f9b2b21aa121f15cd731f49f49d9aa80ef0 | fix slim distillation load params | [
{
"change_type": "MODIFY",
"old_path": "slim/distillation/distill.py",
"new_path": "slim/distillation/distill.py",
"diff": "@@ -156,26 +156,7 @@ def main():\ntrain_fetches = model.train(train_feed_vars)\nloss = train_fetches['loss']\n- fuse_bn = getattr(model.backbone, 'norm_type', None) == 'affine_channel'\n- ignore_params = cfg.finetune_exclude_pretrained_params \\\n- if 'finetune_exclude_pretrained_params' in cfg else []\nstart_iter = 0\n- if FLAGS.resume_checkpoint:\n- checkpoint.load_checkpoint(exe,\n- fluid.default_main_program(),\n- FLAGS.resume_checkpoint)\n- start_iter = checkpoint.global_step()\n- elif cfg.pretrain_weights and fuse_bn and not ignore_params:\n- checkpoint.load_and_fusebn(exe,\n- fluid.default_main_program(),\n- cfg.pretrain_weights)\n- elif cfg.pretrain_weights:\n- checkpoint.load_params(\n- exe,\n- fluid.default_main_program(),\n- cfg.pretrain_weights,\n- ignore_params=ignore_params)\n-\ntrain_reader = create_reader(cfg.TrainReader, (cfg.max_iters - start_iter) *\ndevices_num, cfg)\ntrain_loader.set_sample_list_generator(train_reader, place)\n@@ -283,11 +264,28 @@ def main():\nopt.minimize(loss)\nexe.run(fluid.default_startup_program())\n+ fuse_bn = getattr(model.backbone, 'norm_type', None) == 'affine_channel'\n+ ignore_params = cfg.finetune_exclude_pretrained_params \\\n+ if 'finetune_exclude_pretrained_params' in cfg else []\n+ if FLAGS.resume_checkpoint:\n+ checkpoint.load_checkpoint(exe,\n+ fluid.default_main_program(),\n+ FLAGS.resume_checkpoint)\n+ start_iter = checkpoint.global_step()\n+ elif cfg.pretrain_weights and fuse_bn and not ignore_params:\n+ checkpoint.load_and_fusebn(exe,\n+ fluid.default_main_program(),\n+ cfg.pretrain_weights)\n+ elif cfg.pretrain_weights:\n+ checkpoint.load_params(\n+ exe,\n+ fluid.default_main_program(),\n+ cfg.pretrain_weights,\n+ ignore_params=ignore_params)\nbuild_strategy = fluid.BuildStrategy()\nbuild_strategy.fuse_all_reduce_ops = False\nbuild_strategy.fuse_all_optimizer_ops = False\n- build_strategy.fuse_elewise_add_act_ops = True\n# only enable sync_bn in multi GPU devices\nsync_bn = getattr(model.backbone, 'norm_type', None) == 'sync_bn'\nbuild_strategy.sync_batch_norm = sync_bn and devices_num > 1 \\\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix slim distillation load params (#233) |
499,333 | 13.02.2020 20:54:51 | -28,800 | 2ae28aaf7fd1fec5f99d7ec07c36a6df6aa3d12b | refine resize in YOLO & SSD | [
{
"change_type": "MODIFY",
"old_path": "tools/cpp_infer.py",
"new_path": "tools/cpp_infer.py",
"diff": "@@ -108,10 +108,11 @@ class Resize(object):\nself.max_size = max_size\nself.interp = interp\n- def __call__(self, im):\n+ def __call__(self, im, arch):\norigin_shape = im.shape[:2]\nim_c = im.shape[2]\n- if self.max_size != 0:\n+ scale_set = {'RCNN', 'RetinaNet'}\n+ if self.max_size != 0 and arch in 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@@ -132,7 +133,7 @@ class Resize(object):\nfy=im_scale_y,\ninterpolation=self.interp)\n# padding im\n- if self.max_size != 0:\n+ if self.max_size != 0 and arch in scale_set:\npadding_im = np.zeros(\n(self.max_size, self.max_size, im_c), dtype=np.float32)\nim_h, im_w = im.shape[:2]\n@@ -178,7 +179,7 @@ def Preprocess(img_path, arch, config):\nobj = data_aug_conf.pop('type')\npreprocess = eval(obj)(**data_aug_conf)\nif obj == 'Resize':\n- img, scale = preprocess(img)\n+ img, scale = preprocess(img, arch)\nelse:\nimg = preprocess(img)\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | refine resize in YOLO & SSD (#234) |
499,400 | 13.02.2020 21:15:08 | -28,800 | f92927ef63ea0813aba780181bd5d2d782f64669 | Remove unused file from pruning demo. | [
{
"change_type": "DELETE",
"old_path": "slim/prune/compress.py",
"new_path": null,
"diff": "-# Copyright (c) 2019 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 time\n-import multiprocessing\n-import numpy as np\n-import sys\n-sys.path.append(\"../../\")\n-from paddle.fluid.contrib.slim import Compressor\n-\n-\n-def set_paddle_flags(**kwargs):\n- for key, value in kwargs.items():\n- if os.environ.get(key, None) is None:\n- os.environ[key] = str(value)\n-\n-\n-# NOTE(paddle-dev): All of these flags should be set before\n-# `import paddle`. Otherwise, it would not take any effect.\n-set_paddle_flags(\n- FLAGS_eager_delete_tensor_gb=0, # enable GC to save memory\n-)\n-\n-from paddle import fluid\n-from ppdet.core.workspace import load_config, merge_config, create\n-from ppdet.data.data_feed import create_reader\n-from ppdet.utils.eval_utils import parse_fetches, eval_results\n-from ppdet.utils.cli import ArgsParser\n-from ppdet.utils.check import check_gpu\n-import ppdet.utils.checkpoint as checkpoint\n-from ppdet.modeling.model_input import create_feed\n-\n-import logging\n-FORMAT = '%(asctime)s-%(levelname)s: %(message)s'\n-logging.basicConfig(level=logging.INFO, format=FORMAT)\n-logger = logging.getLogger(__name__)\n-\n-\n-def eval_run(exe, compile_program, reader, keys, values, cls, test_feed, cfg):\n- \"\"\"\n- Run evaluation program, return program outputs.\n- \"\"\"\n- iter_id = 0\n- results = []\n- if len(cls) != 0:\n- values = []\n- for i in range(len(cls)):\n- _, accum_map = cls[i].get_map_var()\n- cls[i].reset(exe)\n- values.append(accum_map)\n-\n- images_num = 0\n- start_time = time.time()\n- has_bbox = 'bbox' in keys\n- for data in reader():\n- data = test_feed.feed(data)\n- feed_data = {'image': data['image'], 'im_size': data['im_size']}\n- outs = exe.run(compile_program,\n- feed=feed_data,\n- fetch_list=[values[0]],\n- return_numpy=False)\n-\n- if cfg.metric == 'VOC':\n- outs.append(data['gt_box'])\n- outs.append(data['gt_label'])\n- outs.append(data['is_difficult'])\n- elif cfg.metric == 'COCO':\n- outs.append(data['im_info'])\n- outs.append(data['im_id'])\n- outs.append(data['im_shape'])\n-\n- res = {\n- k: (np.array(v), v.recursive_sequence_lengths())\n- for k, v in zip(keys, outs)\n- }\n- results.append(res)\n- if iter_id % 100 == 0:\n- logger.info('Test iter {}'.format(iter_id))\n- iter_id += 1\n- images_num += len(res['bbox'][1][0]) if has_bbox else 1\n- logger.info('Test finish iter {}'.format(iter_id))\n-\n- end_time = time.time()\n- fps = images_num / (end_time - start_time)\n- if has_bbox:\n- logger.info('Total number of images: {}, inference time: {} fps.'.\n- format(images_num, fps))\n- else:\n- logger.info('Total iteration: {}, inference time: {} batch/s.'.format(\n- images_num, fps))\n-\n- return results\n-\n-\n-def main():\n- cfg = load_config(FLAGS.config)\n- if 'architecture' in cfg:\n- main_arch = cfg.architecture\n- else:\n- raise ValueError(\"'architecture' not specified in config file.\")\n-\n- merge_config(FLAGS.opt)\n- if 'log_iter' not in cfg:\n- cfg.log_iter = 20\n-\n- # check if set use_gpu=True in paddlepaddle cpu version\n- check_gpu(cfg.use_gpu)\n-\n- if cfg.use_gpu:\n- devices_num = fluid.core.get_cuda_device_count()\n- else:\n- devices_num = int(\n- os.environ.get('CPU_NUM', multiprocessing.cpu_count()))\n-\n- if 'train_feed' not in cfg:\n- train_feed = create(main_arch + 'TrainFeed')\n- else:\n- train_feed = create(cfg.train_feed)\n-\n- if 'eval_feed' not in cfg:\n- eval_feed = create(main_arch + 'EvalFeed')\n- else:\n- eval_feed = create(cfg.eval_feed)\n-\n- place = fluid.CUDAPlace(0) if cfg.use_gpu else fluid.CPUPlace()\n- exe = fluid.Executor(place)\n-\n- lr_builder = create('LearningRate')\n- optim_builder = create('OptimizerBuilder')\n-\n- # build program\n- startup_prog = fluid.Program()\n- train_prog = fluid.Program()\n- with fluid.program_guard(train_prog, startup_prog):\n- with fluid.unique_name.guard():\n- model = create(main_arch)\n- _, feed_vars = create_feed(train_feed, True)\n- train_fetches = model.train(feed_vars)\n- loss = train_fetches['loss']\n- lr = lr_builder()\n- optimizer = optim_builder(lr)\n- optimizer.minimize(loss)\n-\n- train_reader = create_reader(train_feed, cfg.max_iters, FLAGS.dataset_dir)\n-\n- # parse train fetches\n- train_keys, train_values, _ = parse_fetches(train_fetches)\n- train_keys.append(\"lr\")\n- train_values.append(lr.name)\n-\n- train_fetch_list = []\n- for k, v in zip(train_keys, train_values):\n- train_fetch_list.append((k, v))\n-\n- eval_prog = fluid.Program()\n- with fluid.program_guard(eval_prog, startup_prog):\n- with fluid.unique_name.guard():\n- model = create(main_arch)\n- _, test_feed_vars = create_feed(eval_feed, True)\n- fetches = model.eval(test_feed_vars)\n-\n- eval_prog = eval_prog.clone(True)\n-\n- eval_reader = create_reader(eval_feed, args_path=FLAGS.dataset_dir)\n- test_data_feed = fluid.DataFeeder(test_feed_vars.values(), place)\n-\n- # parse eval fetches\n- extra_keys = []\n- if cfg.metric == 'COCO':\n- extra_keys = ['im_info', 'im_id', 'im_shape']\n- if cfg.metric == 'VOC':\n- extra_keys = ['gt_box', 'gt_label', 'is_difficult']\n- eval_keys, eval_values, eval_cls = parse_fetches(fetches, eval_prog,\n- extra_keys)\n- eval_fetch_list = []\n- for k, v in zip(eval_keys, eval_values):\n- eval_fetch_list.append((k, v))\n-\n- exe.run(startup_prog)\n- checkpoint.load_params(exe, train_prog, cfg.pretrain_weights)\n-\n- best_box_ap_list = []\n-\n- def eval_func(program, scope):\n-\n- #place = fluid.CPUPlace()\n- #exe = fluid.Executor(place)\n- results = eval_run(exe, program, eval_reader, eval_keys, eval_values,\n- eval_cls, test_data_feed, cfg)\n-\n- resolution = None\n- if 'mask' in results[0]:\n- resolution = model.mask_head.resolution\n- box_ap_stats = eval_results(results, eval_feed, cfg.metric,\n- cfg.num_classes, resolution, False,\n- FLAGS.output_eval)\n- if len(best_box_ap_list) == 0:\n- best_box_ap_list.append(box_ap_stats[0])\n- elif box_ap_stats[0] > best_box_ap_list[0]:\n- best_box_ap_list[0] = box_ap_stats[0]\n- logger.info(\"Best test box ap: {}\".format(best_box_ap_list[0]))\n- return best_box_ap_list[0]\n-\n- test_feed = [('image', test_feed_vars['image'].name),\n- ('im_size', test_feed_vars['im_size'].name)]\n-\n- com = Compressor(\n- place,\n- fluid.global_scope(),\n- train_prog,\n- train_reader=train_reader,\n- train_feed_list=[(key, value.name) for key, value in feed_vars.items()],\n- train_fetch_list=train_fetch_list,\n- eval_program=eval_prog,\n- eval_reader=eval_reader,\n- eval_feed_list=test_feed,\n- eval_func={'map': eval_func},\n- eval_fetch_list=[eval_fetch_list[0]],\n- save_eval_model=True,\n- prune_infer_model=[[\"image\", \"im_size\"], [\"multiclass_nms_0.tmp_0\"]],\n- train_optimizer=None)\n- com.config(FLAGS.slim_file)\n- com.run()\n-\n-\n-if __name__ == '__main__':\n- parser = ArgsParser()\n- parser.add_argument(\n- \"-s\",\n- \"--slim_file\",\n- default=None,\n- type=str,\n- help=\"Config file of PaddleSlim.\")\n- parser.add_argument(\n- \"--output_eval\",\n- default=None,\n- type=str,\n- help=\"Evaluation directory, default is current directory.\")\n- parser.add_argument(\n- \"-d\",\n- \"--dataset_dir\",\n- default=None,\n- type=str,\n- help=\"Dataset path, same as DataFeed.dataset.dataset_dir\")\n- FLAGS = parser.parse_args()\n- main()\n"
},
{
"change_type": "DELETE",
"old_path": "slim/prune/images/MobileNetV1-YoloV3.pdf",
"new_path": "slim/prune/images/MobileNetV1-YoloV3.pdf",
"diff": "Binary files a/slim/prune/images/MobileNetV1-YoloV3.pdf and /dev/null differ\n"
},
{
"change_type": "DELETE",
"old_path": "slim/prune/yolov3_mobilenet_v1_slim.yaml",
"new_path": null,
"diff": "-version: 1.0\n-pruners:\n- pruner_1:\n- class: 'StructurePruner'\n- pruning_axis:\n- '*': 0\n- criterions:\n- '*': 'l1_norm'\n-strategies:\n- uniform_pruning_strategy:\n- class: 'UniformPruneStrategy'\n- pruner: 'pruner_1'\n- start_epoch: 0\n- target_ratio: 0.5\n- pruned_params: '(conv2_1_sep_weights)|(conv2_2_sep_weights)|(conv3_1_sep_weights)|(conv4_1_sep_weights)|(conv5_1_sep_weights)|(conv5_2_sep_weights)|(conv5_3_sep_weights)|(conv5_4_sep_weights)|(conv5_5_sep_weights)|(conv5_6_sep_weights)|(yolo_block.0.0.0.conv.weights)|(yolo_block.0.0.1.conv.weights)|(yolo_block.0.1.0.conv.weights)|(yolo_block.0.1.1.conv.weights)|(yolo_block.1.0.0.conv.weights)|(yolo_block.1.0.1.conv.weights)|(yolo_block.1.1.0.conv.weights)|(yolo_block.1.1.1.conv.weights)|(yolo_block.1.2.conv.weights)|(yolo_block.2.0.0.conv.weights)|(yolo_block.2.0.1.conv.weights)|(yolo_block.2.1.1.conv.weights)|(yolo_block.2.2.conv.weights)|(yolo_block.2.tip.conv.weights)'\n- metric_name: 'acc_top1'\n-compressor:\n- epoch: 271\n- eval_epoch: 10\n- #init_model: './checkpoints/0' # Please enable this option for loading checkpoint.\n- checkpoint_path: './checkpoints/'\n- strategies:\n- - uniform_pruning_strategy\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Remove unused file from pruning demo. (#225) |
499,306 | 19.02.2020 13:58:36 | -28,800 | dbdbff1b225c7647f0c17083df17b322f30b54c6 | fix distill issue | [
{
"change_type": "MODIFY",
"old_path": "slim/distillation/distill.py",
"new_path": "slim/distillation/distill.py",
"diff": "@@ -227,6 +227,7 @@ def main():\nteacher_program = teacher_program.clone(for_test=True)\ncfg = load_config(FLAGS.config)\n+ merge_config(FLAGS.opt)\ndata_name_map = {\n'target0': 'target0',\n'target1': 'target1',\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix distill issue (#247) |
499,313 | 21.02.2020 10:31:50 | -28,800 | 029a0ec00d3bfb45c5d67f4ec463ec22ef25a871 | kill process group when main process exit | [
{
"change_type": "MODIFY",
"old_path": "ppdet/data/parallel_map.py",
"new_path": "ppdet/data/parallel_map.py",
"diff": "@@ -19,6 +19,7 @@ from __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n+import os\nimport sys\nimport six\nif six.PY3:\n@@ -281,3 +282,13 @@ class ParallelMap(object):\n# FIXME(dengkaipeng): fix me if you have better impliment\n# handle terminate reader process, do not print stack frame\nsignal.signal(signal.SIGTERM, lambda signum, frame: sys.exit())\n+\n+\n+def _term_group(sig_num, frame):\n+ pid = os.getpid()\n+ pg = os.getpgid(os.getpid())\n+ logger.info(\"main proc {} exit, kill process group \" \"{}\".format(pid, pg))\n+ os.killpg(pg, signal.SIGKILL)\n+\n+\n+signal.signal(signal.SIGINT, _term_group)\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | kill process group when main process exit (#136) |
499,313 | 21.02.2020 12:21:04 | -28,800 | 61a8b0e700817353594cf31161801c45243244f9 | fix voc eval | [
{
"change_type": "MODIFY",
"old_path": "ppdet/utils/map_utils.py",
"new_path": "ppdet/utils/map_utils.py",
"diff": "@@ -145,7 +145,9 @@ class DetectionMAP(object):\nvalid_cnt = 0\nfor score_pos, count in zip(self.class_score_poss,\nself.class_gt_counts):\n- if count == 0 or len(score_pos) == 0:\n+ if count == 0: continue\n+ if len(score_pos) == 0:\n+ valid_cnt += 1\ncontinue\naccum_tp_list, accum_fp_list = \\\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix voc eval (#249) |
499,323 | 21.02.2020 21:05:43 | 21,600 | 3849c173a7b194ae15c2716e6a1d42e4e8071b79 | Fix load checkpoint | [
{
"change_type": "MODIFY",
"old_path": "slim/quantization/export_model.py",
"new_path": "slim/quantization/export_model.py",
"diff": "@@ -21,7 +21,6 @@ import sys\nfrom paddle import fluid\nfrom ppdet.core.workspace import load_config, merge_config, create\n-from ppdet.modeling.model_input import create_feed\nfrom ppdet.utils.cli import ArgsParser\nimport ppdet.utils.checkpoint as checkpoint\nfrom tools.export_model import prune_feed_vars\n"
},
{
"change_type": "DELETE",
"old_path": "slim/quantization/freeze.py",
"new_path": null,
"diff": "-# Copyright (c) 2019 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 time\n-import multiprocessing\n-import numpy as np\n-import datetime\n-from collections import deque\n-import sys\n-sys.path.append(\"../../\")\n-from paddle.fluid.contrib.slim import Compressor\n-from paddle.fluid.framework import IrGraph\n-from paddle.fluid import core\n-from paddle.fluid.contrib.slim.quantization import QuantizationTransformPass\n-from paddle.fluid.contrib.slim.quantization import QuantizationFreezePass\n-from paddle.fluid.contrib.slim.quantization import ConvertToInt8Pass\n-from paddle.fluid.contrib.slim.quantization import TransformForMobilePass\n-\n-\n-def set_paddle_flags(**kwargs):\n- for key, value in kwargs.items():\n- if os.environ.get(key, None) is None:\n- os.environ[key] = str(value)\n-\n-\n-# NOTE(paddle-dev): All of these flags should be set before\n-# `import paddle`. Otherwise, it would not take any effect.\n-set_paddle_flags(\n- FLAGS_eager_delete_tensor_gb=0, # enable GC to save memory\n-)\n-\n-from paddle import fluid\n-\n-from ppdet.core.workspace import load_config, merge_config, create\n-from ppdet.data.data_feed import create_reader\n-\n-from ppdet.utils.eval_utils import parse_fetches, eval_results\n-from ppdet.utils.stats import TrainingStats\n-from ppdet.utils.cli import ArgsParser\n-from ppdet.utils.check import check_gpu\n-import ppdet.utils.checkpoint as checkpoint\n-from ppdet.modeling.model_input import create_feed\n-\n-import logging\n-FORMAT = '%(asctime)s-%(levelname)s: %(message)s'\n-logging.basicConfig(level=logging.INFO, format=FORMAT)\n-logger = logging.getLogger(__name__)\n-\n-\n-def eval_run(exe, compile_program, reader, keys, values, cls, test_feed):\n- \"\"\"\n- Run evaluation program, return program outputs.\n- \"\"\"\n- iter_id = 0\n- results = []\n-\n- images_num = 0\n- start_time = time.time()\n- has_bbox = 'bbox' in keys\n- for data in reader():\n- data = test_feed.feed(data)\n- feed_data = {'image': data['image'], 'im_size': data['im_size']}\n- outs = exe.run(compile_program,\n- feed=feed_data,\n- fetch_list=values[0],\n- return_numpy=False)\n- outs.append(data['gt_box'])\n- outs.append(data['gt_label'])\n- outs.append(data['is_difficult'])\n- res = {\n- k: (np.array(v), v.recursive_sequence_lengths())\n- for k, v in zip(keys, outs)\n- }\n- results.append(res)\n- if iter_id % 100 == 0:\n- logger.info('Test iter {}'.format(iter_id))\n- iter_id += 1\n- images_num += len(res['bbox'][1][0]) if has_bbox else 1\n- logger.info('Test finish iter {}'.format(iter_id))\n-\n- end_time = time.time()\n- fps = images_num / (end_time - start_time)\n- if has_bbox:\n- logger.info('Total number of images: {}, inference time: {} fps.'.\n- format(images_num, fps))\n- else:\n- logger.info('Total iteration: {}, inference time: {} batch/s.'.format(\n- images_num, fps))\n-\n- return results\n-\n-\n-def main():\n- cfg = load_config(FLAGS.config)\n- if 'architecture' in cfg:\n- main_arch = cfg.architecture\n- else:\n- raise ValueError(\"'architecture' not specified in config file.\")\n-\n- merge_config(FLAGS.opt)\n- if 'log_iter' not in cfg:\n- cfg.log_iter = 20\n-\n- # check if set use_gpu=True in paddlepaddle cpu version\n- check_gpu(cfg.use_gpu)\n-\n- if cfg.use_gpu:\n- devices_num = fluid.core.get_cuda_device_count()\n- else:\n- devices_num = int(\n- os.environ.get('CPU_NUM', multiprocessing.cpu_count()))\n-\n- if 'eval_feed' not in cfg:\n- eval_feed = create(main_arch + 'EvalFeed')\n- else:\n- eval_feed = create(cfg.eval_feed)\n-\n- place = fluid.CUDAPlace(0) if cfg.use_gpu else fluid.CPUPlace()\n- exe = fluid.Executor(place)\n-\n- _, test_feed_vars = create_feed(eval_feed, False)\n-\n- eval_reader = create_reader(eval_feed, args_path=FLAGS.dataset_dir)\n- #eval_pyreader.decorate_sample_list_generator(eval_reader, place)\n- test_data_feed = fluid.DataFeeder(test_feed_vars.values(), place)\n-\n- assert os.path.exists(FLAGS.model_path)\n- infer_prog, feed_names, fetch_targets = fluid.io.load_inference_model(\n- dirname=FLAGS.model_path,\n- executor=exe,\n- model_filename='__model__.infer',\n- params_filename='__params__')\n-\n- eval_keys = ['bbox', 'gt_box', 'gt_label', 'is_difficult']\n- eval_values = [\n- 'multiclass_nms_0.tmp_0', 'gt_box', 'gt_label', 'is_difficult'\n- ]\n- eval_cls = []\n- eval_values[0] = fetch_targets[0]\n-\n- results = eval_run(exe, infer_prog, eval_reader, eval_keys, eval_values,\n- eval_cls, test_data_feed)\n-\n- resolution = None\n- if 'mask' in results[0]:\n- resolution = model.mask_head.resolution\n- box_ap_stats = eval_results(results, eval_feed, cfg.metric, cfg.num_classes,\n- resolution, False, FLAGS.output_eval)\n-\n- logger.info(\"freeze the graph for inference\")\n- test_graph = IrGraph(core.Graph(infer_prog.desc), for_test=True)\n-\n- freeze_pass = QuantizationFreezePass(\n- scope=fluid.global_scope(),\n- place=place,\n- weight_quantize_type=FLAGS.weight_quant_type)\n- freeze_pass.apply(test_graph)\n- server_program = test_graph.to_program()\n- fluid.io.save_inference_model(\n- dirname=os.path.join(FLAGS.save_path, 'float'),\n- feeded_var_names=feed_names,\n- target_vars=fetch_targets,\n- executor=exe,\n- main_program=server_program,\n- model_filename='model',\n- params_filename='weights')\n-\n- logger.info(\"convert the weights into int8 type\")\n- convert_int8_pass = ConvertToInt8Pass(\n- scope=fluid.global_scope(), place=place)\n- convert_int8_pass.apply(test_graph)\n- server_int8_program = test_graph.to_program()\n- fluid.io.save_inference_model(\n- dirname=os.path.join(FLAGS.save_path, 'int8'),\n- feeded_var_names=feed_names,\n- target_vars=fetch_targets,\n- executor=exe,\n- main_program=server_int8_program,\n- model_filename='model',\n- params_filename='weights')\n-\n- logger.info(\"convert the freezed pass to paddle-lite execution\")\n- mobile_pass = TransformForMobilePass()\n- mobile_pass.apply(test_graph)\n- mobile_program = test_graph.to_program()\n- fluid.io.save_inference_model(\n- dirname=os.path.join(FLAGS.save_path, 'mobile'),\n- feeded_var_names=feed_names,\n- target_vars=fetch_targets,\n- executor=exe,\n- main_program=mobile_program,\n- model_filename='model',\n- params_filename='weights')\n-\n-\n-if __name__ == '__main__':\n- parser = ArgsParser()\n- parser.add_argument(\n- \"-m\", \"--model_path\", default=None, type=str, help=\"path of checkpoint\")\n- parser.add_argument(\n- \"--output_eval\",\n- default=None,\n- type=str,\n- help=\"Evaluation directory, default is current directory.\")\n- parser.add_argument(\n- \"-d\",\n- \"--dataset_dir\",\n- default=None,\n- type=str,\n- help=\"Dataset path, same as DataFeed.dataset.dataset_dir\")\n- parser.add_argument(\n- \"--weight_quant_type\",\n- default='abs_max',\n- type=str,\n- help=\"quantization type for weight\")\n- parser.add_argument(\n- \"--save_path\",\n- default='./output',\n- type=str,\n- help=\"path to save quantization inference model\")\n-\n- FLAGS = parser.parse_args()\n- main()\n"
},
{
"change_type": "MODIFY",
"old_path": "slim/quantization/train.py",
"new_path": "slim/quantization/train.py",
"diff": "@@ -166,14 +166,15 @@ def main():\nfuse_bn = getattr(model.backbone, 'norm_type', None) == 'affine_channel'\n- if FLAGS.resume_checkpoint:\n- checkpoint.load_checkpoint(exe, train_prog, FLAGS.resume_checkpoint)\n- start_iter = checkpoint.global_step()\n- elif cfg.pretrain_weights and fuse_bn and not ignore_params:\n+ if not FLAGS.resume_checkpoint:\n+ if 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, train_prog, cfg.pretrain_weights, ignore_params=ignore_params)\n+ exe,\n+ train_prog,\n+ cfg.pretrain_weights,\n+ ignore_params=ignore_params)\n# insert quantize op in train_prog, return type is CompiledProgram\ntrain_prog = quant_aware(train_prog, place, config, for_test=False)\n@@ -189,6 +190,9 @@ def main():\ncompiled_eval_prog = fluid.compiler.CompiledProgram(eval_prog)\nstart_iter = 0\n+ if FLAGS.resume_checkpoint:\n+ checkpoint.load_checkpoint(exe, eval_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"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Fix load checkpoint (#250) |
499,304 | 24.02.2020 12:48:20 | -28,800 | de2589ea425e037312ac16c7a4695235c1acc2fb | Fix softlink | [
{
"change_type": "DELETE",
"old_path": "docs/advanced_tutorials/slim/DISTILLATION.md",
"new_path": null,
"diff": "-../../../slim/distillation/README.md\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/advanced_tutorials/slim/MODEL_ZOO.md",
"new_path": "docs/advanced_tutorials/slim/MODEL_ZOO.md",
"diff": "-slim/README.md\n\\ No newline at end of file\n+../../../slim/README.md\n\\ No newline at end of file\n"
},
{
"change_type": "DELETE",
"old_path": "docs/advanced_tutorials/slim/NAS.md",
"new_path": null,
"diff": "-../../../slim/nas/README.md\n\\ No newline at end of file\n"
},
{
"change_type": "DELETE",
"old_path": "docs/advanced_tutorials/slim/QUANTIZATION.md",
"new_path": null,
"diff": "-../../../slim/quantization/README.md\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "docs/advanced_tutorials/slim/distillation/DISTILLATION.md",
"diff": "+../../../../slim/distillation/README.md\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/advanced_tutorials/slim/index.rst",
"new_path": "docs/advanced_tutorials/slim/index.rst",
"diff": ".. toctree::\n:maxdepth: 2\n- DISTILLATION.md\n- QUANTIZATION.md\n- NAS.md\n- prune/index\nMODEL_ZOO.md\n+ distillation/index\n+ quantization/index\n+ nas/index\n+ prune/index\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "docs/advanced_tutorials/slim/nas/NAS.md",
"diff": "+../../../../slim/nas/README.md\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "docs/advanced_tutorials/slim/quantization/QUANTIZATION.md",
"diff": "+../../../../slim/quantization/README.md\n\\ No newline at end of file\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Fix softlink (#256) |
499,323 | 25.02.2020 07:25:31 | 21,600 | 17f7cbfa8ea46a2e044d48b3c0603bfea49b33a2 | fix run command for windows | [
{
"change_type": "MODIFY",
"old_path": "slim/quantization/README.md",
"new_path": "slim/quantization/README.md",
"diff": "@@ -63,7 +63,7 @@ python slim/quantization/train.py --not_quant_pattern yolo_output \\\n-o max_iters=30000 \\\nsave_dir=./output/mobilenetv1 \\\nLearningRate.base_lr=0.0001 \\\n- LearningRate.schedulers='[!PiecewiseDecay {gamma: 0.1, milestones: [10000]}]' \\\n+ LearningRate.schedulers=\"[!PiecewiseDecay {gamma: 0.1, milestones: [10000]}]\" \\\npretrain_weights=https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar\n```\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix run command for windows (#261) |
499,333 | 27.02.2020 14:21:48 | -28,800 | 021a13c777bc73e79442b2a0b25a3ee9f12f13d3 | update reader config | [
{
"change_type": "MODIFY",
"old_path": "configs/dcn/cascade_mask_rcnn_dcnv2_se154_vd_fpn_gn_s1x.yml",
"new_path": "configs/dcn/cascade_mask_rcnn_dcnv2_se154_vd_fpn_gn_s1x.yml",
"diff": "@@ -235,7 +235,6 @@ EvalReader:\nTestReader:\nbatch_size: 1\ninputs_def:\n- image_shape: [3,800,1333]\nfields: ['image', 'im_info', 'im_id', 'im_shape']\ndataset:\n!ImageFolder\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/dcn/cascade_rcnn_cls_aware_r200_vd_fpn_dcnv2_nonlocal_softnms.yml",
"new_path": "configs/dcn/cascade_rcnn_cls_aware_r200_vd_fpn_dcnv2_nonlocal_softnms.yml",
"diff": "@@ -185,7 +185,6 @@ EvalReader:\nTestReader:\ninputs_def:\n- image_shape: [3,800,1333]\nfields: ['image', 'im_info', 'im_id', 'im_shape']\ndataset:\n!ImageFolder\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/faster_reader.yml",
"new_path": "configs/faster_reader.yml",
"diff": "@@ -62,7 +62,6 @@ EvalReader:\nTestReader:\ninputs_def:\n- image_shape: [3,800,1333]\nfields: ['image', 'im_info', 'im_id', 'im_shape']\ndataset:\n!ImageFolder\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/mask_fpn_reader.yml",
"new_path": "configs/mask_fpn_reader.yml",
"diff": "@@ -73,7 +73,6 @@ EvalReader:\nTestReader:\ninputs_def:\n- image_shape: [3,800,1333]\nfields: ['image', 'im_info', 'im_id', 'im_shape']\ndataset:\n!ImageFolder\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/mask_reader.yml",
"new_path": "configs/mask_reader.yml",
"diff": "@@ -65,7 +65,6 @@ EvalReader:\nTestReader:\ninputs_def:\n- image_shape: [3,800,1333]\nfields: ['image', 'im_info', 'im_id', 'im_shape']\ndataset:\n!ImageFolder\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | update reader config (#267) |
499,300 | 27.02.2020 19:02:33 | -28,800 | eb7b0ddd7dc6901357c8fb9e92c9ef7bafd0b607 | Force `cudnn` backend for depthwise convs when fp16 is enabled | [
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/backbones/blazenet.py",
"new_path": "ppdet/modeling/backbones/blazenet.py",
"diff": "@@ -19,6 +19,7 @@ from __future__ import print_function\nfrom paddle import fluid\nfrom paddle.fluid.param_attr import ParamAttr\n+from ppdet.experimental import mixed_precision_global_state\nfrom ppdet.core.workspace import register\n__all__ = ['BlazeNet']\n@@ -151,6 +152,7 @@ class BlazeNet(object):\nuse_pool = not stride == 1\nuse_double_block = double_channels is not None\nact = 'relu' if use_double_block else None\n+ mixed_precision_enabled = mixed_precision_global_state() is not None\nif use_5x5kernel:\nconv_dw = self._conv_norm(\n@@ -160,7 +162,7 @@ class BlazeNet(object):\nstride=stride,\npadding=2,\nnum_groups=in_channels,\n- use_cudnn=False,\n+ use_cudnn=mixed_precision_enabled,\nname=name + \"1_dw\")\nelse:\nconv_dw_1 = self._conv_norm(\n@@ -170,7 +172,7 @@ class BlazeNet(object):\nstride=1,\npadding=1,\nnum_groups=in_channels,\n- use_cudnn=False,\n+ use_cudnn=mixed_precision_enabled,\nname=name + \"1_dw_1\")\nconv_dw = self._conv_norm(\ninput=conv_dw_1,\n@@ -179,7 +181,7 @@ class BlazeNet(object):\nstride=stride,\npadding=1,\nnum_groups=in_channels,\n- use_cudnn=False,\n+ use_cudnn=mixed_precision_enabled,\nname=name + \"1_dw_2\")\nconv_pw = self._conv_norm(\n@@ -199,7 +201,7 @@ class BlazeNet(object):\nnum_filters=out_channels,\nstride=1,\npadding=2,\n- use_cudnn=False,\n+ use_cudnn=mixed_precision_enabled,\nname=name + \"2_dw\")\nelse:\nconv_dw_1 = self._conv_norm(\n@@ -209,7 +211,7 @@ class BlazeNet(object):\nstride=1,\npadding=1,\nnum_groups=out_channels,\n- use_cudnn=False,\n+ use_cudnn=mixed_precision_enabled,\nname=name + \"2_dw_1\")\nconv_dw = self._conv_norm(\ninput=conv_dw_1,\n@@ -218,7 +220,7 @@ class BlazeNet(object):\nstride=1,\npadding=1,\nnum_groups=out_channels,\n- use_cudnn=False,\n+ use_cudnn=mixed_precision_enabled,\nname=name + \"2_dw_2\")\nconv_pw = self._conv_norm(\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/backbones/mobilenet.py",
"new_path": "ppdet/modeling/backbones/mobilenet.py",
"diff": "@@ -20,6 +20,7 @@ from paddle import fluid\nfrom paddle.fluid.param_attr import ParamAttr\nfrom paddle.fluid.regularizer import L2Decay\n+from ppdet.experimental import mixed_precision_global_state\nfrom ppdet.core.workspace import register\n__all__ = ['MobileNet']\n@@ -104,6 +105,7 @@ class MobileNet(object):\nstride,\nscale,\nname=None):\n+ mixed_precision_enabled = mixed_precision_global_state() is not None\ndepthwise_conv = self._conv_norm(\ninput=input,\nfilter_size=3,\n@@ -111,7 +113,7 @@ class MobileNet(object):\nstride=stride,\npadding=1,\nnum_groups=int(num_groups * scale),\n- use_cudnn=False,\n+ use_cudnn=mixed_precision_enabled,\nname=name + \"_dw\")\npointwise_conv = self._conv_norm(\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Force `cudnn` backend for depthwise convs when fp16 is enabled (#270) |
499,333 | 04.03.2020 12:47:09 | -28,800 | 9f76868da1ca90bf196b99764ff39b8ca88cacb9 | fix infer on windows | [
{
"change_type": "MODIFY",
"old_path": "tools/infer.py",
"new_path": "tools/infer.py",
"diff": "@@ -74,20 +74,20 @@ def get_test_images(infer_dir, infer_img):\n\"{} is not a file\".format(infer_img)\nassert infer_dir is None or os.path.isdir(infer_dir), \\\n\"{} is not a directory\".format(infer_dir)\n- images = []\n# infer_img has a higher priority\nif infer_img and os.path.isfile(infer_img):\n- images.append(infer_img)\n- return images\n+ return [infer_img]\n+ images = set()\ninfer_dir = os.path.abspath(infer_dir)\nassert os.path.isdir(infer_dir), \\\n\"infer_dir {} is not a directory\".format(infer_dir)\nexts = ['jpg', 'jpeg', 'png', 'bmp']\nexts += [ext.upper() for ext in exts]\nfor ext in exts:\n- images.extend(glob.glob('{}/*.{}'.format(infer_dir, ext)))\n+ images.update(glob.glob('{}/*.{}'.format(infer_dir, ext)))\n+ images = list(images)\nassert len(images) > 0, \"no image found in {}\".format(infer_dir)\nlogger.info(\"Found {} inference images in total.\".format(len(images)))\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix infer on windows (#300) |
499,369 | 12.03.2020 17:53:24 | -28,800 | b2bbca3311fc6ecfb87a2243b79db208f736bc72 | refine pedestrian_yolov3_darknet.yml and vehicle_yolov3_darknet.yml in contrib | [
{
"change_type": "MODIFY",
"old_path": "contrib/PedestrianDetection/pedestrian_yolov3_darknet.yml",
"new_path": "contrib/PedestrianDetection/pedestrian_yolov3_darknet.yml",
"diff": "architecture: YOLOv3\n-train_feed: YoloTrainFeed\n-eval_feed: YoloEvalFeed\n-test_feed: YoloTestFeed\nuse_gpu: true\nmax_iters: 200000\nlog_smooth_window: 20\n@@ -11,6 +8,7 @@ metric: COCO\npretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/DarkNet53_pretrained.tar\nweights: https://paddlemodels.bj.bcebos.com/object_detection/pedestrian_yolov3_darknet.tar\nnum_classes: 1\n+use_fine_grained_loss: false\nYOLOv3:\nbackbone: DarkNet\n@@ -27,8 +25,7 @@ YOLOv3Head:\n[30, 61], [62, 45], [59, 119],\n[116, 90], [156, 198], [373, 326]]\nnorm_decay: 0.\n- ignore_thresh: 0.7\n- label_smooth: true\n+ yolo_loss: YOLOv3Loss\nnms:\nbackground_label: -1\nkeep_top_k: 100\n@@ -37,6 +34,11 @@ YOLOv3Head:\nnormalized: false\nscore_threshold: 0.01\n+YOLOv3Loss:\n+ batch_size: 8\n+ ignore_thresh: 0.7\n+ label_smooth: false\n+\nLearningRate:\nbase_lr: 0.001\nschedulers:\n@@ -57,26 +59,28 @@ OptimizerBuilder:\nfactor: 0.0005\ntype: L2\n-YoloTrainFeed:\n+_READER_: '../../configs/yolov3_reader.yml'\n+TrainReader:\nbatch_size: 8\ndataset:\n+ !COCODataSet\ndataset_dir: dataset/pedestrian\n- annotation: annotations/instances_train2017.json\n+ anno_path: annotations/instances_train2017.json\nimage_dir: train2017\n- num_workers: 8\n- bufsize: 128\n- use_process: true\n+ with_background: false\n-YoloEvalFeed:\n+EvalReader:\nbatch_size: 8\n- image_shape: [3, 608, 608]\ndataset:\n+ !COCODataSet\ndataset_dir: dataset/pedestrian\n- annotation: annotations/instances_val2017.json\n+ anno_path: annotations/instances_val2017.json\nimage_dir: val2017\n+ with_background: false\n-YoloTestFeed:\n+TestReader:\nbatch_size: 1\n- image_shape: [3, 608, 608]\ndataset:\n- annotation: contrib/PedestrianDetection/pedestrian.json\n+ !ImageFolder\n+ anno_path: contrib/PedestrianDetection/pedestrian.json\n+ with_background: false\n"
},
{
"change_type": "MODIFY",
"old_path": "contrib/VehicleDetection/vehicle_yolov3_darknet.yml",
"new_path": "contrib/VehicleDetection/vehicle_yolov3_darknet.yml",
"diff": "architecture: YOLOv3\n-train_feed: YoloTrainFeed\n-eval_feed: YoloEvalFeed\n-test_feed: YoloTestFeed\nuse_gpu: true\nmax_iters: 120000\nlog_smooth_window: 20\n@@ -27,8 +24,7 @@ YOLOv3Head:\n[23, 33], [40, 25], [54, 50],\n[101, 80], [139, 145], [253, 224]]\nnorm_decay: 0.\n- ignore_thresh: 0.7\n- label_smooth: false\n+ yolo_loss: YOLOv3Loss\nnms:\nbackground_label: -1\nkeep_top_k: 100\n@@ -37,6 +33,11 @@ YOLOv3Head:\nnormalized: false\nscore_threshold: 0.005\n+YOLOv3Loss:\n+ batch_size: 8\n+ ignore_thresh: 0.7\n+ label_smooth: false\n+\nLearningRate:\nbase_lr: 0.001\nschedulers:\n@@ -57,26 +58,28 @@ OptimizerBuilder:\nfactor: 0.0005\ntype: L2\n-YoloTrainFeed:\n+_READER_: '../../configs/yolov3_reader.yml'\n+TrainReader:\nbatch_size: 8\ndataset:\n+ !COCODataSet\ndataset_dir: dataset/vehicle\n- annotation: annotations/instances_train2017.json\n+ anno_path: annotations/instances_train2017.json\nimage_dir: train2017\n- num_workers: 8\n- bufsize: 128\n- use_process: true\n+ with_background: false\n-YoloEvalFeed:\n+EvalReader:\nbatch_size: 8\n- image_shape: [3, 608, 608]\ndataset:\n+ !COCODataSet\ndataset_dir: dataset/vehicle\n- annotation: annotations/instances_val2017.json\n+ anno_path: annotations/instances_val2017.json\nimage_dir: val2017\n+ with_background: false\n-YoloTestFeed:\n+TestReader:\nbatch_size: 1\n- image_shape: [3, 608, 608]\ndataset:\n- annotation: contrib/VehicleDetection/vehicle.json\n+ !ImageFolder\n+ anno_path: contrib/VehicleDetection/vehicle.json\n+ with_background: false\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | refine pedestrian_yolov3_darknet.yml and vehicle_yolov3_darknet.yml in contrib (#323) |
499,313 | 16.03.2020 10:39:27 | -28,800 | dfddd5a020d863f25242ca0e3ca82d92db810fe5 | fix yolo configs | [
{
"change_type": "MODIFY",
"old_path": "configs/yolov3_darknet.yml",
"new_path": "configs/yolov3_darknet.yml",
"diff": "@@ -37,7 +37,7 @@ YOLOv3Head:\nYOLOv3Loss:\nbatch_size: 8\nignore_thresh: 0.7\n- label_smooth: false\n+ label_smooth: true\nLearningRate:\nbase_lr: 0.001\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/yolov3_darknet_voc.yml",
"new_path": "configs/yolov3_darknet_voc.yml",
"diff": "@@ -38,7 +38,7 @@ YOLOv3Head:\nYOLOv3Loss:\nbatch_size: 8\nignore_thresh: 0.7\n- label_smooth: true\n+ label_smooth: false\nLearningRate:\nbase_lr: 0.001\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/yolov3_mobilenet_v1.yml",
"new_path": "configs/yolov3_mobilenet_v1.yml",
"diff": "@@ -38,7 +38,7 @@ YOLOv3Head:\nYOLOv3Loss:\nbatch_size: 8\nignore_thresh: 0.7\n- label_smooth: false\n+ label_smooth: true\nLearningRate:\nbase_lr: 0.001\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/yolov3_mobilenet_v1_voc.yml",
"new_path": "configs/yolov3_mobilenet_v1_voc.yml",
"diff": "@@ -72,7 +72,6 @@ TrainReader:\nEvalReader:\ninputs_def:\n- image_shape: [3, 608, 608]\nfields: ['image', 'im_size', 'im_id', 'gt_bbox', 'gt_class', 'is_difficult']\nnum_max_boxes: 50\ndataset:\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/yolov3_r34.yml",
"new_path": "configs/yolov3_r34.yml",
"diff": "@@ -40,7 +40,7 @@ YOLOv3Head:\nYOLOv3Loss:\nbatch_size: 8\nignore_thresh: 0.7\n- label_smooth: false\n+ label_smooth: true\nLearningRate:\nbase_lr: 0.001\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/yolov3_r34_voc.yml",
"new_path": "configs/yolov3_r34_voc.yml",
"diff": "@@ -74,7 +74,6 @@ TrainReader:\nEvalReader:\ninputs_def:\n- image_shape: [3, 608, 608]\nfields: ['image', 'im_size', 'im_id', 'gt_bbox', 'gt_class', 'is_difficult']\nnum_max_boxes: 50\ndataset:\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix yolo configs (#331) |
499,306 | 17.03.2020 10:18:39 | -28,800 | 2d385d258381392aea906f35c1dc00ea02e654b6 | save inference model in slim/distillation | [
{
"change_type": "MODIFY",
"old_path": "slim/distillation/distill.py",
"new_path": "slim/distillation/distill.py",
"diff": "@@ -335,6 +335,12 @@ def main():\ncheckpoint.save(exe,\nfluid.default_main_program(),\nos.path.join(save_dir, save_name))\n+ if FLAGS.save_inference:\n+ feeded_var_names = ['image', 'im_size']\n+ targets = list(fetches.values())\n+ fluid.io.save_inference_model(save_dir + '/infer',\n+ feeded_var_names, targets, exe,\n+ eval_prog)\n# eval\nresults = eval_run(exe, compiled_eval_prog, eval_loader, eval_keys,\neval_values, eval_cls)\n@@ -349,7 +355,13 @@ def main():\nbest_box_ap_list[1] = step_id\ncheckpoint.save(exe,\nfluid.default_main_program(),\n- os.path.join(\"./\", \"best_model\"))\n+ os.path.join(save_dir, \"best_model\"))\n+ if FLAGS.save_inference:\n+ feeded_var_names = ['image', 'im_size']\n+ targets = list(fetches.values())\n+ fluid.io.save_inference_model(save_dir + '/infer',\n+ feeded_var_names, targets,\n+ exe, eval_prog)\nlogger.info(\"Best test box ap: {}, in step: {}\".format(\nbest_box_ap_list[0], best_box_ap_list[1]))\ntrain_loader.reset()\n@@ -379,5 +391,10 @@ if __name__ == '__main__':\ndefault=None,\ntype=str,\nhelp=\"Evaluation directory, default is current directory.\")\n+ parser.add_argument(\n+ \"--save_inference\",\n+ default=False,\n+ type=bool,\n+ help=\"Whether to save inference model.\")\nFLAGS = parser.parse_args()\nmain()\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | save inference model in slim/distillation (#339) |
499,308 | 17.03.2020 16:46:56 | -28,800 | b18151e630ab9a5853d7067dce4d68b901ac4da0 | add ce for PaddleDetection | [
{
"change_type": "MODIFY",
"old_path": "tools/train.py",
"new_path": "tools/train.py",
"diff": "@@ -19,6 +19,7 @@ from __future__ import print_function\nimport os\nimport time\nimport numpy as np\n+import random\nimport datetime\nfrom collections import deque\n@@ -60,11 +61,14 @@ def main():\nFLAGS.dist = 'PADDLE_TRAINER_ID' in env and 'PADDLE_TRAINERS_NUM' in env\nif FLAGS.dist:\ntrainer_id = int(env['PADDLE_TRAINER_ID'])\n- import random\nlocal_seed = (99 + trainer_id)\nrandom.seed(local_seed)\nnp.random.seed(local_seed)\n+ if FLAGS.enable_ce:\n+ random.seed(0)\n+ np.random.seed(0)\n+\ncfg = load_config(FLAGS.config)\nif 'architecture' in cfg:\nmain_arch = cfg.architecture\n@@ -101,6 +105,9 @@ def main():\n# build program\nstartup_prog = fluid.Program()\ntrain_prog = fluid.Program()\n+ if FLAGS.enable_ce:\n+ startup_prog.random_seed = 1000\n+ train_prog.random_seed = 1000\nwith fluid.program_guard(train_prog, startup_prog):\nwith fluid.unique_name.guard():\nmodel = create(main_arch)\n@@ -319,5 +326,11 @@ if __name__ == '__main__':\ntype=str,\ndefault=\"tb_log_dir/scalar\",\nhelp='Tensorboard logging directory for scalar.')\n+ parser.add_argument(\n+ \"--enable_ce\",\n+ type=bool,\n+ default=False,\n+ help=\"If set True, enable continuous evaluation job.\"\n+ \"This flag is only used for internal test.\")\nFLAGS = parser.parse_args()\nmain()\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | add ce for PaddleDetection (#343) |
499,313 | 18.03.2020 11:14:57 | -28,800 | 1455801e3f7ab1b78a444f2f112c2b1b47da8dfe | add YOLOv3Loss.batch_size comments | [
{
"change_type": "MODIFY",
"old_path": "configs/dcn/yolov3_r50vd_dcn.yml",
"new_path": "configs/dcn/yolov3_r50vd_dcn.yml",
"diff": "@@ -40,6 +40,10 @@ YOLOv3Head:\nscore_threshold: 0.01\nYOLOv3Loss:\n+ # batch_size here is only used for fine grained loss, not used\n+ # for training batch_size setting, training batch_size setting\n+ # is in configs/yolov3_reader.yml TrainReader.batch_size, batch\n+ # size here should be set as same value as TrainReader.batch_size\nbatch_size: 8\nignore_thresh: 0.7\nlabel_smooth: false\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/dcn/yolov3_r50vd_dcn_db_iouloss_obj365_pretrained_coco.yml",
"new_path": "configs/dcn/yolov3_r50vd_dcn_db_iouloss_obj365_pretrained_coco.yml",
"diff": "@@ -42,6 +42,10 @@ YOLOv3Head:\ndrop_block: true\nYOLOv3Loss:\n+ # batch_size here is only used for fine grained loss, not used\n+ # for training batch_size setting, training batch_size setting\n+ # is in configs/yolov3_reader.yml TrainReader.batch_size, batch\n+ # size here should be set as same value as TrainReader.batch_size\nbatch_size: 8\nignore_thresh: 0.7\nlabel_smooth: false\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/dcn/yolov3_r50vd_dcn_db_obj365_pretrained_coco.yml",
"new_path": "configs/dcn/yolov3_r50vd_dcn_db_obj365_pretrained_coco.yml",
"diff": "@@ -43,6 +43,10 @@ YOLOv3Head:\nkeep_prob: 0.94\nYOLOv3Loss:\n+ # batch_size here is only used for fine grained loss, not used\n+ # for training batch_size setting, training batch_size setting\n+ # is in configs/yolov3_reader.yml TrainReader.batch_size, batch\n+ # size here should be set as same value as TrainReader.batch_size\nbatch_size: 8\nignore_thresh: 0.7\nlabel_smooth: false\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/dcn/yolov3_r50vd_dcn_obj365_pretrained_coco.yml",
"new_path": "configs/dcn/yolov3_r50vd_dcn_obj365_pretrained_coco.yml",
"diff": "@@ -41,6 +41,10 @@ YOLOv3Head:\nscore_threshold: 0.01\nYOLOv3Loss:\n+ # batch_size here is only used for fine grained loss, not used\n+ # for training batch_size setting, training batch_size setting\n+ # is in configs/yolov3_reader.yml TrainReader.batch_size, batch\n+ # size here should be set as same value as TrainReader.batch_size\nbatch_size: 8\nignore_thresh: 0.7\nlabel_smooth: false\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/yolov3_darknet.yml",
"new_path": "configs/yolov3_darknet.yml",
"diff": "@@ -35,6 +35,10 @@ YOLOv3Head:\nscore_threshold: 0.01\nYOLOv3Loss:\n+ # batch_size here is only used for fine grained loss, not used\n+ # for training batch_size setting, training batch_size setting\n+ # is in configs/yolov3_reader.yml TrainReader.batch_size, batch\n+ # size here should be set as same value as TrainReader.batch_size\nbatch_size: 8\nignore_thresh: 0.7\nlabel_smooth: true\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/yolov3_darknet_voc.yml",
"new_path": "configs/yolov3_darknet_voc.yml",
"diff": "@@ -36,6 +36,10 @@ YOLOv3Head:\nscore_threshold: 0.01\nYOLOv3Loss:\n+ # batch_size here is only used for fine grained loss, not used\n+ # for training batch_size setting, training batch_size setting\n+ # is in configs/yolov3_reader.yml TrainReader.batch_size, batch\n+ # size here should be set as same value as TrainReader.batch_size\nbatch_size: 8\nignore_thresh: 0.7\nlabel_smooth: false\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/yolov3_mobilenet_v1.yml",
"new_path": "configs/yolov3_mobilenet_v1.yml",
"diff": "@@ -36,6 +36,10 @@ YOLOv3Head:\nscore_threshold: 0.01\nYOLOv3Loss:\n+ # batch_size here is only used for fine grained loss, not used\n+ # for training batch_size setting, training batch_size setting\n+ # is in configs/yolov3_reader.yml TrainReader.batch_size, batch\n+ # size here should be set as same value as TrainReader.batch_size\nbatch_size: 8\nignore_thresh: 0.7\nlabel_smooth: true\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/yolov3_mobilenet_v1_fruit.yml",
"new_path": "configs/yolov3_mobilenet_v1_fruit.yml",
"diff": "@@ -38,6 +38,10 @@ YOLOv3Head:\nscore_threshold: 0.01\nYOLOv3Loss:\n+ # batch_size here is only used for fine grained loss, not used\n+ # for training batch_size setting, training batch_size setting\n+ # is in configs/yolov3_reader.yml TrainReader.batch_size, batch\n+ # size here should be set as same value as TrainReader.batch_size\nbatch_size: 8\nignore_thresh: 0.7\nlabel_smooth: true\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/yolov3_mobilenet_v1_voc.yml",
"new_path": "configs/yolov3_mobilenet_v1_voc.yml",
"diff": "@@ -37,6 +37,10 @@ YOLOv3Head:\nscore_threshold: 0.01\nYOLOv3Loss:\n+ # batch_size here is only used for fine grained loss, not used\n+ # for training batch_size setting, training batch_size setting\n+ # is in configs/yolov3_reader.yml TrainReader.batch_size, batch\n+ # size here should be set as same value as TrainReader.batch_size\nbatch_size: 8\nignore_thresh: 0.7\nlabel_smooth: false\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/yolov3_r34.yml",
"new_path": "configs/yolov3_r34.yml",
"diff": "@@ -38,6 +38,10 @@ YOLOv3Head:\nscore_threshold: 0.01\nYOLOv3Loss:\n+ # batch_size here is only used for fine grained loss, not used\n+ # for training batch_size setting, training batch_size setting\n+ # is in configs/yolov3_reader.yml TrainReader.batch_size, batch\n+ # size here should be set as same value as TrainReader.batch_size\nbatch_size: 8\nignore_thresh: 0.7\nlabel_smooth: true\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/yolov3_r34_voc.yml",
"new_path": "configs/yolov3_r34_voc.yml",
"diff": "@@ -39,6 +39,10 @@ YOLOv3Head:\nscore_threshold: 0.01\nYOLOv3Loss:\n+ # batch_size here is only used for fine grained loss, not used\n+ # for training batch_size setting, training batch_size setting\n+ # is in configs/yolov3_reader.yml TrainReader.batch_size, batch\n+ # size here should be set as same value as TrainReader.batch_size\nbatch_size: 8\nignore_thresh: 0.7\nlabel_smooth: false\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | add YOLOv3Loss.batch_size comments (#347) |
499,400 | 20.03.2020 15:49:30 | -28,800 | cc84b7abfb32df40681fb2823900e1655d2e66da | Fix sensitivy in slim demo. | [
{
"change_type": "MODIFY",
"old_path": "slim/sensitive/sensitive.py",
"new_path": "slim/sensitive/sensitive.py",
"diff": "@@ -82,7 +82,6 @@ def main():\nfeed_vars, eval_loader = model.build_inputs(**inputs_def)\nfetches = model.eval(feed_vars)\neval_prog = eval_prog.clone(True)\n-\nif FLAGS.print_params:\nprint(\n\"-------------------------All parameters in current graph----------------------\"\n@@ -104,7 +103,7 @@ def main():\nif cfg.metric == 'COCO':\nextra_keys = ['im_info', 'im_id', 'im_shape']\nif cfg.metric == 'VOC':\n- extra_keys = ['gt_box', 'gt_label', 'is_difficult']\n+ extra_keys = ['gt_bbox', 'gt_class', 'is_difficult']\nif cfg.metric == 'WIDERFACE':\nextra_keys = ['im_id', 'im_shape', 'gt_box']\neval_keys, eval_values, eval_cls = parse_fetches(fetches, eval_prog,\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Fix sensitivy in slim demo. (#365) |
499,313 | 23.03.2020 11:37:54 | -28,800 | 366eb59c9ff75d8cab093f0449ead860e0b75649 | add prune export_model | [
{
"change_type": "MODIFY",
"old_path": "slim/prune/eval.py",
"new_path": "slim/prune/eval.py",
"diff": "@@ -176,7 +176,7 @@ def main():\n# load model\nexe.run(startup_prog)\nif 'weights' in cfg:\n- checkpoint.load_params(exe, eval_prog, cfg.weights)\n+ checkpoint.load_checkpoint(exe, eval_prog, cfg.weights)\nresults = eval_run(exe, compile_program, loader, keys, values, cls, cfg,\nsub_eval_prog, sub_keys, sub_values)\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "slim/prune/export_model.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+\n+from paddle import fluid\n+\n+from ppdet.core.workspace import load_config, merge_config, create\n+from ppdet.utils.cli import ArgsParser\n+import ppdet.utils.checkpoint as checkpoint\n+from paddleslim.prune import Pruner\n+from paddleslim.analysis import flops\n+\n+import logging\n+FORMAT = '%(asctime)s-%(levelname)s: %(message)s'\n+logging.basicConfig(level=logging.INFO, format=FORMAT)\n+logger = logging.getLogger(__name__)\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+ 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+\n+def main():\n+ cfg = load_config(FLAGS.config)\n+\n+ if 'architecture' in cfg:\n+ main_arch = cfg.architecture\n+ else:\n+ raise ValueError(\"'architecture' not specified in config file.\")\n+\n+ merge_config(FLAGS.opt)\n+\n+ # Use CPU for exporting inference model instead of GPU\n+ place = fluid.CPUPlace()\n+ exe = fluid.Executor(place)\n+\n+ model = create(main_arch)\n+\n+ startup_prog = fluid.Program()\n+ infer_prog = fluid.Program()\n+ with fluid.program_guard(infer_prog, startup_prog):\n+ with fluid.unique_name.guard():\n+ inputs_def = cfg['TestReader']['inputs_def']\n+ inputs_def['use_dataloader'] = False\n+ feed_vars, _ = model.build_inputs(**inputs_def)\n+ test_fetches = model.test(feed_vars)\n+ infer_prog = infer_prog.clone(True)\n+\n+ pruned_params = FLAGS.pruned_params\n+ assert (\n+ FLAGS.pruned_params is not None\n+ ), \"FLAGS.pruned_params is empty!!! Please set it by '--pruned_params' option.\"\n+ pruned_params = FLAGS.pruned_params.strip().split(\",\")\n+ logger.info(\"pruned params: {}\".format(pruned_params))\n+ pruned_ratios = [float(n) for n in FLAGS.pruned_ratios.strip().split(\",\")]\n+ logger.info(\"pruned ratios: {}\".format(pruned_ratios))\n+ assert (len(pruned_params) == len(pruned_ratios)\n+ ), \"The length of pruned params and pruned ratios should be equal.\"\n+ assert (pruned_ratios > [0] * len(pruned_ratios) and\n+ pruned_ratios < [1] * len(pruned_ratios)\n+ ), \"The elements of pruned ratios should be in range (0, 1).\"\n+\n+ base_flops = flops(infer_prog)\n+ pruner = Pruner()\n+ infer_prog, _, _ = pruner.prune(\n+ infer_prog,\n+ fluid.global_scope(),\n+ params=pruned_params,\n+ ratios=pruned_ratios,\n+ place=place,\n+ only_graph=True)\n+ pruned_flops = flops(infer_prog)\n+ logger.info(\"pruned FLOPS: {}\".format(\n+ float(base_flops - pruned_flops) / base_flops))\n+\n+ exe.run(startup_prog)\n+ checkpoint.load_checkpoint(exe, infer_prog, cfg.weights)\n+\n+ save_infer_model(FLAGS, exe, feed_vars, test_fetches, infer_prog)\n+\n+\n+if __name__ == '__main__':\n+ parser = ArgsParser()\n+ parser.add_argument(\n+ \"--output_dir\",\n+ type=str,\n+ default=\"output\",\n+ help=\"Directory for storing the output model files.\")\n+\n+ parser.add_argument(\n+ \"-p\",\n+ \"--pruned_params\",\n+ default=None,\n+ type=str,\n+ help=\"The parameters to be pruned when calculating sensitivities.\")\n+ parser.add_argument(\n+ \"--pruned_ratios\",\n+ default=None,\n+ type=str,\n+ help=\"The ratios pruned iteratively for each parameter when calculating sensitivities.\"\n+ )\n+\n+ FLAGS = parser.parse_args()\n+ main()\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | add prune export_model (#378) |
499,400 | 24.03.2020 11:34:10 | -28,800 | 3146ebe0f022f7e13c75fe481a748b610aefa7c3 | Fix loading checkpoint in eval script of pruning demo. | [
{
"change_type": "MODIFY",
"old_path": "slim/prune/eval.py",
"new_path": "slim/prune/eval.py",
"diff": "@@ -86,6 +86,7 @@ def main():\nfetches = model.eval(feed_vars, multi_scale_test)\neval_prog = eval_prog.clone(True)\n+ exe.run(startup_prog)\nreader = create_reader(cfg.EvalReader)\nloader.set_sample_list_generator(reader, place)\n@@ -123,7 +124,7 @@ def main():\nparams=pruned_params,\nratios=pruned_ratios,\nplace=place,\n- only_graph=True)\n+ only_graph=False)\npruned_flops = flops(eval_prog)\nlogger.info(\"pruned FLOPS: {}\".format(\nfloat(base_flops - pruned_flops) / base_flops))\n@@ -174,7 +175,6 @@ def main():\nsub_eval_prog = sub_eval_prog.clone(True)\n# load model\n- exe.run(startup_prog)\nif 'weights' in cfg:\ncheckpoint.load_checkpoint(exe, eval_prog, cfg.weights)\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Fix loading checkpoint in eval script of pruning demo. (#391) |
499,313 | 31.03.2020 14:35:22 | -28,800 | ca199f73d5d0fb8bc7b871387106fdd656b189e6 | fix downsample | [
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/architectures/yolov3.py",
"new_path": "ppdet/modeling/architectures/yolov3.py",
"diff": "@@ -121,7 +121,7 @@ class YOLOv3(object):\n-2] // downsample if image_shape[-2] else None\ntargets_def[k]['shape'][4] = image_shape[\n-1] // downsample if image_shape[-1] else None\n- downsample // 2\n+ downsample //= 2\ninputs_def.update(targets_def)\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix downsample (#420) |
499,333 | 02.04.2020 21:23:29 | -28,800 | f6d7d9a3a9aa2b350114d2dd300a486b307f905b | refine mask eval | [
{
"change_type": "MODIFY",
"old_path": "ppdet/utils/coco_eval.py",
"new_path": "ppdet/utils/coco_eval.py",
"diff": "@@ -105,7 +105,35 @@ def mask_eval(results, anno_file, outfile, resolution, thresh_binarize=0.5):\ncoco_gt = COCO(anno_file)\nclsid2catid = {i + 1: v for i, v in enumerate(coco_gt.getCatIds())}\n- segm_results = mask2out(results, clsid2catid, resolution, thresh_binarize)\n+ segm_results = []\n+ for t in results:\n+ im_ids = np.array(t['im_id'][0])\n+ bboxes = t['bbox'][0]\n+ lengths = t['bbox'][1][0]\n+ masks = t['mask']\n+ if bboxes.shape == (1, 1) or bboxes is None:\n+ continue\n+ if len(bboxes.tolist()) == 0:\n+ continue\n+ s = 0\n+ for i in range(len(lengths)):\n+ num = lengths[i]\n+ im_id = int(im_ids[i][0])\n+ clsid_scores = bboxes[s:s + num][:, 0:2]\n+ mask = masks[s:s + num]\n+ for j in range(num):\n+ clsid, score = clsid_scores[j].tolist()\n+ catid = int(clsid2catid[clsid])\n+ segm = mask[j]\n+ segm['counts'] = segm['counts'].decode('utf8')\n+ coco_res = {\n+ 'image_id': im_id,\n+ 'category_id': int(catid),\n+ 'segmentation': segm,\n+ 'score': score\n+ }\n+ segm_results.append(coco_res)\n+\nif len(segm_results) == 0:\nlogger.warning(\"The number of valid mask detected is zero.\\n \\\nPlease use reasonable model and check input data.\")\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/utils/eval_utils.py",
"new_path": "ppdet/utils/eval_utils.py",
"diff": "@@ -103,7 +103,8 @@ def eval_run(exe,\ncfg=None,\nsub_prog=None,\nsub_keys=None,\n- sub_values=None):\n+ sub_values=None,\n+ resolution=None):\n\"\"\"\nRun evaluation program, return program outputs.\n\"\"\"\n@@ -152,6 +153,9 @@ def eval_run(exe,\nif multi_scale_test:\nres = clean_res(\nres, ['im_info', 'bbox', 'im_id', 'im_shape', 'mask'])\n+ if 'mask' in res:\n+ from ppdet.utils.post_process import mask_encode\n+ res['mask'] = mask_encode(res, resolution)\nresults.append(res)\nif iter_id % 100 == 0:\nlogger.info('Test iter {}'.format(iter_id))\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/utils/post_process.py",
"new_path": "ppdet/utils/post_process.py",
"diff": "@@ -18,7 +18,7 @@ from __future__ import print_function\nimport logging\nimport numpy as np\n-\n+import cv2\nimport paddle.fluid as fluid\n__all__ = ['nms']\n@@ -210,3 +210,64 @@ def mstest_mask_post_process(result, cfg):\nmask_pred = np.mean(mask_list, axis=0)\nreturn {'mask': (mask_pred, [[len(mask_pred)]])}\n+\n+\n+def mask_encode(results, resolution, thresh_binarize=0.5):\n+ import pycocotools.mask as mask_util\n+ from ppdet.utils.coco_eval import expand_boxes\n+ scale = (resolution + 2.0) / resolution\n+ bboxes = results['bbox'][0]\n+ masks = results['mask'][0]\n+ lengths = results['mask'][1][0]\n+ im_shapes = results['im_shape'][0]\n+ segms = []\n+ if bboxes.shape == (1, 1) or bboxes is None:\n+ return segms\n+ if len(bboxes.tolist()) == 0:\n+ return segms\n+\n+ s = 0\n+ # for each sample\n+ for i in range(len(lengths)):\n+ num = lengths[i]\n+ im_shape = im_shapes[i]\n+\n+ bbox = bboxes[s:s + num][:, 2:]\n+ clsid_scores = bboxes[s:s + num][:, 0:2]\n+ mask = masks[s:s + num]\n+ s += num\n+\n+ im_h = int(im_shape[0])\n+ im_w = int(im_shape[1])\n+ expand_bbox = expand_boxes(bbox, scale)\n+ expand_bbox = expand_bbox.astype(np.int32)\n+ padded_mask = np.zeros(\n+ (resolution + 2, resolution + 2), dtype=np.float32)\n+\n+ for j in range(num):\n+ xmin, ymin, xmax, ymax = expand_bbox[j].tolist()\n+ clsid, score = clsid_scores[j].tolist()\n+ clsid = int(clsid)\n+ padded_mask[1:-1, 1:-1] = mask[j, clsid, :, :]\n+\n+ w = xmax - xmin + 1\n+ h = ymax - ymin + 1\n+ w = np.maximum(w, 1)\n+ h = np.maximum(h, 1)\n+ resized_mask = cv2.resize(padded_mask, (w, h))\n+ resized_mask = np.array(\n+ resized_mask > thresh_binarize, dtype=np.uint8)\n+ im_mask = np.zeros((im_h, im_w), dtype=np.uint8)\n+\n+ x0 = min(max(xmin, 0), im_w)\n+ x1 = min(max(xmax + 1, 0), im_w)\n+ y0 = min(max(ymin, 0), im_h)\n+ y1 = min(max(ymax + 1, 0), im_h)\n+\n+ im_mask[y0:y1, x0:x1] = resized_mask[(y0 - ymin):(y1 - ymin), (\n+ x0 - xmin):(x1 - xmin)]\n+ segm = mask_util.encode(\n+ np.array(\n+ im_mask[:, :, np.newaxis], order='F'))[0]\n+ segms.append(segm)\n+ return segms\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/eval.py",
"new_path": "tools/eval.py",
"diff": "@@ -152,14 +152,14 @@ def main():\nif 'weights' in cfg:\ncheckpoint.load_params(exe, startup_prog, cfg.weights)\n+ resolution = None\n+ if 'Mask' in cfg.architecture:\n+ resolution = model.mask_head.resolution\nresults = eval_run(exe, compile_program, loader, keys, values, cls, cfg,\n- sub_eval_prog, sub_keys, sub_values)\n+ sub_eval_prog, sub_keys, sub_values, resolution)\n#print(cfg['EvalReader']['dataset'].__dict__)\n# evaluation\n- resolution = None\n- if 'mask' in results[0]:\n- resolution = model.mask_head.resolution\n# if map_type not set, use default 11point, only use in VOC eval\nmap_type = cfg.map_type if 'map_type' in cfg else '11point'\neval_results(\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/train.py",
"new_path": "tools/train.py",
"diff": "@@ -262,11 +262,17 @@ def main():\nif FLAGS.eval:\n# evaluation\n- results = eval_run(exe, compiled_eval_prog, eval_loader,\n- eval_keys, eval_values, eval_cls)\nresolution = None\n- if 'mask' in results[0]:\n+ if 'Mask' in cfg.architecture:\nresolution = model.mask_head.resolution\n+ results = eval_run(\n+ exe,\n+ compiled_eval_prog,\n+ eval_loader,\n+ eval_keys,\n+ eval_values,\n+ eval_cls,\n+ resolution=resolution)\nbox_ap_stats = eval_results(\nresults, cfg.metric, cfg.num_classes, resolution,\nis_bbox_normalized, FLAGS.output_eval, map_type,\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | refine mask eval (#430) |
499,313 | 04.04.2020 12:21:40 | -28,800 | 2866aa3da6d48e42c3b599610ecbbf3159e29086 | fix sensitive import | [
{
"change_type": "MODIFY",
"old_path": "slim/sensitive/sensitive.py",
"new_path": "slim/sensitive/sensitive.py",
"diff": "@@ -38,7 +38,6 @@ set_paddle_flags(\nfrom paddle import fluid\nfrom ppdet.experimental import mixed_precision_context\nfrom ppdet.core.workspace import load_config, merge_config, create\n-#from ppdet.data.data_feed import create_reader\nfrom ppdet.data.reader import create_reader\n@@ -49,7 +48,6 @@ from ppdet.utils.stats import TrainingStats\nfrom ppdet.utils.cli import ArgsParser\nfrom ppdet.utils.check import check_gpu, check_version\nimport ppdet.utils.checkpoint as checkpoint\n-from ppdet.modeling.model_input import create_feed\nfrom paddleslim.prune import sensitivity\nimport logging\nFORMAT = '%(asctime)s-%(levelname)s: %(message)s'\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix sensitive import (#441) |
499,304 | 04.04.2020 14:22:42 | -28,800 | c06f1ea03684d5a938c095573011864269013985 | add mobilenetvs & ssdlite | [
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/backbones/__init__.py",
"new_path": "ppdet/modeling/backbones/__init__.py",
"diff": "@@ -18,6 +18,7 @@ from . import resnet\nfrom . import resnext\nfrom . import darknet\nfrom . import mobilenet\n+from . import mobilenet_v3\nfrom . import senet\nfrom . import fpn\nfrom . import vgg\n@@ -33,6 +34,7 @@ from .resnet import *\nfrom .resnext import *\nfrom .darknet import *\nfrom .mobilenet import *\n+from .mobilenet_v3 import *\nfrom .senet import *\nfrom .fpn import *\nfrom .vgg import *\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "ppdet/modeling/backbones/mobilenet_v3.py",
"diff": "+import paddle.fluid as fluid\n+from paddle.fluid.param_attr import ParamAttr\n+from paddle.fluid.regularizer import L2Decay\n+\n+from ppdet.core.workspace import register\n+import math\n+\n+__all__ = ['MobileNetV3']\n+\n+\n+@register\n+class MobileNetV3():\n+ def __init__(self,\n+ scale=1.0,\n+ model_name='small',\n+ with_extra_blocks=False,\n+ conv_decay=0.0,\n+ bn_decay=0.0,\n+ extra_block_filters=[[256, 512], [128, 256], [128, 256],\n+ [64, 128]]):\n+ self.scale = scale\n+ self.model_name = model_name\n+ self.with_extra_blocks = with_extra_blocks\n+ self.extra_block_filters = extra_block_filters\n+ self.conv_decay = conv_decay\n+ self.bn_decay = bn_decay\n+ self.inplanes = 16\n+ self.end_points = []\n+ self.block_stride = 1\n+ if model_name == \"large\":\n+ self.cfg = [\n+ # kernel_size, expand, channel, se_block, act_mode, stride\n+ [3, 16, 16, False, 'relu', 1],\n+ [3, 64, 24, False, 'relu', 2],\n+ [3, 72, 24, False, 'relu', 1],\n+ [5, 72, 40, True, 'relu', 2],\n+ [5, 120, 40, True, 'relu', 1],\n+ [5, 120, 40, True, 'relu', 1],\n+ [3, 240, 80, False, 'hard_swish', 2],\n+ [3, 200, 80, False, 'hard_swish', 1],\n+ [3, 184, 80, False, 'hard_swish', 1],\n+ [3, 184, 80, False, 'hard_swish', 1],\n+ [3, 480, 112, True, 'hard_swish', 1],\n+ [3, 672, 112, True, 'hard_swish', 1],\n+ [5, 672, 160, True, 'hard_swish', 2],\n+ [5, 960, 160, True, 'hard_swish', 1],\n+ [5, 960, 160, True, 'hard_swish', 1],\n+ ]\n+ elif model_name == \"small\":\n+ self.cfg = [\n+ # kernel_size, expand, channel, se_block, act_mode, stride\n+ [3, 16, 16, True, 'relu', 2],\n+ [3, 72, 24, False, 'relu', 2],\n+ [3, 88, 24, False, 'relu', 1],\n+ [5, 96, 40, True, 'hard_swish', 2],\n+ [5, 240, 40, True, 'hard_swish', 1],\n+ [5, 240, 40, True, 'hard_swish', 1],\n+ [5, 120, 48, True, 'hard_swish', 1],\n+ [5, 144, 48, True, 'hard_swish', 1],\n+ [5, 288, 96, True, 'hard_swish', 2],\n+ [5, 576, 96, True, 'hard_swish', 1],\n+ [5, 576, 96, True, 'hard_swish', 1],\n+ ]\n+ else:\n+ raise NotImplementedError\n+\n+ def _conv_bn_layer(self,\n+ input,\n+ filter_size,\n+ num_filters,\n+ stride,\n+ padding,\n+ num_groups=1,\n+ if_act=True,\n+ act=None,\n+ name=None,\n+ use_cudnn=True):\n+ conv_param_attr = ParamAttr(\n+ name=name + '_weights', regularizer=L2Decay(self.conv_decay))\n+ conv = fluid.layers.conv2d(\n+ input=input,\n+ num_filters=num_filters,\n+ filter_size=filter_size,\n+ stride=stride,\n+ padding=padding,\n+ groups=num_groups,\n+ act=None,\n+ use_cudnn=use_cudnn,\n+ param_attr=conv_param_attr,\n+ bias_attr=False)\n+ bn_name = name + '_bn'\n+ bn_param_attr = ParamAttr(\n+ name=bn_name + \"_scale\", regularizer=L2Decay(self.bn_decay))\n+ bn_bias_attr = ParamAttr(\n+ name=bn_name + \"_offset\", regularizer=L2Decay(self.bn_decay))\n+ bn = fluid.layers.batch_norm(\n+ input=conv,\n+ param_attr=bn_param_attr,\n+ bias_attr=bn_bias_attr,\n+ moving_mean_name=bn_name + '_mean',\n+ moving_variance_name=bn_name + '_variance')\n+ if if_act:\n+ if act == 'relu':\n+ bn = fluid.layers.relu(bn)\n+ elif act == 'hard_swish':\n+ bn = self._hard_swish(bn)\n+ elif act == 'relu6':\n+ bn = fluid.layers.relu6(bn)\n+ return bn\n+\n+ def _hard_swish(self, x):\n+ return x * fluid.layers.relu6(x + 3) / 6.\n+\n+ def _se_block(self, input, num_out_filter, ratio=4, name=None):\n+ num_mid_filter = int(num_out_filter // ratio)\n+ pool = fluid.layers.pool2d(\n+ input=input, pool_type='avg', global_pooling=True, use_cudnn=False)\n+ conv1 = fluid.layers.conv2d(\n+ input=pool,\n+ filter_size=1,\n+ num_filters=num_mid_filter,\n+ act='relu',\n+ param_attr=ParamAttr(name=name + '_1_weights'),\n+ bias_attr=ParamAttr(name=name + '_1_offset'))\n+ conv2 = fluid.layers.conv2d(\n+ input=conv1,\n+ filter_size=1,\n+ num_filters=num_out_filter,\n+ act='hard_sigmoid',\n+ param_attr=ParamAttr(name=name + '_2_weights'),\n+ bias_attr=ParamAttr(name=name + '_2_offset'))\n+\n+ scale = fluid.layers.elementwise_mul(x=input, y=conv2, axis=0)\n+ return scale\n+\n+ def _residual_unit(self,\n+ input,\n+ num_in_filter,\n+ num_mid_filter,\n+ num_out_filter,\n+ stride,\n+ filter_size,\n+ act=None,\n+ use_se=False,\n+ name=None):\n+ input_data = input\n+ conv0 = self._conv_bn_layer(\n+ input=input,\n+ filter_size=1,\n+ num_filters=num_mid_filter,\n+ stride=1,\n+ padding=0,\n+ if_act=True,\n+ act=act,\n+ name=name + '_expand')\n+ if self.block_stride == 16 and stride == 2:\n+ self.end_points.append(conv0)\n+ conv1 = self._conv_bn_layer(\n+ input=conv0,\n+ filter_size=filter_size,\n+ num_filters=num_mid_filter,\n+ stride=stride,\n+ padding=int((filter_size - 1) // 2),\n+ if_act=True,\n+ act=act,\n+ num_groups=num_mid_filter,\n+ use_cudnn=False,\n+ name=name + '_depthwise')\n+\n+ if use_se:\n+ conv1 = self._se_block(\n+ input=conv1, num_out_filter=num_mid_filter, name=name + '_se')\n+\n+ conv2 = self._conv_bn_layer(\n+ input=conv1,\n+ filter_size=1,\n+ num_filters=num_out_filter,\n+ stride=1,\n+ padding=0,\n+ if_act=False,\n+ name=name + '_linear')\n+ if num_in_filter != num_out_filter or stride != 1:\n+ return conv2\n+ else:\n+ return fluid.layers.elementwise_add(x=input_data, y=conv2, act=None)\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+ padding=\"SAME\",\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+ padding=\"SAME\",\n+ num_groups=int(num_filters1),\n+ act='relu6',\n+ use_cudnn=False,\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+ padding=\"SAME\",\n+ act='relu6',\n+ name=name + \"_extra2_sep\")\n+ return normal_conv\n+\n+ def __call__(self, input):\n+ scale = self.scale\n+ inplanes = self.inplanes\n+ cfg = self.cfg\n+ blocks = []\n+\n+ #conv1\n+ conv = self._conv_bn_layer(\n+ input,\n+ filter_size=3,\n+ num_filters=inplanes if scale <= 1.0 else int(inplanes * scale),\n+ stride=2,\n+ padding=1,\n+ num_groups=1,\n+ if_act=True,\n+ act='hard_swish',\n+ name='conv1')\n+ i = 0\n+ for layer_cfg in cfg:\n+ self.block_stride *= layer_cfg[5]\n+ conv = self._residual_unit(\n+ input=conv,\n+ num_in_filter=inplanes,\n+ num_mid_filter=int(scale * layer_cfg[1]),\n+ num_out_filter=int(scale * layer_cfg[2]),\n+ act=layer_cfg[4],\n+ stride=layer_cfg[5],\n+ filter_size=layer_cfg[0],\n+ use_se=layer_cfg[3],\n+ name='conv' + str(i + 2))\n+ inplanes = int(scale * layer_cfg[2])\n+ i += 1\n+\n+ if not self.with_extra_blocks:\n+ return conv\n+\n+ # extra block\n+ conv_extra = self._conv_bn_layer(\n+ conv,\n+ filter_size=1,\n+ num_filters=int(scale * cfg[-1][1]),\n+ stride=1,\n+ padding=\"SAME\",\n+ num_groups=1,\n+ if_act=True,\n+ act='hard_swish',\n+ name='conv' + str(i + 2))\n+ self.end_points.append(conv_extra)\n+ i += 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(i + 2))\n+ self.end_points.append(conv_extra)\n+ i += 1\n+\n+ return self.end_points\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/ops.py",
"new_path": "ppdet/modeling/ops.py",
"diff": "import numpy as np\nfrom numbers import Integral\n+import math\n+import six\nfrom paddle import fluid\nfrom paddle.fluid.param_attr import ParamAttr\n@@ -24,8 +26,9 @@ from ppdet.utils.bbox_utils import bbox_overlaps, box_to_delta\n__all__ = [\n'AnchorGenerator', 'DropBlock', 'RPNTargetAssign', 'GenerateProposals',\n'MultiClassNMS', 'BBoxAssigner', 'MaskAssigner', 'RoIAlign', 'RoIPool',\n- 'MultiBoxHead', 'SSDOutputDecoder', 'RetinaTargetAssign',\n- 'RetinaOutputDecoder', 'ConvNorm', 'MultiClassSoftNMS', 'LibraBBoxAssigner'\n+ 'MultiBoxHead', 'SSDLiteMultiBoxHead', 'SSDOutputDecoder',\n+ 'RetinaTargetAssign', 'RetinaOutputDecoder', 'ConvNorm',\n+ 'MultiClassSoftNMS', 'LibraBBoxAssigner'\n]\n@@ -1064,6 +1067,155 @@ class MultiBoxHead(object):\nself.pad = pad\n+@register\n+@serializable\n+class SSDLiteMultiBoxHead(object):\n+ def __init__(self,\n+ min_ratio=20,\n+ max_ratio=90,\n+ base_size=300,\n+ min_sizes=None,\n+ max_sizes=None,\n+ aspect_ratios=[[2.], [2., 3.], [2., 3.], [2., 3.], [2., 3.],\n+ [2., 3.]],\n+ steps=None,\n+ offset=0.5,\n+ flip=True,\n+ clip=False,\n+ pad=0,\n+ conv_decay=0.0):\n+ super(SSDLiteMultiBoxHead, self).__init__()\n+ self.min_ratio = min_ratio\n+ self.max_ratio = max_ratio\n+ self.base_size = base_size\n+ self.min_sizes = min_sizes\n+ self.max_sizes = max_sizes\n+ self.aspect_ratios = aspect_ratios\n+ self.steps = steps\n+ self.offset = offset\n+ self.flip = flip\n+ self.pad = pad\n+ self.clip = clip\n+ self.conv_decay = conv_decay\n+\n+ def _separable_conv(self, input, num_filters, name):\n+ dwconv_param_attr = ParamAttr(\n+ name=name + 'dw_weights', regularizer=L2Decay(self.conv_decay))\n+ num_filter1 = input.shape[1]\n+ depthwise_conv = fluid.layers.conv2d(\n+ input=input,\n+ num_filters=num_filter1,\n+ filter_size=3,\n+ stride=1,\n+ padding=\"SAME\",\n+ groups=int(num_filter1),\n+ act=None,\n+ use_cudnn=False,\n+ param_attr=dwconv_param_attr,\n+ bias_attr=False)\n+ bn_name = name + '_bn'\n+ bn_param_attr = ParamAttr(\n+ name=bn_name + \"_scale\", regularizer=L2Decay(0.0))\n+ bn_bias_attr = ParamAttr(\n+ name=bn_name + \"_offset\", regularizer=L2Decay(0.0))\n+ bn = fluid.layers.batch_norm(\n+ input=depthwise_conv,\n+ param_attr=bn_param_attr,\n+ bias_attr=bn_bias_attr,\n+ moving_mean_name=bn_name + '_mean',\n+ moving_variance_name=bn_name + '_variance')\n+ bn = fluid.layers.relu6(bn)\n+ pwconv_param_attr = ParamAttr(\n+ name=name + 'pw_weights', regularizer=L2Decay(self.conv_decay))\n+ pointwise_conv = fluid.layers.conv2d(\n+ input=bn,\n+ num_filters=num_filters,\n+ filter_size=1,\n+ stride=1,\n+ act=None,\n+ use_cudnn=True,\n+ param_attr=pwconv_param_attr,\n+ bias_attr=False)\n+ return pointwise_conv\n+\n+ def __call__(self, inputs, image, num_classes):\n+ def _permute_and_reshape(input, last_dim):\n+ trans = fluid.layers.transpose(input, perm=[0, 2, 3, 1])\n+ compile_shape = [0, -1, last_dim]\n+ return fluid.layers.reshape(trans, shape=compile_shape)\n+\n+ def _is_list_or_tuple_(data):\n+ return (isinstance(data, list) or isinstance(data, tuple))\n+\n+ if self.min_sizes is None and self.max_sizes is None:\n+ num_layer = len(inputs)\n+ self.min_sizes = []\n+ self.max_sizes = []\n+ step = int(\n+ math.floor(((self.max_ratio - self.min_ratio)) / (num_layer - 2\n+ )))\n+ for ratio in six.moves.range(self.min_ratio, self.max_ratio + 1,\n+ step):\n+ self.min_sizes.append(self.base_size * ratio / 100.)\n+ self.max_sizes.append(self.base_size * (ratio + step) / 100.)\n+ self.min_sizes = [self.base_size * .10] + self.min_sizes\n+ self.max_sizes = [self.base_size * .20] + self.max_sizes\n+\n+ locs, confs = [], []\n+ boxes, mvars = [], []\n+\n+ for i, input in enumerate(inputs):\n+ min_size = self.min_sizes[i]\n+ max_size = self.max_sizes[i]\n+ if not _is_list_or_tuple_(min_size):\n+ min_size = [min_size]\n+ if not _is_list_or_tuple_(max_size):\n+ max_size = [max_size]\n+ step = [\n+ self.steps[i] if self.steps else 0.0, self.steps[i]\n+ if self.steps else 0.0\n+ ]\n+ box, var = fluid.layers.prior_box(\n+ input,\n+ image,\n+ min_sizes=min_size,\n+ max_sizes=max_size,\n+ steps=step,\n+ aspect_ratios=self.aspect_ratios[i],\n+ variance=[0.1, 0.1, 0.2, 0.2],\n+ clip=self.clip,\n+ flip=self.flip,\n+ offset=0.5)\n+\n+ num_boxes = box.shape[2]\n+ box = fluid.layers.reshape(box, shape=[-1, 4])\n+ var = fluid.layers.reshape(var, shape=[-1, 4])\n+ num_loc_output = num_boxes * 4\n+ num_conf_output = num_boxes * num_classes\n+ # get loc\n+ mbox_loc = self._separable_conv(input, num_loc_output,\n+ \"loc_{}\".format(i + 1))\n+ loc = _permute_and_reshape(mbox_loc, 4)\n+ # get conf\n+ mbox_conf = self._separable_conv(input, num_conf_output,\n+ \"conf_{}\".format(i + 1))\n+ conf = _permute_and_reshape(mbox_conf, num_classes)\n+\n+ locs.append(loc)\n+ confs.append(conf)\n+ boxes.append(box)\n+ mvars.append(var)\n+\n+ ssd_mbox_loc = fluid.layers.concat(locs, axis=1)\n+ ssd_mbox_conf = fluid.layers.concat(confs, axis=1)\n+ prior_boxes = fluid.layers.concat(boxes)\n+ box_vars = fluid.layers.concat(mvars)\n+\n+ prior_boxes.stop_gradient = True\n+ box_vars.stop_gradient = True\n+ return ssd_mbox_loc, ssd_mbox_conf, prior_boxes, box_vars\n+\n+\n@register\n@serializable\nclass SSDOutputDecoder(object):\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | add mobilenetvs & ssdlite (#439) |
499,313 | 07.04.2020 12:38:37 | -28,800 | 365082f2100d95e52c4a0d1164aa6c29f2558ff5 | fix killpg | [
{
"change_type": "MODIFY",
"old_path": "ppdet/data/parallel_map.py",
"new_path": "ppdet/data/parallel_map.py",
"diff": "@@ -35,6 +35,8 @@ import traceback\nlogger = logging.getLogger(__name__)\n+worker_set = set()\n+\nclass EndSignal(object):\n\"\"\" signal used to notify worker to exit\n@@ -120,6 +122,7 @@ class ParallelMap(object):\nself._consumers = []\nself._consumer_endsig = {}\n+ global worker_set\nfor i in range(consumer_num):\nconsumer_id = 'consumer-' + id + '-' + str(i)\np = Worker(\n@@ -128,6 +131,7 @@ class ParallelMap(object):\nself._consumers.append(p)\np.daemon = True\nsetattr(p, 'id', consumer_id)\n+ worker_set.add(p)\nself._epoch = -1\nself._feeding_ev = Event()\n@@ -279,16 +283,17 @@ class ParallelMap(object):\nself._feeding_ev.set()\n-# FIXME(dengkaipeng): fix me if you have better impliment\n+# FIXME: fix me if you have better impliment\n# handle terminate reader process, do not print stack frame\nsignal.signal(signal.SIGTERM, lambda signum, frame: sys.exit())\n-def _term_group(sig_num, frame):\n- pid = os.getpid()\n- pg = os.getpgid(os.getpid())\n- logger.info(\"main proc {} exit, kill process group \" \"{}\".format(pid, pg))\n- os.killpg(pg, signal.SIGKILL)\n+def _term_workers(sig_num, frame):\n+ global worker_set\n+ logger.info(\"main proc {} exit, kill subprocess {}\".format(\n+ pid, [w.pid for w in worker_set]))\n+ for w in worker_set:\n+ os.kill(w, signal.SIGKILL)\n-signal.signal(signal.SIGINT, _term_group)\n+signal.signal(signal.SIGINT, _term_workers)\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix killpg (#450) |
499,406 | 08.04.2020 13:45:52 | -28,800 | ed24ab2906f5120296ae029a15240276a299926d | add profiler tools | [
{
"change_type": "MODIFY",
"old_path": "tools/train.py",
"new_path": "tools/train.py",
"diff": "@@ -22,6 +22,7 @@ import numpy as np\nimport random\nimport datetime\nfrom collections import deque\n+from paddle.fluid import profiler\ndef set_paddle_flags(**kwargs):\n@@ -256,6 +257,13 @@ def main():\nit, np.mean(outs[-1]), logs, time_cost, eta)\nlogger.info(strs)\n+ # NOTE : profiler tools, used for benchmark\n+ if FLAGS.is_profiler and it == 5:\n+ profiler.start_profiler(\"All\")\n+ elif FLAGS.is_profiler and it == 10:\n+ profiler.stop_profiler(\"total\", FLAGS.profiler_path)\n+ return\n+\nif (it > 0 and it % cfg.snapshot_iter == 0 or it == cfg.max_iters - 1) \\\nand (not FLAGS.dist or trainer_id == 0):\n@@ -340,5 +348,17 @@ if __name__ == '__main__':\ndefault=False,\nhelp=\"If set True, enable continuous evaluation job.\"\n\"This flag is only used for internal test.\")\n+\n+ #NOTE:args for profiler tools, used for benchmark\n+ parser.add_argument(\n+ '--is_profiler',\n+ type=int,\n+ default=0,\n+ help='The switch of profiler tools. (used for benchmark)')\n+ parser.add_argument(\n+ '--profiler_path',\n+ type=str,\n+ default=\"./detection.profiler\",\n+ help='The profiler output file path. (used for benchmark)')\nFLAGS = parser.parse_args()\nmain()\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | add profiler tools (#377) |
499,313 | 08.04.2020 19:21:32 | -28,800 | 063e9b206979d1500dd0c68af6f4d3ac327a0e64 | fix threads not exit on ctrl+c | [
{
"change_type": "MODIFY",
"old_path": "ppdet/data/parallel_map.py",
"new_path": "ppdet/data/parallel_map.py",
"diff": "@@ -35,6 +35,7 @@ import traceback\nlogger = logging.getLogger(__name__)\n+main_pid = os.getpid()\nworker_set = set()\n@@ -131,6 +132,7 @@ class ParallelMap(object):\nself._consumers.append(p)\np.daemon = True\nsetattr(p, 'id', consumer_id)\n+ if use_process:\nworker_set.add(p)\nself._epoch = -1\n@@ -288,12 +290,22 @@ class ParallelMap(object):\nsignal.signal(signal.SIGTERM, lambda signum, frame: sys.exit())\n+# FIXME(dkp): KeyboardInterrupt should be handled inside ParallelMap\n+# and do such as: 1. exit workers 2. close queues 3. release shared\n+# memory, HACK KeyboardInterrupt with global signal.SIGINT handler\n+# here, should be refined later\ndef _term_workers(sig_num, frame):\n- global worker_set\n- logger.info(\"main proc {} exit, kill subprocess {}\".format(\n- pid, [w.pid for w in worker_set]))\n+ global worker_set, main_pid\n+ # only do subporcess killing in main process\n+ if os.getpid() != main_pid:\n+ return\n+\n+ logger.info(\"KeyboardInterrupt: main proc {} exit, kill subprocess {}\" \\\n+ .format(os.getpid(), [w.pid for w in worker_set]))\nfor w in worker_set:\n- os.kill(w, signal.SIGKILL)\n+ if w.pid is not None:\n+ os.kill(w.pid, signal.SIGINT)\n+ sys.exit()\nsignal.signal(signal.SIGINT, _term_workers)\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix threads not exit on ctrl+c (#463) |
499,313 | 10.04.2020 10:54:41 | -28,800 | 3fa01f104d627b7d7b1e411fe8391479204e569d | fix yolov3_enhance_reader EvalReader | [
{
"change_type": "MODIFY",
"old_path": "configs/dcn/yolov3_enhance_reader.yml",
"new_path": "configs/dcn/yolov3_enhance_reader.yml",
"diff": "@@ -70,6 +70,8 @@ EvalReader:\nstd: [0.229, 0.224, 0.225]\nis_scale: False\nis_channel_first: false\n+ - !PadBox\n+ num_max_boxes: 50\n- !Permute\nto_bgr: false\nchannel_first: True\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix yolov3_enhance_reader EvalReader (#473) |
499,304 | 11.04.2020 11:37:29 | -28,800 | 763a8f2dff407fd2d560b41c76354712ec056748 | fix windows python path | [
{
"change_type": "MODIFY",
"old_path": "docs/tutorials/INSTALL.md",
"new_path": "docs/tutorials/INSTALL.md",
"diff": "@@ -86,14 +86,21 @@ Required python packages are specified in [requirements.txt](https://github.com/\npip install -r requirements.txt\n```\n-**Make sure the tests pass:**\n+**Specify the current Python path:**\n+```shell\n+# In Linux/Mac\n+export PYTHONPATH=$PYTHONPATH:.\n+# In windows\n+set PYTHONPATH=%PYTHONPATH%;.\n```\n-export PYTHONPATH=`pwd`:$PYTHONPATH\n+\n+**Make sure the tests pass:**\n+\n+```shell\npython ppdet/modeling/tests/test_architectures.py\n```\n-\n## Datasets\nPaddleDetection includes support for [COCO](http://cocodataset.org) and [Pascal VOC](http://host.robots.ox.ac.uk/pascal/VOC/) by default, please follow these instructions to set up the dataset.\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix windows python path (#480) |
499,333 | 14.04.2020 16:04:43 | -28,800 | d5a5fa4b30fcdd15cff1a47b53cf96296b15cbf5 | fix mask eval | [
{
"change_type": "MODIFY",
"old_path": "ppdet/utils/coco_eval.py",
"new_path": "ppdet/utils/coco_eval.py",
"diff": "@@ -121,6 +121,7 @@ def mask_eval(results, anno_file, outfile, resolution, thresh_binarize=0.5):\nim_id = int(im_ids[i][0])\nclsid_scores = bboxes[s:s + num][:, 0:2]\nmask = masks[s:s + num]\n+ s += num\nfor j in range(num):\nclsid, score = clsid_scores[j].tolist()\ncatid = int(clsid2catid[clsid])\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix mask eval (#498) |
499,304 | 15.04.2020 20:05:21 | -28,800 | d103a9f83a84be9c2945a59b061e6bd1753ba759 | fix quant train prog | [
{
"change_type": "MODIFY",
"old_path": "slim/quantization/train.py",
"new_path": "slim/quantization/train.py",
"diff": "@@ -59,6 +59,10 @@ def load_global_step(exe, prog, path):\ndef main():\n+ if FLAGS.eval is False:\n+ raise ValueError(\n+ \"Currently only supports `--eval==True` while training in `quantization`.\"\n+ )\nenv = os.environ\nFLAGS.dist = 'PADDLE_TRAINER_ID' in env and 'PADDLE_TRAINERS_NUM' in env\nif FLAGS.dist:\n@@ -202,7 +206,6 @@ def main():\nif FLAGS.eval:\n# insert quantize op in eval_prog\neval_prog = quant_aware(eval_prog, place, config, for_test=True)\n-\ncompiled_eval_prog = fluid.compiler.CompiledProgram(eval_prog)\nstart_iter = 0\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix quant train prog (#509) |
499,304 | 16.04.2020 11:33:13 | -28,800 | f8bc467346c4ae5b82d8c15e74598516839c1aed | Set MobileNetV3 `feature_maps` parameter | [
{
"change_type": "MODIFY",
"old_path": "configs/ssd/ssdlite_mobilenet_v3_large.yml",
"new_path": "configs/ssd/ssdlite_mobilenet_v3_large.yml",
"diff": "@@ -26,8 +26,8 @@ MobileNetV3:\nscale: 1.0\nmodel_name: large\nextra_block_filters: [[256, 512], [128, 256], [128, 256], [64, 128]]\n- with_extra_blocks: true\nconv_decay: 0.00004\n+ feature_maps: [5, 7, 8, 9, 10, 11]\nSSDLiteMultiBoxHead:\naspect_ratios: [[2.], [2., 3.], [2., 3.], [2., 3.], [2., 3.], [2., 3.]]\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/ssd/ssdlite_mobilenet_v3_small.yml",
"new_path": "configs/ssd/ssdlite_mobilenet_v3_small.yml",
"diff": "@@ -26,8 +26,8 @@ MobileNetV3:\nscale: 1.0\nmodel_name: small\nextra_block_filters: [[256, 512], [128, 256], [128, 256], [64, 128]]\n- with_extra_blocks: true\nconv_decay: 0.00004\n+ feature_maps: [5, 7, 8, 9, 10, 11]\nSSDLiteMultiBoxHead:\naspect_ratios: [[2.], [2., 3.], [2., 3.], [2., 3.], [2., 3.], [2., 3.]]\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/yolov3_mobilenet_v3.yml",
"new_path": "configs/yolov3_mobilenet_v3.yml",
"diff": "@@ -19,7 +19,7 @@ MobileNetV3:\nnorm_decay: 0.\nmodel_name: large\nscale: 1.\n- with_extra_blocks: false\n+ feature_maps: [1, 2, 3, 4, 6]\nYOLOv3Head:\nanchor_masks: [[6, 7, 8], [3, 4, 5], [0, 1, 2]]\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/backbones/mobilenet_v3.py",
"new_path": "ppdet/modeling/backbones/mobilenet_v3.py",
"diff": "# See the License for the specific language governing permissions and\n# limitations under the License.\n+from __future__ import absolute_import\n+from __future__ import division\n+from __future__ import print_function\n+\n+from collections import OrderedDict\n+\nimport paddle.fluid as fluid\nfrom paddle.fluid.param_attr import ParamAttr\nfrom paddle.fluid.regularizer import L2Decay\nfrom ppdet.core.workspace import register\n-import math\n+from numbers import Integral\n__all__ = ['MobileNetV3']\n@@ -32,7 +38,7 @@ class MobileNetV3():\nnorm_type (str): normalization type, 'bn' and 'sync_bn' are supported.\nnorm_decay (float): weight decay for normalization layer weights.\nconv_decay (float): weight decay for convolution layer weights.\n- with_extra_blocks (bool): if extra blocks should be added.\n+ feature_maps (list): index of stages whose feature maps are returned.\nextra_block_filters (list): number of filter for each extra block.\n\"\"\"\n__shared__ = ['norm_type']\n@@ -40,21 +46,24 @@ class MobileNetV3():\ndef __init__(self,\nscale=1.0,\nmodel_name='small',\n- with_extra_blocks=False,\n+ feature_maps=[5, 6, 7, 8, 9, 10],\nconv_decay=0.0,\nnorm_type='bn',\nnorm_decay=0.0,\nextra_block_filters=[[256, 512], [128, 256], [128, 256],\n[64, 128]]):\n+ if isinstance(feature_maps, Integral):\n+ feature_maps = [feature_maps]\n+\nself.scale = scale\nself.model_name = model_name\n- self.with_extra_blocks = with_extra_blocks\n+ self.feature_maps = feature_maps\nself.extra_block_filters = extra_block_filters\nself.conv_decay = conv_decay\nself.norm_decay = norm_decay\nself.inplanes = 16\nself.end_points = []\n- self.block_stride = 1\n+ self.block_stride = 0\nif model_name == \"large\":\nself.cfg = [\n# kernel_size, expand, channel, se_block, act_mode, stride\n@@ -181,8 +190,11 @@ class MobileNetV3():\nif_act=True,\nact=act,\nname=name + '_expand')\n- if self.block_stride == 16 and stride == 2:\n+ if self.block_stride == 4 and stride == 2:\n+ self.block_stride += 1\n+ if self.block_stride in self.feature_maps:\nself.end_points.append(conv0)\n+\nconv1 = self._conv_bn_layer(\ninput=conv0,\nfilter_size=filter_size,\n@@ -265,9 +277,11 @@ class MobileNetV3():\nname='conv1')\ni = 0\nfor layer_cfg in cfg:\n- self.block_stride *= layer_cfg[5]\nif layer_cfg[5] == 2:\n- blocks.append(conv)\n+ self.block_stride += 1\n+ if self.block_stride in self.feature_maps:\n+ self.end_points.append(conv)\n+\nconv = self._residual_unit(\ninput=conv,\nnum_in_filter=inplanes,\n@@ -280,10 +294,9 @@ class MobileNetV3():\nname='conv' + str(i + 2))\ninplanes = int(scale * layer_cfg[2])\ni += 1\n- blocks.append(conv)\n-\n- if not self.with_extra_blocks:\n- return blocks\n+ self.block_stride += 1\n+ if self.block_stride in self.feature_maps:\n+ self.end_points.append(conv)\n# extra block\nconv_extra = self._conv_bn_layer(\n@@ -296,13 +309,18 @@ class MobileNetV3():\nif_act=True,\nact='hard_swish',\nname='conv' + str(i + 2))\n+ self.block_stride += 1\n+ if self.block_stride in self.feature_maps:\nself.end_points.append(conv_extra)\ni += 1\nfor block_filter in self.extra_block_filters:\nconv_extra = self._extra_block_dw(conv_extra, block_filter[0],\nblock_filter[1], 2,\n'conv' + str(i + 2))\n+ self.block_stride += 1\n+ if self.block_stride in self.feature_maps:\nself.end_points.append(conv_extra)\ni += 1\n- return self.end_points\n+ return OrderedDict([('mbv3_{}'.format(idx), feat)\n+ for idx, feat in enumerate(self.end_points)])\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Set MobileNetV3 `feature_maps` parameter (#515) |
499,304 | 20.04.2020 15:11:50 | -28,800 | 003f265719c0e81b7662e6e1763330dd238a2f66 | fix inference vis.py py2 encoding | [
{
"change_type": "MODIFY",
"old_path": "inference/tools/vis.py",
"new_path": "inference/tools/vis.py",
"diff": "@@ -20,6 +20,7 @@ import gflags\nimport numpy as np\nimport json\nfrom PIL import Image, ImageDraw, ImageFont\n+import io\nFlags = gflags.FLAGS\ngflags.DEFINE_string('img_path', 'abc', 'image path')\n@@ -80,7 +81,7 @@ if __name__ == \"__main__\":\nimg = cv2.imread(Flags.img_path)\nimg = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\nclass2LabelMap = dict()\n- with open(Flags.c2l_path, \"r\", encoding=\"utf-8\") as json_f:\n+ with io.open(Flags.c2l_path, \"r\", encoding=\"utf-8\") as json_f:\nclass2LabelMap = json.load(json_f)\nfor box in detection_result.detection_boxes:\nif box.score >= Flags.threshold:\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix inference vis.py py2 encoding (#522) |
499,385 | 22.04.2020 23:01:11 | -28,800 | cbddf331f472df52801d421262ffa84765ba9a1a | Fix bug in class_aware_sampling | [
{
"change_type": "MODIFY",
"old_path": "ppdet/data/reader.py",
"new_path": "ppdet/data/reader.py",
"diff": "@@ -279,7 +279,7 @@ class Reader(object):\nself.indexes = np.random.choice(\nself._sample_num,\nself._sample_num,\n- replace=False,\n+ replace=True,\np=self.img_weights)\nif self._shuffle:\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/train.py",
"new_path": "tools/train.py",
"diff": "@@ -43,7 +43,6 @@ from ppdet.experimental import mixed_precision_context\nfrom ppdet.core.workspace import load_config, merge_config, create\nfrom ppdet.data.reader import create_reader\n-from ppdet.utils.cli import print_total_cfg\nfrom ppdet.utils import dist_utils\nfrom ppdet.utils.eval_utils import parse_fetches, eval_run, eval_results\nfrom ppdet.utils.stats import TrainingStats\n@@ -85,8 +84,6 @@ def main():\ncheck_gpu(cfg.use_gpu)\n# check if paddlepaddle version is satisfied\ncheck_version()\n- if not FLAGS.dist or trainer_id == 0:\n- print_total_cfg(cfg)\nif cfg.use_gpu:\ndevices_num = fluid.core.get_cuda_device_count()\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Fix bug in class_aware_sampling (#541) |
499,313 | 23.04.2020 12:22:44 | -28,800 | f891064adfa0483405b5cbcba617c343743f9cb3 | add yolov3_mobilenet_v3 pruned model for mobile side | [
{
"change_type": "MODIFY",
"old_path": "configs/yolov3_mobilenet_v3.yml",
"new_path": "configs/yolov3_mobilenet_v3.yml",
"diff": "@@ -19,6 +19,7 @@ MobileNetV3:\nnorm_decay: 0.\nmodel_name: large\nscale: 1.\n+ extra_block_filters: []\nfeature_maps: [1, 2, 3, 4, 6]\nYOLOv3Head:\n"
},
{
"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": "@@ -231,7 +231,9 @@ def main():\nassert pruned_ratios > [0] * len(pruned_ratios) and pruned_ratios < [1] * len(pruned_ratios), \\\n\"The elements of pruned ratios should be in range (0, 1).\"\n- pruner = Pruner()\n+ assert FLAGS.prune_criterion in ['l1_norm', 'geometry_median'], \\\n+ \"unsupported prune criterion {}\".format(FLAGS.prune_criterion)\n+ pruner = Pruner(criterion=FLAGS.prune_criterion)\ndistill_prog = pruner.prune(\nfluid.default_main_program(),\nfluid.global_scope(),\n@@ -361,5 +363,11 @@ if __name__ == '__main__':\ntype=str,\nhelp=\"The ratios pruned iteratively for each parameter when calculating sensitivities.\"\n)\n+ parser.add_argument(\n+ \"--prune_criterion\",\n+ default='l1_norm',\n+ type=str,\n+ help=\"criterion function type for channels sorting in pruning, can be set \" \\\n+ \"as 'l1_norm' or 'geometry_median' currently, default 'l1_norm'\")\nFLAGS = parser.parse_args()\nmain()\n"
},
{
"change_type": "MODIFY",
"old_path": "slim/prune/prune.py",
"new_path": "slim/prune/prune.py",
"diff": "@@ -187,7 +187,9 @@ def main():\npruned_ratios < [1] * len(pruned_ratios)\n), \"The elements of pruned ratios should be in range (0, 1).\"\n- pruner = Pruner()\n+ assert FLAGS.prune_criterion in ['l1_norm', 'geometry_median'], \\\n+ \"unsupported prune criterion {}\".format(FLAGS.prune_criterion)\n+ pruner = Pruner(criterion=FLAGS.prune_criterion)\ntrain_prog = pruner.prune(\ntrain_prog,\nfluid.global_scope(),\n@@ -388,5 +390,11 @@ if __name__ == '__main__':\ndefault=False,\naction='store_true',\nhelp=\"Whether to only print the parameters' names and shapes.\")\n+ parser.add_argument(\n+ \"--prune_criterion\",\n+ default='l1_norm',\n+ type=str,\n+ help=\"criterion function type for channels sorting in pruning, can be set \" \\\n+ \"as 'l1_norm' or 'geometry_median' currently, default 'l1_norm'\")\nFLAGS = parser.parse_args()\nmain()\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | add yolov3_mobilenet_v3 pruned model for mobile side (#532) |
499,388 | 30.04.2020 13:06:21 | -28,800 | 50f32ee1f460c115b8da5b6bcb02af37ccbe92b0 | fix iou aware bug | [
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/losses/yolo_loss.py",
"new_path": "ppdet/modeling/losses/yolo_loss.py",
"diff": "@@ -117,6 +117,7 @@ class YOLOv3Loss(object):\nfor i, (output, target,\nanchors) in enumerate(zip(outputs, targets, mask_anchors)):\nan_num = len(anchors) // 2\n+ if self._iou_aware_loss is not None:\nioup, output = self._split_ioup(output, an_num, num_classes)\nx, y, w, h, obj, cls = self._split_output(output, an_num,\nnum_classes)\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix iou aware bug (#578) |
499,300 | 30.04.2020 19:51:27 | -28,800 | 1a485e12c94e5f68664914f1fc8a8b0abf10a7ae | Remove `pycocotools` from `requirements.txt`
* Remove `pycocotools` from `requirements.txt`
git version is required for numpy > 1.18
* Remove `cython`, add pip install doc | [
{
"change_type": "MODIFY",
"old_path": "docs/tutorials/INSTALL.md",
"new_path": "docs/tutorials/INSTALL.md",
"diff": "@@ -59,6 +59,8 @@ COCO-API is needed for running. Installation is as follows:\n# Alternatively, if you do not have permissions or prefer\n# not to install the COCO API into global site-packages\npython setup.py install --user\n+ # or with pip\n+ pip install \"git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI\"\n**Installation of COCO-API in windows:**\n"
},
{
"change_type": "MODIFY",
"old_path": "requirements.txt",
"new_path": "requirements.txt",
"diff": "@@ -3,8 +3,6 @@ docstring_parser @ http://github.com/willthefrog/docstring_parser/tarball/master\ntypeguard ; python_version >= '3.4'\ntb-paddle\ntensorboard >= 1.15\n-cython\n-pycocotools\nopencv-python\nPyYAML\nshapely\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Remove `pycocotools` from `requirements.txt` (#582)
* Remove `pycocotools` from `requirements.txt`
git version is required for numpy > 1.18
* Remove `cython`, add pip install doc |
499,400 | 01.05.2020 10:37:52 | -28,800 | 20303e693bf0dcfa85b184e2ce1ca44b47473e95 | Fix eval run in pruning | [
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/anchor_heads/rpn_head.py",
"new_path": "ppdet/modeling/anchor_heads/rpn_head.py",
"diff": "@@ -169,7 +169,7 @@ class RPNHead(object):\nrpn_cls_prob = fluid.layers.transpose(\nrpn_cls_prob, perm=[0, 3, 1, 2])\nprop_op = self.train_proposal if mode == 'train' else self.test_proposal\n- rpn_rois, rpn_roi_probs = prop_op(\n+ rpn_rois, rpn_roi_probs, _ = prop_op(\nscores=rpn_cls_prob,\nbbox_deltas=rpn_bbox_pred,\nim_info=im_info,\n@@ -430,7 +430,7 @@ class FPNRPNHead(RPNHead):\nrpn_cls_prob_fpn, shape=(0, 0, 0, -1))\nrpn_cls_prob_fpn = fluid.layers.transpose(\nrpn_cls_prob_fpn, perm=[0, 3, 1, 2])\n- rpn_rois_fpn, rpn_roi_prob_fpn = prop_op(\n+ rpn_rois_fpn, rpn_roi_prob_fpn, _ = prop_op(\nscores=rpn_cls_prob_fpn,\nbbox_deltas=rpn_bbox_pred_fpn,\nim_info=im_info,\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/tests/test_architectures.py",
"new_path": "ppdet/modeling/tests/test_architectures.py",
"diff": "@@ -56,6 +56,9 @@ class TestMaskRCNN(TestFasterRCNN):\nself.cfg_file = 'configs/mask_rcnn_r50_1x.yml'\n+@unittest.skip(\n+ reason=\"It should be fixed to adapt https://github.com/PaddlePaddle/Paddle/pull/23797\"\n+)\nclass TestCascadeRCNN(TestFasterRCNN):\ndef set_config(self):\nself.cfg_file = 'configs/cascade_rcnn_r50_fpn_1x.yml'\n"
},
{
"change_type": "MODIFY",
"old_path": "slim/prune/prune.py",
"new_path": "slim/prune/prune.py",
"diff": "@@ -256,7 +256,7 @@ def main():\nif FLAGS.eval:\n# evaluation\nresults = eval_run(exe, compiled_eval_prog, eval_loader, eval_keys,\n- eval_values, eval_cls)\n+ eval_values, eval_cls, cfg)\nresolution = None\nif 'mask' in results[0]:\nresolution = model.mask_head.resolution\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Fix eval run in pruning (#576) |
499,385 | 01.05.2020 01:16:06 | 18,000 | cad500e55c7ee68521783151f092d6f13e1a0ce0 | Update rpn_head.py | [
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/anchor_heads/rpn_head.py",
"new_path": "ppdet/modeling/anchor_heads/rpn_head.py",
"diff": "@@ -169,7 +169,7 @@ class RPNHead(object):\nrpn_cls_prob = fluid.layers.transpose(\nrpn_cls_prob, perm=[0, 3, 1, 2])\nprop_op = self.train_proposal if mode == 'train' else self.test_proposal\n- rpn_rois, rpn_roi_probs, _ = prop_op(\n+ rpn_rois, rpn_roi_probs = prop_op(\nscores=rpn_cls_prob,\nbbox_deltas=rpn_bbox_pred,\nim_info=im_info,\n@@ -430,7 +430,7 @@ class FPNRPNHead(RPNHead):\nrpn_cls_prob_fpn, shape=(0, 0, 0, -1))\nrpn_cls_prob_fpn = fluid.layers.transpose(\nrpn_cls_prob_fpn, perm=[0, 3, 1, 2])\n- rpn_rois_fpn, rpn_roi_prob_fpn, _ = prop_op(\n+ rpn_rois_fpn, rpn_roi_prob_fpn = prop_op(\nscores=rpn_cls_prob_fpn,\nbbox_deltas=rpn_bbox_pred_fpn,\nim_info=im_info,\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Update rpn_head.py (#588) |
499,324 | 06.05.2020 19:08:36 | -28,800 | 04a338b61858d3ff1ed12b87b78666a2e0c64b2d | Update yolov3_darknet_voc_diouloss.yml
use_fine_grained_loss: true | [
{
"change_type": "MODIFY",
"old_path": "configs/yolov3_darknet_voc_diouloss.yml",
"new_path": "configs/yolov3_darknet_voc_diouloss.yml",
"diff": "@@ -9,7 +9,7 @@ map_type: 11point\npretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/DarkNet53_pretrained.tar\nweights: output/yolov3_darknet_voc/model_final\nnum_classes: 20\n-use_fine_grained_loss: false\n+use_fine_grained_loss: true\nYOLOv3:\nbackbone: DarkNet\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Update yolov3_darknet_voc_diouloss.yml (#598)
use_fine_grained_loss: true |
499,304 | 07.05.2020 08:40:37 | -28,800 | 1d9239738d5901b2204a8d4e6895593191915cf7 | add ssdlite_mbv1 | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "configs/ssd/ssdlite_mobilenet_v1.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/MobileNetV1_ssld_pretrained.tar\n+save_dir: output\n+weights: output/ssdlite_mobilenet_v1/model_final\n+num_classes: 81\n+\n+SSD:\n+ backbone: MobileNet\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+MobileNet:\n+ norm_decay: 0.0\n+ conv_group_scale: 1\n+ extra_block_filters: [[256, 512], [128, 256], [128, 256], [64, 128]]\n+ with_extra_blocks: true\n+\n+SSDLiteMultiBoxHead:\n+ aspect_ratios: [[2.], [2., 3.], [2., 3.], [2., 3.], [2., 3.], [2., 3.]]\n+ base_size: 300\n+ steps: [16, 32, 64, 100, 150, 300]\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.4\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, 300, 300]\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: 300\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, 300, 300]\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: 300\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,300,300]\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: 300\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": "@@ -193,10 +193,11 @@ results of image size 608/416/320 above. Deformable conv is added on stage 5 of\n| Backbone | Size | Image/gpu | Lr schd | Inf time (fps) | Box AP | Download | Configs |\n| :------: | :--: | :-------: | :-----: | :------------: | :----: | :----------------------------------------------------------: | :----: |\n+| MobileNet_v1 | 300 | 64 | 40w | - | 23.6 | [model](https://paddlemodels.bj.bcebos.com/object_detection/ssdlite_mobilenet_v1.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/ssd/ssdlite_mobilenet_v1.yml) |\n| MobileNet_v3 small | 320 | 64 | 40w | - | 16.6 | [model](https://paddlemodels.bj.bcebos.com/object_detection/mobilenet_v3_ssdlite_small.tar) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/ssd/ssdlite_mobilenet_v3_small.yml) |\n| MobileNet_v3 large | 320 | 64 | 40w | - | 22.8 | [model](https://paddlemodels.bj.bcebos.com/object_detection/mobilenet_v3_ssdlite_large.tar) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/ssd/ssdlite_mobilenet_v3_large.yml) |\n-**Notes:** MobileNet_v3-SSDLite is trained in 8 GPU with total batch size as 512 and uses cosine decay strategy to train.\n+**Notes:** `SSDLite` is trained in 8 GPU with total batch size as 512 and uses cosine decay strategy to train.\n### SSD\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | add ssdlite_mbv1 (#595) |
499,400 | 08.05.2020 11:31:15 | -28,800 | be2c012bb4048d3fe032b5194253095588324e0b | Fix eval_run in demo of pruning and sensitivity | [
{
"change_type": "MODIFY",
"old_path": "slim/prune/prune.py",
"new_path": "slim/prune/prune.py",
"diff": "@@ -293,8 +293,14 @@ def main():\nif FLAGS.eval:\n# evaluation\n- results = eval_run(exe, compiled_eval_prog, eval_loader,\n- eval_keys, eval_values, eval_cls)\n+ results = eval_run(\n+ exe,\n+ compiled_eval_prog,\n+ eval_loader,\n+ eval_keys,\n+ eval_values,\n+ eval_cls,\n+ cfg=cfg)\nresolution = None\nif 'mask' in results[0]:\nresolution = model.mask_head.resolution\n"
},
{
"change_type": "MODIFY",
"old_path": "slim/sensitive/sensitive.py",
"new_path": "slim/sensitive/sensitive.py",
"diff": "@@ -131,8 +131,14 @@ def main():\ncompiled_eval_prog = fluid.compiler.CompiledProgram(program)\n- results = eval_run(exe, compiled_eval_prog, eval_loader, eval_keys,\n- eval_values, eval_cls)\n+ results = eval_run(\n+ exe,\n+ compiled_eval_prog,\n+ eval_loader,\n+ eval_keys,\n+ eval_values,\n+ eval_cls,\n+ cfg=cfg)\nresolution = None\nif 'mask' in results[0]:\nresolution = model.mask_head.resolution\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Fix eval_run in demo of pruning and sensitivity (#611) |
499,304 | 08.05.2020 13:11:03 | -28,800 | 807287417f7d8a4cb02a69c2fdb307bebf1badb7 | fix face_eval check_config | [
{
"change_type": "MODIFY",
"old_path": "tools/export_serving_model.py",
"new_path": "tools/export_serving_model.py",
"diff": "@@ -22,6 +22,7 @@ from paddle import fluid\nfrom ppdet.core.workspace import load_config, merge_config, create\nfrom ppdet.utils.cli import ArgsParser\n+from ppdet.utils.check import check_config\nimport ppdet.utils.checkpoint as checkpoint\nimport yaml\nimport logging\n@@ -55,13 +56,10 @@ def save_serving_model(FLAGS, exe, feed_vars, test_fetches, infer_prog):\ndef main():\ncfg = load_config(FLAGS.config)\n+ merge_config(FLAGS.opt)\n+ check_config(cfg)\n- if 'architecture' in cfg:\nmain_arch = cfg.architecture\n- else:\n- raise ValueError(\"'architecture' not specified in config file.\")\n-\n- merge_config(FLAGS.opt)\n# Use CPU for exporting inference model instead of GPU\nplace = fluid.CPUPlace()\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/face_eval.py",
"new_path": "tools/face_eval.py",
"diff": "@@ -25,7 +25,7 @@ from collections import OrderedDict\nimport ppdet.utils.checkpoint as checkpoint\nfrom ppdet.utils.cli import ArgsParser\n-from ppdet.utils.check import check_gpu\n+from ppdet.utils.check import check_gpu, check_config\nfrom ppdet.utils.widerface_eval_utils import get_shrink, bbox_vote, \\\nsave_widerface_bboxes, save_fddb_bboxes, to_chw_bgr\nfrom ppdet.core.workspace import load_config, merge_config, create\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix face_eval check_config (#612) |
499,333 | 08.05.2020 15:21:50 | -28,800 | 78c37c48e52c07fd66c100e8e4d1fef28649b34c | fix yolo eval | [
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/anchor_heads/yolo_head.py",
"new_path": "ppdet/modeling/anchor_heads/yolo_head.py",
"diff": "@@ -68,7 +68,8 @@ class YOLOv3Head(object):\nbackground_label=-1).__dict__,\nweight_prefix_name='',\ndownsample=[32, 16, 8],\n- scale_x_y=1.0):\n+ scale_x_y=1.0,\n+ clip_bbox=True):\nself.norm_decay = norm_decay\nself.num_classes = num_classes\nself.anchor_masks = anchor_masks\n@@ -86,6 +87,7 @@ class YOLOv3Head(object):\nself.downsample = downsample\n# TODO(guanzhong) activate scale_x_y in Paddle 2.0\n#self.scale_x_y = scale_x_y\n+ self.clip_bbox = clip_bbox\ndef _conv_bn(self,\ninput,\n@@ -325,7 +327,7 @@ class YOLOv3Head(object):\nconf_thresh=self.nms.score_threshold,\ndownsample_ratio=self.downsample[i],\nname=self.prefix_name + \"yolo_box\" + str(i),\n- clip_bbox=False)\n+ clip_bbox=self.clip_bbox)\nboxes.append(box)\nscores.append(fluid.layers.transpose(score, perm=[0, 2, 1]))\n@@ -352,8 +354,7 @@ class YOLOv4Head(YOLOv3Head):\n__inject__ = ['nms', 'yolo_loss']\n__shared__ = ['num_classes', 'weight_prefix_name']\n- def __init__(\n- self,\n+ def __init__(self,\nanchors=[[12, 16], [19, 36], [40, 28], [36, 75], [76, 55],\n[72, 146], [142, 110], [192, 243], [459, 401]],\nanchor_masks=[[0, 1, 2], [3, 4, 5], [6, 7, 8]],\n@@ -370,7 +371,8 @@ class YOLOv4Head(YOLOv3Head):\nscale_x_y=[1.2, 1.1, 1.05],\nyolo_loss=\"YOLOv3Loss\",\niou_aware=False,\n- iou_aware_factor=0.4, ):\n+ iou_aware_factor=0.4,\n+ clip_bbox=False):\nsuper(YOLOv4Head, self).__init__(\nanchors=anchors,\nanchor_masks=anchor_masks,\n@@ -381,7 +383,8 @@ class YOLOv4Head(YOLOv3Head):\nscale_x_y=scale_x_y,\nyolo_loss=yolo_loss,\niou_aware=iou_aware,\n- iou_aware_factor=iou_aware_factor)\n+ iou_aware_factor=iou_aware_factor,\n+ clip_box=clip_bbox)\nself.spp_stage = spp_stage\ndef _upsample(self, input, scale=2, name=None):\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/architectures/yolo.py",
"new_path": "ppdet/modeling/architectures/yolo.py",
"diff": "@@ -42,7 +42,7 @@ class YOLOv3(object):\ndef __init__(self,\nbackbone,\n- yolo_head='YOLOv4Head',\n+ yolo_head='YOLOv3Head',\nuse_fine_grained_loss=False):\nsuper(YOLOv3, self).__init__()\nself.backbone = backbone\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/utils/coco_eval.py",
"new_path": "ppdet/utils/coco_eval.py",
"diff": "@@ -275,11 +275,11 @@ def bbox2out(results, clsid2catid, is_bbox_normalized=False):\nw *= im_width\nh *= im_height\nelse:\n- im_size = t['im_size'][0][i].tolist()\n- xmin, ymin, xmax, ymax = \\\n- clip_bbox([xmin, ymin, xmax, ymax], im_size)\n- w = xmax - xmin\n- h = ymax - ymin\n+ # for yolov4\n+ # w = xmax - xmin\n+ # h = ymax - ymin\n+ w = xmax - xmin + 1\n+ h = ymax - ymin + 1\nbbox = [xmin, ymin, w, h]\ncoco_res = {\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/eval.py",
"new_path": "tools/eval.py",
"diff": "@@ -111,7 +111,7 @@ def main():\nextra_keys = []\nif cfg.metric == 'COCO':\n- extra_keys = ['im_info', 'im_id', 'im_shape', 'im_size']\n+ extra_keys = ['im_info', 'im_id', 'im_shape']\nif cfg.metric == 'VOC':\nextra_keys = ['gt_bbox', 'gt_class', 'is_difficult']\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix yolo eval (#613) |
499,333 | 09.05.2020 11:14:07 | -28,800 | 52ecf50607de7e199f6de36637053324555dc37d | fix clip_bbox | [
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/anchor_heads/yolo_head.py",
"new_path": "ppdet/modeling/anchor_heads/yolo_head.py",
"diff": "@@ -384,7 +384,7 @@ class YOLOv4Head(YOLOv3Head):\nyolo_loss=yolo_loss,\niou_aware=iou_aware,\niou_aware_factor=iou_aware_factor,\n- clip_box=clip_bbox)\n+ clip_bbox=clip_bbox)\nself.spp_stage = spp_stage\ndef _upsample(self, input, scale=2, name=None):\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix clip_bbox (#620) |
499,333 | 09.05.2020 12:27:01 | -28,800 | 3fba477820e3873432b12d6c0b90eb93af1d5ede | minor fix for cornernet & yolov4 | [
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/anchor_heads/corner_head.py",
"new_path": "ppdet/modeling/anchor_heads/corner_head.py",
"diff": "@@ -23,12 +23,8 @@ from paddle.fluid.initializer import Constant\nfrom ..backbones.hourglass import _conv_norm, kaiming_init\nfrom ppdet.core.workspace import register\nimport numpy as np\n-try:\n- import cornerpool_lib\n-except:\n- print(\n- \"warning: cornerpool_lib not found, compile in ext_op at first if needed\"\n- )\n+import logging\n+logger = logging.getLogger(__name__)\n__all__ = ['CornerHead']\n@@ -247,6 +243,10 @@ class CornerHead(object):\nae_threshold=1,\nnum_dets=1000,\ntop_k=100):\n+ try:\n+ import cornerpool_lib\n+ except:\n+ logger.error(\"cornerpool_lib not found, compile in ext_op at first\")\nself.train_batch_size = train_batch_size\nself.test_batch_size = test_batch_size\nself.num_classes = num_classes\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/architectures/cornernet_squeeze.py",
"new_path": "ppdet/modeling/architectures/cornernet_squeeze.py",
"diff": "@@ -59,7 +59,7 @@ class CornerNetSqueeze(object):\nbody_feats = self.backbone(im)\nif self.fpn is not None:\nbody_feats, _ = self.fpn.get_output(body_feats)\n- body_feats = [body_feats.values()[-1]]\n+ body_feats = [list(body_feats.values())[-1]]\nif mode == 'train':\ntarget_vars = [\n'tl_heatmaps', 'br_heatmaps', 'tag_masks', 'tl_regrs',\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/losses/yolo_loss.py",
"new_path": "ppdet/modeling/losses/yolo_loss.py",
"diff": "@@ -166,7 +166,7 @@ class YOLOv3Loss(object):\n# self.scale_x_y, Sequence) else self.scale_x_y[i]\nloss_obj_pos, loss_obj_neg = self._calc_obj_loss(\noutput, obj, tobj, gt_box, self._batch_size, anchors,\n- num_classes, downsample, self._ignore_thresh, scale_x_y)\n+ num_classes, downsample, self._ignore_thresh)\nloss_cls = fluid.layers.sigmoid_cross_entropy_with_logits(cls, tcls)\nloss_cls = fluid.layers.elementwise_mul(loss_cls, tobj, axis=0)\n@@ -276,7 +276,7 @@ class YOLOv3Loss(object):\nreturn (tx, ty, tw, th, tscale, tobj, tcls)\ndef _calc_obj_loss(self, output, obj, tobj, gt_box, batch_size, anchors,\n- num_classes, downsample, ignore_thresh, scale_x_y):\n+ num_classes, downsample, ignore_thresh):\n# A prediction bbox overlap any gt_bbox over ignore_thresh,\n# objectness loss will be ignored, process as follows:\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | minor fix for cornernet & yolov4 (#621) |
499,304 | 10.05.2020 11:56:51 | -28,800 | cb3875d464f731bd424ddc41e455aa6b47a8eb8d | fix voc doc JPEGImages error | [
{
"change_type": "MODIFY",
"old_path": ".gitignore",
"new_path": ".gitignore",
"diff": "@@ -22,6 +22,7 @@ __pycache__/\n/lib/\n/lib64/\n/output/\n+/inference_model/\n/parts/\n/sdist/\n/var/\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix voc doc JPEGImages error (#624) |
499,304 | 10.05.2020 11:58:29 | -28,800 | 0d127b2b9b70427a4c1c286e6124e11c4a2625b9 | fix python deploy --model_dir | [
{
"change_type": "MODIFY",
"old_path": "deploy/python/infer.py",
"new_path": "deploy/python/infer.py",
"diff": "@@ -531,7 +531,7 @@ if __name__ == '__main__':\ntype=str,\ndefault=None,\nhelp=(\"Directory include:'__model__', '__params__', \"\n- \"'infer_cfg.yml', created by export_model.\"),\n+ \"'infer_cfg.yml', created by tools/export_model.py.\"),\nrequired=True)\nparser.add_argument(\n\"--image_file\", type=str, default='', help=\"Path of image file.\")\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix python deploy --model_dir (#629) |
499,333 | 12.05.2020 17:12:37 | -28,800 | 919310bbc0600e03e0c886a8b589546a203e139a | deprecate cpp_infer | [
{
"change_type": "MODIFY",
"old_path": "tools/cpp_infer.py",
"new_path": "tools/cpp_infer.py",
"diff": "@@ -505,6 +505,8 @@ def visualize(bbox_results, catid2name, num_classes, mask_results=None):\ndef infer():\n+ logger.info(\"cpp_infer.py is deprecated since release/0.3. Please use\"\n+ \"deploy/python for your python deployment\")\nmodel_path = FLAGS.model_path\nconfig_path = FLAGS.config_path\nres = {}\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | deprecate cpp_infer (#651) |
499,306 | 13.05.2020 10:57:03 | -28,800 | a65395fd2758cbe8c0de638874bda2018121ecc2 | fix eval run api usage in slim/distillation | [
{
"change_type": "MODIFY",
"old_path": "slim/distillation/distill.py",
"new_path": "slim/distillation/distill.py",
"diff": "@@ -338,7 +338,7 @@ def main():\neval_prog)\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 run api usage in slim/distillation (#655) |
499,311 | 13.05.2020 20:05:55 | -28,800 | 38d1517fdadbcf9c19706deff2e0f8a95936ee88 | Make TensorRT dir settable | [
{
"change_type": "MODIFY",
"old_path": "deploy/cpp/CMakeLists.txt",
"new_path": "deploy/cpp/CMakeLists.txt",
"diff": "@@ -9,6 +9,7 @@ option(WITH_TENSORRT \"Compile demo with TensorRT.\" OFF)\nSET(PADDLE_DIR \"\" CACHE PATH \"Location of libraries\")\nSET(OPENCV_DIR \"\" CACHE PATH \"Location of libraries\")\nSET(CUDA_LIB \"\" CACHE PATH \"Location of libraries\")\n+SET(TENSORRT_DIR \"\" CACHE PATH \"Compile demo with TensorRT\")\ninclude(cmake/yaml-cpp.cmake)\n@@ -112,8 +113,8 @@ endif()\nif (NOT WIN32)\nif (WITH_TENSORRT AND WITH_GPU)\n- include_directories(\"${PADDLE_DIR}/third_party/install/tensorrt/include\")\n- link_directories(\"${PADDLE_DIR}/third_party/install/tensorrt/lib\")\n+ include_directories(\"${TENSORRT_DIR}/include\")\n+ link_directories(\"${TENSORRT_DIR}/lib\")\nendif()\nendif(NOT WIN32)\n@@ -195,15 +196,15 @@ endif(NOT WIN32)\nif(WITH_GPU)\nif(NOT WIN32)\nif (WITH_TENSORRT)\n- set(DEPS ${DEPS} ${PADDLE_DIR}/third_party/install/tensorrt/lib/libnvinfer${CMAKE_STATIC_LIBRARY_SUFFIX})\n- set(DEPS ${DEPS} ${PADDLE_DIR}/third_party/install/tensorrt/lib/libnvinfer_plugin${CMAKE_STATIC_LIBRARY_SUFFIX})\n+ set(DEPS ${DEPS} ${TENSORRT_DIR}/lib/libnvinfer${CMAKE_SHARED_LIBRARY_SUFFIX})\n+ set(DEPS ${DEPS} ${TENSORRT_DIR}/lib/libnvinfer_plugin${CMAKE_SHARED_LIBRARY_SUFFIX})\nendif()\nset(DEPS ${DEPS} ${CUDA_LIB}/libcudart${CMAKE_SHARED_LIBRARY_SUFFIX})\nset(DEPS ${DEPS} ${CUDNN_LIB}/libcudnn${CMAKE_SHARED_LIBRARY_SUFFIX})\nelse()\nset(DEPS ${DEPS} ${CUDA_LIB}/cudart${CMAKE_STATIC_LIBRARY_SUFFIX} )\nset(DEPS ${DEPS} ${CUDA_LIB}/cublas${CMAKE_STATIC_LIBRARY_SUFFIX} )\n- set(DEPS ${DEPS} ${CUDA_LIB}/cudnn${CMAKE_STATIC_LIBRARY_SUFFIX})\n+ set(DEPS ${DEPS} ${CUDNN_LIB}/cudnn${CMAKE_STATIC_LIBRARY_SUFFIX})\nendif()\nendif()\n"
},
{
"change_type": "MODIFY",
"old_path": "deploy/cpp/cmake/yaml-cpp.cmake",
"new_path": "deploy/cpp/cmake/yaml-cpp.cmake",
"diff": "@@ -26,4 +26,5 @@ ExternalProject_Add(\n# Disable install step\nINSTALL_COMMAND \"\"\nLOG_DOWNLOAD ON\n+ LOG_BUILD 1\n)\n"
},
{
"change_type": "MODIFY",
"old_path": "deploy/cpp/scripts/bootstrap.sh",
"new_path": "deploy/cpp/scripts/bootstrap.sh",
"diff": "# download pre-compiled opencv lib\n-OPENCV_URL=https://paddleseg.bj.bcebos.com/deploy/deps/opencv346.tar.bz2\n-if [ ! -d \"./deps/opencv346\" ]; then\n+OPENCV_URL=https://paddleseg.bj.bcebos.com/deploy/docker/opencv3gcc4.8.tar.bz2\n+if [ ! -d \"./deps/opencv3gcc4.8\" ]; then\nmkdir -p deps\ncd deps\nwget -c ${OPENCV_URL}\n- tar xvfj opencv346.tar.bz2\n- rm -rf opencv346.tar.bz2\n+ tar xvfj opencv3gcc4.8.tar.bz2\n+ rm -rf opencv3gcc4.8.tar.bz2\ncd ..\nfi\n-\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Make TensorRT dir settable (#658) |
499,333 | 14.05.2020 15:07:06 | -28,800 | e3f1384deb3108adc05873493014a35950c04eae | update doc for ext_op | [
{
"change_type": "MODIFY",
"old_path": "ppdet/ext_op/src/make.sh",
"new_path": "ppdet/ext_op/src/make.sh",
"diff": "@@ -19,5 +19,3 @@ g++ bottom_pool_op.cc bottom_pool_op.cu.o top_pool_op.cc top_pool_op.cu.o right_\n-L /usr/local/cuda/lib64 -lpaddle_framework -lcudart\nrm *.cu.o\n-\n-export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$lib_dir\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/anchor_heads/corner_head.py",
"new_path": "ppdet/modeling/anchor_heads/corner_head.py",
"diff": "@@ -246,7 +246,8 @@ class CornerHead(object):\ntry:\nimport cornerpool_lib\nexcept:\n- logger.error(\"cornerpool_lib not found, compile in ext_op at first\")\n+ logger.error(\n+ \"cornerpool_lib not found, compile in ppdet/ext_op at first\")\nself.train_batch_size = train_batch_size\nself.test_batch_size = test_batch_size\nself.num_classes = num_classes\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | update doc for ext_op (#667) |
499,304 | 14.05.2020 16:24:24 | -28,800 | b464f689d5e125ef7e74610ed354d7bcdfbb76e7 | fix check_version in some script | [
{
"change_type": "MODIFY",
"old_path": "slim/distillation/distill.py",
"new_path": "slim/distillation/distill.py",
"diff": "@@ -32,7 +32,7 @@ from ppdet.data.reader import create_reader\nfrom ppdet.utils.eval_utils import parse_fetches, eval_results, eval_run\nfrom ppdet.utils.stats import TrainingStats\nfrom ppdet.utils.cli import ArgsParser\n-from ppdet.utils.check import check_gpu, check_config\n+from ppdet.utils.check import check_gpu, check_version, check_config\nimport ppdet.utils.checkpoint as checkpoint\nimport logging\n@@ -134,6 +134,7 @@ def main():\ncheck_config(cfg)\n# check if set use_gpu=True in paddlepaddle cpu version\ncheck_gpu(cfg.use_gpu)\n+ check_version()\nmain_arch = cfg.architecture\n"
},
{
"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": "@@ -35,7 +35,7 @@ from ppdet.data.reader import create_reader\nfrom ppdet.utils.eval_utils import parse_fetches, eval_results, eval_run\nfrom ppdet.utils.stats import TrainingStats\nfrom ppdet.utils.cli import ArgsParser\n-from ppdet.utils.check import check_gpu, check_config\n+from ppdet.utils.check import check_gpu, check_version, check_config\nimport ppdet.utils.checkpoint as checkpoint\nimport logging\n@@ -123,6 +123,7 @@ def main():\ncheck_config(cfg)\n# check if set use_gpu=True in paddlepaddle cpu version\ncheck_gpu(cfg.use_gpu)\n+ check_version()\nmain_arch = cfg.architecture\n"
},
{
"change_type": "MODIFY",
"old_path": "slim/prune/export_model.py",
"new_path": "slim/prune/export_model.py",
"diff": "@@ -27,7 +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.check import check_config\n+from ppdet.utils.check import check_config, check_version\nfrom paddleslim.prune import Pruner\nfrom paddleslim.analysis import flops\n@@ -82,6 +82,7 @@ def main():\ncfg = load_config(FLAGS.config)\nmerge_config(FLAGS.opt)\ncheck_config(cfg)\n+ check_version()\nmain_arch = cfg.architecture\n"
},
{
"change_type": "MODIFY",
"old_path": "slim/quantization/export_model.py",
"new_path": "slim/quantization/export_model.py",
"diff": "@@ -27,7 +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.check import check_config\n+from ppdet.utils.check import check_config, check_version\nfrom tools.export_model import prune_feed_vars\nimport logging\n@@ -57,6 +57,7 @@ def main():\ncfg = load_config(FLAGS.config)\nmerge_config(FLAGS.opt)\ncheck_config(cfg)\n+ check_version()\nmain_arch = cfg.architecture\n"
},
{
"change_type": "MODIFY",
"old_path": "slim/sensitive/sensitive.py",
"new_path": "slim/sensitive/sensitive.py",
"diff": "@@ -53,6 +53,7 @@ def main():\ncfg = load_config(FLAGS.config)\nmerge_config(FLAGS.opt)\ncheck_config(cfg)\n+ check_version()\nmain_arch = cfg.architecture\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/export_model.py",
"new_path": "tools/export_model.py",
"diff": "@@ -28,7 +28,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.check import check_config\n+from ppdet.utils.check import check_config, check_version\nimport yaml\nimport logging\nfrom collections import OrderedDict\n@@ -176,6 +176,8 @@ def main():\nmerge_config(FLAGS.opt)\ncheck_config(cfg)\n+ check_version()\n+\nmain_arch = cfg.architecture\n# Use CPU for exporting inference model instead of GPU\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/export_serving_model.py",
"new_path": "tools/export_serving_model.py",
"diff": "@@ -22,7 +22,7 @@ from paddle import fluid\nfrom ppdet.core.workspace import load_config, merge_config, create\nfrom ppdet.utils.cli import ArgsParser\n-from ppdet.utils.check import check_config\n+from ppdet.utils.check import check_config, check_version\nimport ppdet.utils.checkpoint as checkpoint\nimport yaml\nimport logging\n@@ -58,6 +58,7 @@ def main():\ncfg = load_config(FLAGS.config)\nmerge_config(FLAGS.opt)\ncheck_config(cfg)\n+ check_version()\nmain_arch = cfg.architecture\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/face_eval.py",
"new_path": "tools/face_eval.py",
"diff": "@@ -30,7 +30,7 @@ from collections import OrderedDict\nimport ppdet.utils.checkpoint as checkpoint\nfrom ppdet.utils.cli import ArgsParser\n-from ppdet.utils.check import check_gpu, check_config\n+from ppdet.utils.check import check_gpu, check_version, check_config\nfrom ppdet.utils.widerface_eval_utils import get_shrink, bbox_vote, \\\nsave_widerface_bboxes, save_fddb_bboxes, to_chw_bgr\nfrom ppdet.core.workspace import load_config, merge_config, create\n@@ -219,6 +219,7 @@ def main():\ncheck_config(cfg)\n# check if set use_gpu=True in paddlepaddle cpu version\ncheck_gpu(cfg.use_gpu)\n+ check_version()\nmain_arch = cfg.architecture\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix check_version in some script (#670) |
499,304 | 14.05.2020 17:52:03 | -28,800 | 31f7c6984e571f380565a68e5d28f437af4df19f | fix deploy/python/infer variable | [
{
"change_type": "MODIFY",
"old_path": "deploy/python/infer.py",
"new_path": "deploy/python/infer.py",
"diff": "@@ -518,7 +518,7 @@ def predict_video():\nfourcc = cv2.VideoWriter_fourcc(*'mp4v')\nvideo_name = os.path.split(FLAGS.video_file)[-1]\nif not os.path.exists(FLAGS.output_dir):\n- os.makedirs(FLAGES.output_dir)\n+ os.makedirs(FLAGS.output_dir)\nout_path = os.path.join(FLAGS.output_dir, video_name)\nwriter = cv2.VideoWriter(out_path, fourcc, fps, (width, height))\nindex = 1\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix deploy/python/infer variable (#675) |
499,304 | 15.05.2020 10:50:59 | -28,800 | 42bd90d717085b2fc8d5f718def120dc617b32b9 | fix catid2name in coco eval | [
{
"change_type": "MODIFY",
"old_path": "ppdet/utils/coco_eval.py",
"new_path": "ppdet/utils/coco_eval.py",
"diff": "@@ -609,6 +609,7 @@ def coco17_category_info(with_background=True):\nif not with_background:\nclsid2catid = {k - 1: v for k, v in clsid2catid.items()}\n+ catid2name.pop(0)\nelse:\nclsid2catid.update({0: 0})\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix catid2name in coco eval (#681) |
499,323 | 15.05.2020 00:17:46 | 18,000 | 3697a31eb8de891ddd7814cb7003319dd14f909f | Fix train_eval in quantization | [
{
"change_type": "MODIFY",
"old_path": "slim/quantization/train.py",
"new_path": "slim/quantization/train.py",
"diff": "@@ -256,8 +256,14 @@ def main():\nif FLAGS.eval:\n# evaluation\n- results = eval_run(exe, compiled_eval_prog, eval_loader,\n- eval_keys, eval_values, eval_cls)\n+ results = eval_run(\n+ exe,\n+ compiled_eval_prog,\n+ eval_loader,\n+ eval_keys,\n+ eval_values,\n+ eval_cls,\n+ cfg=cfg)\nresolution = None\nif 'mask' in results[0]:\nresolution = model.mask_head.resolution\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Fix train_eval in quantization (#682) |
499,400 | 15.05.2020 18:45:06 | -28,800 | 9227e51cf68446c20b8893c4a67fa06268a7df26 | Fix eval in pruning demo. | [
{
"change_type": "MODIFY",
"old_path": "slim/prune/eval.py",
"new_path": "slim/prune/eval.py",
"diff": "@@ -168,13 +168,23 @@ def main():\nif 'weights' in cfg:\ncheckpoint.load_checkpoint(exe, eval_prog, cfg.weights)\n- results = eval_run(exe, compile_program, loader, keys, values, cls, cfg,\n- sub_eval_prog, sub_keys, sub_values)\n-\n- # evaluation\nresolution = None\n- if 'mask' in results[0]:\n+ if 'Mask' in cfg.architecture:\nresolution = model.mask_head.resolution\n+\n+ results = eval_run(\n+ exe,\n+ compile_program,\n+ loader,\n+ keys,\n+ values,\n+ cls,\n+ cfg,\n+ sub_eval_prog,\n+ sub_keys,\n+ sub_values,\n+ resolution=resolution)\n+\n# if map_type not set, use default 11point, only use in VOC eval\nmap_type = cfg.map_type if 'map_type' in cfg else '11point'\neval_results(\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Fix eval in pruning demo. (#687) |
499,304 | 15.05.2020 20:00:28 | -28,800 | bb42d6de89e4109cc7db367cd64ed099cdc251c3 | fix obj365 segmentation error | [
{
"change_type": "MODIFY",
"old_path": "configs/obj365/cascade_rcnn_dcnv2_se154_vd_fpn_gn_cas.yml",
"new_path": "configs/obj365/cascade_rcnn_dcnv2_se154_vd_fpn_gn_cas.yml",
"diff": "@@ -124,8 +124,6 @@ TrainReader:\n- !DecodeImage\nto_rgb: True\n- !RandomFlipImage\n- is_mask_flip: true\n- is_normalized: false\nprob: 0.5\n- !NormalizeImage\nis_channel_first: false\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix obj365 segmentation error (#691) |
499,333 | 15.05.2020 20:51:23 | -28,800 | 4b17659c6fefc575f9dea22bf8d58131bfd3ef80 | fix unittest in ext_op | [
{
"change_type": "MODIFY",
"old_path": "ppdet/ext_op/test/test_corner_pool.py",
"new_path": "ppdet/ext_op/test/test_corner_pool.py",
"diff": "@@ -83,11 +83,7 @@ class TestRightPoolOp(unittest.TestCase):\nplace = fluid.CUDAPlace(0)\nwith fluid.program_guard(tp, sp):\n- x = fluid.data(\n- name=self.name,\n- shape=x_shape,\n- dtype=x_type,\n- append_batch_size=False)\n+ x = fluid.data(name=self.name, shape=x_shape, dtype=x_type)\ny = self.func_map[self.name][0](x)\nnp.random.seed(0)\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix unittest in ext_op (#689) |
499,300 | 18.05.2020 10:40:01 | -28,800 | aa217a9f8a963a310ab5ee5adea56290789b845f | Work around broadcast issue in iou_aware | [
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/anchor_heads/iou_aware.py",
"new_path": "ppdet/modeling/anchor_heads/iou_aware.py",
"diff": "@@ -35,7 +35,9 @@ def _split_ioup(output, an_num, num_classes):\ndef _de_sigmoid(x, eps=1e-7):\nx = fluid.layers.clip(x, eps, 1 / eps)\n- x = fluid.layers.clip((1 / x - 1.0), eps, 1 / eps)\n+ one = fluid.layers.fill_constant(\n+ shape=[1, 1, 1, 1], dtype=x.dtype, value=1.)\n+ x = fluid.layers.clip((one / x - 1.0), eps, 1 / eps)\nx = -fluid.layers.log(x)\nreturn x\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Work around broadcast issue in iou_aware (#690) |
499,333 | 18.05.2020 11:12:56 | -28,800 | 0ce6b7e117daa25cd6fe22e450d7084472cda917 | remove trt_int8 | [
{
"change_type": "MODIFY",
"old_path": "deploy/cpp/include/config_parser.h",
"new_path": "deploy/cpp/include/config_parser.h",
"diff": "@@ -42,12 +42,12 @@ class ConfigPaser {\nYAML::Node config;\nconfig = YAML::LoadFile(model_dir + OS_PATH_SEP + cfg);\n- // Get runtime mode : fluid, trt_int8, trt_fp16, trt_fp32\n+ // Get runtime mode : fluid, trt_fp16, trt_fp32\nif (config[\"mode\"].IsDefined()) {\nmode_ = config[\"mode\"].as<std::string>();\n} else {\nstd::cerr << \"Please set mode, \"\n- << \"support value : fluid/trt_int8/trt_fp16/trt_fp32.\"\n+ << \"support value : fluid/trt_fp16/trt_fp32.\"\n<< std::endl;\nreturn false;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "deploy/cpp/src/object_detector.cc",
"new_path": "deploy/cpp/src/object_detector.cc",
"diff": "@@ -33,7 +33,8 @@ void ObjectDetector::LoadModel(const std::string& model_dir,\nif (run_mode == \"trt_fp16\") {\nprecision = paddle::AnalysisConfig::Precision::kHalf;\n} else if (run_mode == \"trt_int8\") {\n- precision = paddle::AnalysisConfig::Precision::kInt8;\n+ printf(\"TensorRT int8 mode is not supported now, \"\n+ \"please use 'trt_fp32' or 'trt_fp16' instead\");\n} else {\nif (run_mode != \"trt_32\") {\nprintf(\"run_mode should be 'fluid', 'trt_fp32' or 'trt_fp16'\");\n@@ -45,7 +46,7 @@ void ObjectDetector::LoadModel(const std::string& model_dir,\nmin_subgraph_size,\nprecision,\nfalse,\n- run_mode == \"trt_int8\");\n+ false);\n}\n} else {\nconfig.DisableGpu();\n"
},
{
"change_type": "MODIFY",
"old_path": "deploy/python/infer.py",
"new_path": "deploy/python/infer.py",
"diff": "@@ -318,8 +318,10 @@ def load_predictor(model_dir,\nraise ValueError(\n\"Predict by TensorRT mode: {}, expect use_gpu==True, but use_gpu == {}\"\n.format(run_mode, use_gpu))\n+ if run_mode == 'trt_int8':\n+ raise ValueError(\"TensorRT int8 mode is not supported now, \"\n+ \"please use trt_fp32 or trt_fp16 instead.\")\nprecision_map = {\n- 'trt_int8': fluid.core.AnalysisConfig.Precision.Int8,\n'trt_fp32': fluid.core.AnalysisConfig.Precision.Float32,\n'trt_fp16': fluid.core.AnalysisConfig.Precision.Half\n}\n@@ -341,7 +343,7 @@ def load_predictor(model_dir,\nmin_subgraph_size=min_subgraph_size,\nprecision_mode=precision_map[run_mode],\nuse_static=False,\n- use_calib_mode=run_mode == 'trt_int8')\n+ use_calib_mode=False)\n# disable print log when predict\nconfig.disable_glog_info()\n@@ -482,8 +484,6 @@ class Detector():\nt1 = time.time()\nself.predictor.zero_copy_run()\nt2 = time.time()\n- ms = (t2 - t1) * 1000.0\n- print(\"Inference: {} ms per batch image\".format(ms))\noutput_names = self.predictor.get_output_names()\nboxes_tensor = self.predictor.get_output_tensor(output_names[0])\n@@ -491,6 +491,10 @@ class Detector():\nif self.config.mask_resolution is not None:\nmasks_tensor = self.predictor.get_output_tensor(output_names[1])\nnp_masks = masks_tensor.copy_to_cpu()\n+\n+ ms = (t2 - t1) * 1000.0\n+ print(\"Inference: {} ms per batch image\".format(ms))\n+\nresults = self.postprocess(\nnp_boxes, np_masks, im_info, threshold=threshold)\nreturn results\n@@ -556,7 +560,7 @@ if __name__ == '__main__':\n\"--run_mode\",\ntype=str,\ndefault='fluid',\n- help=\"mode of running(fluid/trt_fp32/trt_fp16/trt_int8)\")\n+ help=\"mode of running(fluid/trt_fp32/trt_fp16)\")\nparser.add_argument(\n\"--use_gpu\", default=False, help=\"Whether to predict with GPU.\")\nparser.add_argument(\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | remove trt_int8 (#708) |
499,333 | 18.05.2020 12:00:00 | -28,800 | 95713b8594e7cda8df502c7762a625764098006d | fix ext_op | [
{
"change_type": "MODIFY",
"old_path": "ppdet/ext_op/test/test_corner_pool.py",
"new_path": "ppdet/ext_op/test/test_corner_pool.py",
"diff": "@@ -17,7 +17,14 @@ from __future__ import print_function\nimport unittest\nimport numpy as np\nimport paddle.fluid as fluid\n-import cornerpool_lib\n+import os\n+import sys\n+# add python path of PadleDetection to sys.path\n+parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 4)))\n+if parent_path not in sys.path:\n+ sys.path.append(parent_path)\n+\n+from ppdet.ext_op import cornerpool_lib\ndef bottom_pool_np(x):\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/anchor_heads/corner_head.py",
"new_path": "ppdet/modeling/anchor_heads/corner_head.py",
"diff": "@@ -243,11 +243,6 @@ class CornerHead(object):\nae_threshold=1,\nnum_dets=1000,\ntop_k=100):\n- try:\n- import cornerpool_lib\n- except:\n- logger.error(\n- \"cornerpool_lib not found, compile in ppdet/ext_op at first\")\nself.train_batch_size = train_batch_size\nself.test_batch_size = test_batch_size\nself.num_classes = num_classes\n@@ -279,6 +274,11 @@ class CornerHead(object):\nreturn conv1\ndef get_output(self, input):\n+ try:\n+ from ppdet.ext_op import cornerpool_lib\n+ except:\n+ logger.error(\n+ \"cornerpool_lib not found, compile in ppdet/ext_op at first\")\nfor ind in range(self.stack):\ncnv = input[ind]\ntl_modules = corner_pool(\n@@ -455,6 +455,11 @@ class CornerHead(object):\nreturn {'loss': loss}\ndef get_prediction(self, input):\n+ try:\n+ from ppdet.ext_op import cornerpool_lib\n+ except:\n+ logger.error(\n+ \"cornerpool_lib not found, compile in ppdet/ext_op at first\")\nind = self.stack - 1\ntl_modules = corner_pool(\ninput,\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix ext_op (#711) |
499,300 | 18.05.2020 14:01:28 | -28,800 | 6d23b275972edf1371432a2d8402303320700789 | Fix FCOS API usage
revert `reshape` changes | [
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/anchor_heads/fcos_head.py",
"new_path": "ppdet/modeling/anchor_heads/fcos_head.py",
"diff": "@@ -283,14 +283,22 @@ class FCOSHead(object):\nlast dimension is [x1, y1, x2, y2]\n\"\"\"\nact_shape_cls = self.__merge_hw(box_cls)\n- box_cls_ch_last = fluid.layers.reshape(x=box_cls, shape=act_shape_cls)\n+ box_cls_ch_last = fluid.layers.reshape(\n+ x=box_cls,\n+ shape=[self.batch_size, self.num_classes, -1],\n+ actual_shape=act_shape_cls)\nbox_cls_ch_last = fluid.layers.sigmoid(box_cls_ch_last)\nact_shape_reg = self.__merge_hw(box_reg, \"channel_last\")\nbox_reg_ch_last = fluid.layers.transpose(box_reg, perm=[0, 2, 3, 1])\nbox_reg_ch_last = fluid.layers.reshape(\n- x=box_reg_ch_last, shape=act_shape_reg)\n+ x=box_reg_ch_last,\n+ shape=[self.batch_size, -1, 4],\n+ actual_shape=act_shape_reg)\nact_shape_ctn = self.__merge_hw(box_ctn)\n- box_ctn_ch_last = fluid.layers.reshape(x=box_ctn, shape=act_shape_ctn)\n+ box_ctn_ch_last = fluid.layers.reshape(\n+ x=box_ctn,\n+ shape=[self.batch_size, 1, -1],\n+ actual_shape=act_shape_ctn)\nbox_ctn_ch_last = fluid.layers.sigmoid(box_ctn_ch_last)\nbox_reg_decoding = fluid.layers.stack(\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Fix FCOS API usage (#718)
revert `reshape` changes |
499,375 | 18.05.2020 15:10:06 | -28,800 | befe81243a78b37167fd0199f7f150ea1802b0c8 | keep the option 'num_classes' and 'with_background' consistent | [
{
"change_type": "MODIFY",
"old_path": "configs/anchor_free/fcos_dcn_r50_fpn_1x.yml",
"new_path": "configs/anchor_free/fcos_dcn_r50_fpn_1x.yml",
"diff": "@@ -8,7 +8,7 @@ save_dir: output\npretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar\nmetric: COCO\nweights: output/fcos_dcn_r50_fpn_1x/model_final\n-num_classes: 81\n+num_classes: 80\nFCOS:\nbackbone: ResNet\n@@ -32,7 +32,7 @@ FPN:\nhas_extra_convs: true\nFCOSHead:\n- num_classes: 81\n+ num_classes: 80\nfpn_stride: [8, 16, 32, 64, 128]\nnum_convs: 4\nnorm_type: \"gn\"\n@@ -81,7 +81,7 @@ TrainReader:\nimage_dir: train2017\nanno_path: annotations/instances_train2017.json\ndataset_dir: dataset/coco\n- with_background: true\n+ with_background: false\nsample_transforms:\n- !DecodeImage\nto_rgb: true\n@@ -111,7 +111,7 @@ TrainReader:\nnorm_reg_targets: True\nbatch_size: 2\nshuffle: true\n- worker_num: 16\n+ worker_num: 4\nuse_process: false\nEvalReader:\n@@ -144,9 +144,9 @@ EvalReader:\n- !PadBatch\npad_to_stride: 128\nuse_padded_im_info: true\n- batch_size: 8\n+ batch_size: 1\nshuffle: false\n- worker_num: 2\n+ worker_num: 1\nuse_process: false\nTestReader:\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/anchor_free/fcos_r50_fpn_1x.yml",
"new_path": "configs/anchor_free/fcos_r50_fpn_1x.yml",
"diff": "@@ -8,7 +8,7 @@ save_dir: output\npretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar\nmetric: COCO\nweights: output/fcos_r50_fpn_1x/model_final\n-num_classes: 81\n+num_classes: 80\nFCOS:\nbackbone: ResNet\n@@ -31,7 +31,7 @@ FPN:\nhas_extra_convs: true\nFCOSHead:\n- num_classes: 81\n+ num_classes: 80\nfpn_stride: [8, 16, 32, 64, 128]\nnum_convs: 4\nnorm_type: \"gn\"\n@@ -80,7 +80,7 @@ TrainReader:\nimage_dir: train2017\nanno_path: annotations/instances_train2017.json\ndataset_dir: dataset/coco\n- with_background: true\n+ with_background: false\nsample_transforms:\n- !DecodeImage\nto_rgb: true\n@@ -110,7 +110,7 @@ TrainReader:\nnorm_reg_targets: True\nbatch_size: 2\nshuffle: true\n- worker_num: 16\n+ worker_num: 4\nuse_process: false\nEvalReader:\n@@ -143,7 +143,7 @@ EvalReader:\n- !PadBatch\npad_to_stride: 128\nuse_padded_im_info: true\n- batch_size: 8\n+ batch_size: 1\nshuffle: false\nworker_num: 2\nuse_process: false\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/anchor_free/fcos_r50_fpn_multiscale_2x.yml",
"new_path": "configs/anchor_free/fcos_r50_fpn_multiscale_2x.yml",
"diff": "@@ -8,7 +8,7 @@ save_dir: output\npretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar\nmetric: COCO\nweights: output/fcos_r50_fpn_multiscale_2x/model_final\n-num_classes: 81\n+num_classes: 80\nFCOS:\nbackbone: ResNet\n@@ -31,7 +31,7 @@ FPN:\nhas_extra_convs: true\nFCOSHead:\n- num_classes: 81\n+ num_classes: 80\nfpn_stride: [8, 16, 32, 64, 128]\nnum_convs: 4\nnorm_type: \"gn\"\n@@ -80,7 +80,7 @@ TrainReader:\nimage_dir: train2017\nanno_path: annotations/instances_train2017.json\ndataset_dir: dataset/coco\n- with_background: true\n+ with_background: false\nsample_transforms:\n- !DecodeImage\nto_rgb: true\n@@ -110,7 +110,7 @@ TrainReader:\nnorm_reg_targets: True\nbatch_size: 2\nshuffle: true\n- worker_num: 16\n+ worker_num: 4\nuse_process: false\nEvalReader:\n@@ -143,7 +143,7 @@ EvalReader:\n- !PadBatch\npad_to_stride: 128\nuse_padded_im_info: true\n- batch_size: 8\n+ batch_size: 1\nshuffle: false\nworker_num: 2\nuse_process: false\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/data/transform/batch_operators.py",
"new_path": "ppdet/data/transform/batch_operators.py",
"diff": "@@ -439,7 +439,7 @@ class Gt2FCOSTarget(BaseOperator):\npoints2gtarea[is_match_current_level == 0] = self.INF\npoints2min_area = points2gtarea.min(axis=1)\npoints2min_area_ind = points2gtarea.argmin(axis=1)\n- labels = gt_class[points2min_area_ind]\n+ labels = gt_class[points2min_area_ind] + 1\nlabels[points2min_area == self.INF] = 0\nreg_targets = reg_targets[range(xs.shape[0]), points2min_area_ind]\nctn_targets = np.sqrt((reg_targets[:, [0, 2]].min(axis=1) / \\\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/anchor_heads/fcos_head.py",
"new_path": "ppdet/modeling/anchor_heads/fcos_head.py",
"diff": "@@ -50,7 +50,7 @@ class FCOSHead(object):\n__shared__ = ['num_classes']\ndef __init__(self,\n- num_classes=81,\n+ num_classes=80,\nfpn_stride=[8, 16, 32, 64, 128],\nprior_prob=0.01,\nnum_convs=4,\n@@ -65,7 +65,7 @@ class FCOSHead(object):\nkeep_top_k=100,\nnms_threshold=0.45,\nbackground_label=-1).__dict__):\n- self.num_classes = num_classes - 1\n+ self.num_classes = num_classes\nself.fpn_stride = fpn_stride[::-1]\nself.prior_prob = prior_prob\nself.num_convs = num_convs\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | keep the option 'num_classes' and 'with_background' consistent (#722) |
499,400 | 19.05.2020 15:55:01 | -28,800 | 50bc85d266d04e736eb095f46d6b82cfc55c32c2 | Fix eval_run in pruning script | [
{
"change_type": "MODIFY",
"old_path": "slim/prune/prune.py",
"new_path": "slim/prune/prune.py",
"diff": "@@ -307,6 +307,9 @@ def main():\nif FLAGS.eval:\n# evaluation\n+ resolution = None\n+ if 'Mask' in cfg.architecture:\n+ resolution = model.mask_head.resolution\nresults = eval_run(\nexe,\ncompiled_eval_prog,\n@@ -314,10 +317,8 @@ def main():\neval_keys,\neval_values,\neval_cls,\n- cfg=cfg)\n- resolution = None\n- if 'mask' in results[0]:\n- resolution = model.mask_head.resolution\n+ cfg=cfg,\n+ resolution=resolution)\nbox_ap_stats = eval_results(\nresults,\ncfg.metric,\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Fix eval_run in pruning script (#724) |
499,304 | 21.05.2020 09:55:26 | -28,800 | d10c36148fdc2cfa4ecd2c606aa7a7da906ad0d3 | fix cpp deploy in windows | [
{
"change_type": "MODIFY",
"old_path": "deploy/cpp/CMakeLists.txt",
"new_path": "deploy/cpp/CMakeLists.txt",
"diff": "@@ -9,6 +9,7 @@ option(WITH_TENSORRT \"Compile demo with TensorRT.\" OFF)\nSET(PADDLE_DIR \"\" CACHE PATH \"Location of libraries\")\nSET(OPENCV_DIR \"\" CACHE PATH \"Location of libraries\")\nSET(CUDA_LIB \"\" CACHE PATH \"Location of libraries\")\n+SET(CUDNN_LIB \"\" CACHE PATH \"Location of libraries\")\nSET(TENSORRT_DIR \"\" CACHE PATH \"Compile demo with TensorRT\")\ninclude(cmake/yaml-cpp.cmake)\n@@ -51,7 +52,6 @@ endif()\nif(EXISTS \"${PADDLE_DIR}/third_party/install/snappystream/include\")\ninclude_directories(\"${PADDLE_DIR}/third_party/install/snappystream/include\")\nendif()\n-include_directories(\"${PADDLE_DIR}/third_party/install/zlib/include\")\ninclude_directories(\"${PADDLE_DIR}/third_party/boost\")\ninclude_directories(\"${PADDLE_DIR}/third_party/eigen3\")\n@@ -62,7 +62,6 @@ if(EXISTS \"${PADDLE_DIR}/third_party/install/snappystream/lib\")\nlink_directories(\"${PADDLE_DIR}/third_party/install/snappystream/lib\")\nendif()\n-link_directories(\"${PADDLE_DIR}/third_party/install/zlib/lib\")\nlink_directories(\"${PADDLE_DIR}/third_party/install/protobuf/lib\")\nlink_directories(\"${PADDLE_DIR}/third_party/install/glog/lib\")\nlink_directories(\"${PADDLE_DIR}/third_party/install/gflags/lib\")\n@@ -183,7 +182,7 @@ if (NOT WIN32)\nelse()\nset(DEPS ${DEPS}\n${MATH_LIB} ${MKLDNN_LIB}\n- glog gflags_static libprotobuf zlibstatic xxhash libyaml-cppmt)\n+ glog gflags_static libprotobuf xxhash libyaml-cppmt)\nset(DEPS ${DEPS} libcmt shlwapi)\nif (EXISTS \"${PADDLE_DIR}/third_party/install/snappy/lib\")\nset(DEPS ${DEPS} snappy)\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix cpp deploy in windows (#747) |
499,385 | 21.05.2020 10:34:14 | 18,000 | f95da6bebff0f043ac03928fc4f9caa27d48e343 | Fix deploy/cpp/src/object_detector.cc | [
{
"change_type": "MODIFY",
"old_path": "deploy/cpp/src/object_detector.cc",
"new_path": "deploy/cpp/src/object_detector.cc",
"diff": "@@ -19,8 +19,8 @@ namespace PaddleDetection {\n// Load Model and create model predictor\nvoid ObjectDetector::LoadModel(const std::string& model_dir,\nbool use_gpu,\n- const int batch_size,\nconst int min_subgraph_size,\n+ const int batch_size,\nconst std::string& run_mode) {\npaddle::AnalysisConfig config;\nstd::string prog_file = model_dir + OS_PATH_SEP + \"__model__\";\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Fix deploy/cpp/src/object_detector.cc (#755) |
499,333 | 28.05.2020 21:22:26 | -28,800 | b4ea26999382111c78a9d7d04b98b0f3f0c6e11f | update elementwise in cornernet | [
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/anchor_heads/corner_head.py",
"new_path": "ppdet/modeling/anchor_heads/corner_head.py",
"diff": "@@ -358,8 +358,13 @@ class CornerHead(object):\ntag1 = fluid.layers.squeeze(br_tag, [2])\ntag_mean = (tag0 + tag1) / 2\n- tag0 = fluid.layers.pow(tag0 - tag_mean, 2) / (num + 1e-4) * gt_masks\n- tag1 = fluid.layers.pow(tag1 - tag_mean, 2) / (num + 1e-4) * gt_masks\n+ tag0 = fluid.layers.pow(tag0 - tag_mean, 2)\n+ tag1 = fluid.layers.pow(tag1 - tag_mean, 2)\n+\n+ tag0 = fluid.layers.elementwise_div(tag0, num + 1e-4, axis=0)\n+ tag1 = fluid.layers.elementwise_div(tag1, num + 1e-4, axis=0)\n+ tag0 = tag0 * gt_masks\n+ tag1 = tag1 * gt_masks\ntag0 = fluid.layers.reduce_sum(tag0)\ntag1 = fluid.layers.reduce_sum(tag1)\n@@ -381,8 +386,8 @@ class CornerHead(object):\ndist = tag_mean_1 - tag_mean_2\ndist = 1 - fluid.layers.abs(dist)\ndist = fluid.layers.relu(dist)\n- dist = dist - 1 / (num + 1e-4)\n- dist = dist / (num2 + 1e-4)\n+ dist = fluid.layers.elementwise_sub(dist, 1 / (num + 1e-4), axis=0)\n+ dist = fluid.layers.elementwise_div(dist, (num2 + 1e-4), axis=0)\ndist = dist * mask\npush = fluid.layers.reduce_sum(dist)\nreturn pull, push\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | update elementwise in cornernet (#804) |
499,311 | 03.06.2020 14:30:14 | -28,800 | 32fb7a7185374ef9e0314665ea43bdd3329bb799 | fix cpp bug cannot load video | [
{
"change_type": "MODIFY",
"old_path": "deploy/cpp/include/object_detector.h",
"new_path": "deploy/cpp/include/object_detector.h",
"diff": "@@ -54,12 +54,14 @@ cv::Mat VisualizeResult(const cv::Mat& img,\nclass ObjectDetector {\npublic:\n- explicit ObjectDetector(const std::string& model_dir, bool use_gpu = false,\n- const std::string& run_mode = \"fluid\") {\n+ explicit ObjectDetector(const std::string& model_dir,\n+ bool use_gpu=false,\n+ const std::string& run_mode=\"fluid\",\n+ const int gpu_id=0) {\nconfig_.load_config(model_dir);\nthreshold_ = config_.draw_threshold_;\npreprocessor_.Init(config_.preprocess_info_, config_.arch_);\n- LoadModel(model_dir, use_gpu, config_.min_subgraph_size_, 1, run_mode);\n+ LoadModel(model_dir, use_gpu, config_.min_subgraph_size_, 1, run_mode, gpu_id);\n}\n// Load Paddle inference model\n@@ -68,7 +70,8 @@ class ObjectDetector {\nbool use_gpu,\nconst int min_subgraph_size,\nconst int batch_size = 1,\n- const std::string& run_mode = \"fluid\");\n+ const std::string& run_mode = \"fluid\",\n+ const int gpu_id=0);\n// Run predictor\nvoid Predict(\n"
},
{
"change_type": "MODIFY",
"old_path": "deploy/cpp/scripts/bootstrap.sh",
"new_path": "deploy/cpp/scripts/bootstrap.sh",
"diff": "# download pre-compiled opencv lib\n+#OPENCV_URL=https://bj.bcebos.com/paddleseg/deploy/opencv3.4.6gcc4.8ffmpeg.tar.gz2\n+#if [ ! -d \"./deps/opencv3.4.6gcc4.8ffmpeg/\" ]; then\n+# mkdir -p deps\n+# cd deps\n+# wget -c ${OPENCV_URL}\n+# tar xvfj opencv3.4.6gcc4.8ffmpeg.tar.gz2\n+# cd ..\n+#fi\nOPENCV_URL=https://paddleseg.bj.bcebos.com/deploy/docker/opencv3gcc4.8.tar.bz2\nif [ ! -d \"./deps/opencv3gcc4.8\" ]; then\nmkdir -p deps\n"
},
{
"change_type": "MODIFY",
"old_path": "deploy/cpp/src/main.cc",
"new_path": "deploy/cpp/src/main.cc",
"diff": "@@ -25,7 +25,8 @@ 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_string(run_mode, \"fluid\", \"mode of running(fluid/trt_fp32/trt_fp16)\");\n+DEFINE_string(run_mode, \"fluid\", \"Mode of running(fluid/trt_fp32/trt_fp16)\");\n+DEFINE_int32(gpu_id, 0, \"Device id of GPU to execute\");\nvoid PredictVideo(const std::string& video_path,\nPaddleDetection::ObjectDetector* det) {\n@@ -44,9 +45,9 @@ void PredictVideo(const std::string& video_path,\n// Create VideoWriter for output\ncv::VideoWriter video_out;\n- std::string video_out_path = \"output.avi\";\n+ std::string video_out_path = \"output.mp4\";\nvideo_out.open(video_out_path.c_str(),\n- CV_FOURCC('M', 'J', 'P', 'G'),\n+ 0x00000021,\nvideo_fps,\ncv::Size(video_width, video_height),\ntrue);\n@@ -60,6 +61,7 @@ void PredictVideo(const std::string& video_path,\nauto colormap = PaddleDetection::GenerateColorMap(labels.size());\n// Capture all frames and do inference\ncv::Mat frame;\n+ int frame_id = 0;\nwhile (capture.read(frame)) {\nif (frame.empty()) {\nbreak;\n@@ -67,7 +69,18 @@ void PredictVideo(const std::string& video_path,\ndet->Predict(frame, &result);\ncv::Mat out_im = PaddleDetection::VisualizeResult(\nframe, result, labels, colormap);\n+ for (const auto& item : result) {\n+ printf(\"In frame id %d, we detect: class=%d confidence=%.2f rect=[%d %d %d %d]\\n\",\n+ frame_id,\n+ item.class_id,\n+ item.confidence,\n+ item.rect[0],\n+ item.rect[1],\n+ item.rect[2],\n+ item.rect[3]);\n+ }\nvideo_out.write(out_im);\n+ frame_id += 1;\n}\ncapture.release();\nvideo_out.release();\n@@ -97,7 +110,7 @@ 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.jpeg\", vis_img, compression_params);\n+ cv::imwrite(\"output.jpg\", vis_img, compression_params);\nprintf(\"Visualized output saved as output.jpeg\\n\");\n}\n@@ -118,7 +131,7 @@ int main(int argc, char** argv) {\n// Load model and create a object detector\nPaddleDetection::ObjectDetector det(FLAGS_model_dir, FLAGS_use_gpu,\n- FLAGS_run_mode);\n+ FLAGS_run_mode, FLAGS_gpu_id);\n// Do inference on input video or image\nif (!FLAGS_video_path.empty()) {\nPredictVideo(FLAGS_video_path, &det);\n"
},
{
"change_type": "MODIFY",
"old_path": "deploy/cpp/src/object_detector.cc",
"new_path": "deploy/cpp/src/object_detector.cc",
"diff": "@@ -21,13 +21,14 @@ void ObjectDetector::LoadModel(const std::string& model_dir,\nbool use_gpu,\nconst int min_subgraph_size,\nconst int batch_size,\n- const std::string& run_mode) {\n+ const std::string& run_mode,\n+ const int gpu_id) {\npaddle::AnalysisConfig config;\nstd::string prog_file = model_dir + OS_PATH_SEP + \"__model__\";\nstd::string params_file = model_dir + OS_PATH_SEP + \"__params__\";\nconfig.SetModel(prog_file, params_file);\nif (use_gpu) {\n- config.EnableUseGpu(100, 0);\n+ config.EnableUseGpu(100, gpu_id);\nif (run_mode != \"fluid\") {\nauto precision = paddle::AnalysisConfig::Precision::kFloat32;\nif (run_mode == \"trt_fp16\") {\n@@ -187,7 +188,6 @@ void ObjectDetector::Predict(const cv::Mat& im,\nif (output_size < 6) {\nstd::cerr << \"[WARNING] No object detected.\" << std::endl;\n- return true;\n}\noutput_data_.resize(output_size);\nout_tensor->copy_to_cpu(output_data_.data());\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix cpp bug cannot load video (#845) |
499,333 | 03.06.2020 20:37:25 | -28,800 | 5a3a85a5fdf4440befccfebd48cbef997ecefa22 | fix check.py | [
{
"change_type": "MODIFY",
"old_path": "ppdet/utils/check.py",
"new_path": "ppdet/utils/check.py",
"diff": "@@ -66,6 +66,8 @@ def check_version(version='1.7.0'):\nlength = min(len(version_installed), len(version_split))\nfor i in six.moves.range(length):\n+ if version_installed[i] > version_split[i]:\n+ return\nif version_installed[i] < version_split[i]:\nraise Exception(err)\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix check.py (#865) |
499,385 | 08.06.2020 12:48:28 | -28,800 | 377a5ce1269c7f05b5f19b72360bd1a6800b8454 | Clean fluid.compiler.CompiledProgram | [
{
"change_type": "MODIFY",
"old_path": "slim/distillation/distill.py",
"new_path": "slim/distillation/distill.py",
"diff": "@@ -305,7 +305,7 @@ def main():\nbuild_strategy=build_strategy,\nexec_strategy=exec_strategy)\n- compiled_eval_prog = fluid.compiler.CompiledProgram(eval_prog)\n+ compiled_eval_prog = fluid.CompiledProgram(eval_prog)\n# whether output bbox is normalized in model output layer\nis_bbox_normalized = False\n"
},
{
"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": "@@ -276,7 +276,7 @@ def main():\nloss_name=loss.name,\nbuild_strategy=build_strategy,\nexec_strategy=exec_strategy)\n- compiled_eval_prog = fluid.compiler.CompiledProgram(eval_prog)\n+ compiled_eval_prog = fluid.CompiledProgram(eval_prog)\n# parse eval fetches\nextra_keys = []\n"
},
{
"change_type": "MODIFY",
"old_path": "slim/nas/train_nas.py",
"new_path": "slim/nas/train_nas.py",
"diff": "@@ -323,7 +323,7 @@ def main():\nbuild_strategy=build_strategy,\nexec_strategy=exec_strategy)\nif FLAGS.eval:\n- compiled_eval_prog = fluid.compiler.CompiledProgram(eval_prog)\n+ compiled_eval_prog = fluid.CompiledProgram(eval_prog)\ntrain_loader.set_sample_list_generator(train_reader, place)\n"
},
{
"change_type": "MODIFY",
"old_path": "slim/prune/eval.py",
"new_path": "slim/prune/eval.py",
"diff": "@@ -119,8 +119,7 @@ def main():\nlogger.info(\"pruned FLOPS: {}\".format(\nfloat(base_flops - pruned_flops) / base_flops))\n- compile_program = fluid.compiler.CompiledProgram(\n- eval_prog).with_data_parallel()\n+ compile_program = fluid.CompiledProgram(eval_prog).with_data_parallel()\nassert cfg.metric != 'OID', \"eval process of OID dataset \\\nis not supported.\"\n"
},
{
"change_type": "MODIFY",
"old_path": "slim/prune/prune.py",
"new_path": "slim/prune/prune.py",
"diff": "@@ -215,7 +215,7 @@ def main():\nlogger.info(\"FLOPs -{}; total FLOPs: {}; pruned FLOPs: {}\".format(\nfloat(base_flops - pruned_flops) / base_flops, base_flops,\npruned_flops))\n- compiled_eval_prog = fluid.compiler.CompiledProgram(eval_prog)\n+ compiled_eval_prog = fluid.CompiledProgram(eval_prog)\nif FLAGS.resume_checkpoint:\ncheckpoint.load_checkpoint(exe, train_prog, FLAGS.resume_checkpoint)\n"
},
{
"change_type": "MODIFY",
"old_path": "slim/quantization/eval.py",
"new_path": "slim/quantization/eval.py",
"diff": "@@ -132,8 +132,7 @@ def main():\ncheckpoint.load_params(exe, eval_prog, cfg.weights)\neval_prog = convert(eval_prog, place, config, save_int8=False)\n- compile_program = fluid.compiler.CompiledProgram(\n- eval_prog).with_data_parallel()\n+ compile_program = fluid.CompiledProgram(eval_prog).with_data_parallel()\nresults = eval_run(exe, compile_program, loader, keys, values, cls, cfg,\nsub_eval_prog, sub_keys, sub_values)\n"
},
{
"change_type": "MODIFY",
"old_path": "slim/quantization/train.py",
"new_path": "slim/quantization/train.py",
"diff": "@@ -200,7 +200,7 @@ def main():\nif FLAGS.eval:\n# insert quantize op in eval_prog\neval_prog = quant_aware(eval_prog, place, config, for_test=True)\n- compiled_eval_prog = fluid.compiler.CompiledProgram(eval_prog)\n+ compiled_eval_prog = fluid.CompiledProgram(eval_prog)\nstart_iter = 0\nif FLAGS.resume_checkpoint:\n"
},
{
"change_type": "MODIFY",
"old_path": "slim/sensitive/sensitive.py",
"new_path": "slim/sensitive/sensitive.py",
"diff": "@@ -122,7 +122,7 @@ def main():\ndef test(program):\n- compiled_eval_prog = fluid.compiler.CompiledProgram(program)\n+ compiled_eval_prog = fluid.CompiledProgram(program)\nresults = eval_run(\nexe,\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/eval.py",
"new_path": "tools/eval.py",
"diff": "@@ -88,8 +88,7 @@ def main():\ncfg.metric, json_directory=FLAGS.output_eval, dataset=dataset)\nreturn\n- compile_program = fluid.compiler.CompiledProgram(\n- eval_prog).with_data_parallel()\n+ compile_program = fluid.CompiledProgram(eval_prog).with_data_parallel()\nassert cfg.metric != 'OID', \"eval process of OID dataset \\\nis not supported.\"\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/train.py",
"new_path": "tools/train.py",
"diff": "@@ -180,7 +180,7 @@ def main():\nexec_strategy=exec_strategy)\nif FLAGS.eval:\n- compiled_eval_prog = fluid.compiler.CompiledProgram(eval_prog)\n+ compiled_eval_prog = fluid.CompiledProgram(eval_prog)\nfuse_bn = getattr(model.backbone, 'norm_type', None) == 'affine_channel'\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Clean fluid.compiler.CompiledProgram (#891) |
499,385 | 08.06.2020 14:14:41 | -28,800 | f1b91931f1645d94d2b2e9612fb9fd62e4726665 | Add Python version description for ViualDL | [
{
"change_type": "MODIFY",
"old_path": "docs/tutorials/QUICK_STARTED.md",
"new_path": "docs/tutorials/QUICK_STARTED.md",
"diff": "@@ -20,6 +20,14 @@ python dataset/fruit/download_fruit.py\nTraining:\n+```bash\n+python -u tools/train.py -c configs/yolov3_mobilenet_v1_fruit.yml --eval\n+```\n+\n+Use `yolov3_mobilenet_v1` to fine-tune the model from COCO dataset.\n+\n+Meanwhile, loss and mAP can be observed on VisualDL by set `--use_vdl` and `--vdl_log_dir`. But note Python version required >= 3.5 for VisualDL.\n+\n```bash\npython -u tools/train.py -c configs/yolov3_mobilenet_v1_fruit.yml \\\n--use_vdl=True \\\n@@ -27,7 +35,7 @@ python -u tools/train.py -c configs/yolov3_mobilenet_v1_fruit.yml \\\n--eval\n```\n-Use `yolov3_mobilenet_v1` to fine-tune the model from COCO dataset. Meanwhile, loss and mAP can be observed on VisualDL.\n+Then observe the loss and mAP curve through VisualDL command:\n```bash\nvisualdl --logdir vdl_fruit_dir/scalar/ --host <host_IP> --port <port_num>\n@@ -35,7 +43,9 @@ visualdl --logdir vdl_fruit_dir/scalar/ --host <host_IP> --port <port_num>\nResult on VisualDL is shown below:\n-\n+<div align=\"center\">\n+ <img src='../images/visualdl_fruit.jpg' width='800'>\n+</div>\nModel can be downloaded [here](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_fruit.tar)\n@@ -55,8 +65,13 @@ python -u tools/infer.py -c configs/yolov3_mobilenet_v1_fruit.yml \\\nInference images are shown below:\n+<div align=\"center\">\n+ <img src='../../demo/orange_71.jpg' width='600'>\n+</div>\n+\n-\n-\n+<div align=\"center\">\n+ <img src='../images/orange_71_detection.jpg' width='600'>\n+</div>\nFor detailed infomation of training and evalution, please refer to [GETTING_STARTED.md](GETTING_STARTED.md).\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Add Python version description for ViualDL (#895) |
499,333 | 09.06.2020 14:53:00 | -28,800 | 2f6b2ec24d1de1cca484eb890e851295f974d1c2 | support fcos on voc | [
{
"change_type": "MODIFY",
"old_path": "configs/anchor_free/fcos_dcn_r50_fpn_1x.yml",
"new_path": "configs/anchor_free/fcos_dcn_r50_fpn_1x.yml",
"diff": "@@ -75,7 +75,7 @@ OptimizerBuilder:\nTrainReader:\ninputs_def:\n- fields: ['image', 'gt_bbox', 'gt_class', 'gt_score', 'im_info']\n+ fields: ['image', 'im_info', 'fcos_target']\ndataset:\n!COCODataSet\nimage_dir: train2017\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/anchor_free/fcos_r50_fpn_1x.yml",
"new_path": "configs/anchor_free/fcos_r50_fpn_1x.yml",
"diff": "@@ -74,7 +74,7 @@ OptimizerBuilder:\nTrainReader:\ninputs_def:\n- fields: ['image', 'gt_bbox', 'gt_class', 'gt_score', 'im_info']\n+ fields: ['image', 'im_info', 'fcos_target']\ndataset:\n!COCODataSet\nimage_dir: train2017\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/anchor_free/fcos_r50_fpn_multiscale_2x.yml",
"new_path": "configs/anchor_free/fcos_r50_fpn_multiscale_2x.yml",
"diff": "@@ -74,7 +74,7 @@ OptimizerBuilder:\nTrainReader:\ninputs_def:\n- fields: ['image', 'gt_bbox', 'gt_class', 'gt_score', 'im_info']\n+ fields: ['image', 'im_info', 'fcos_target']\ndataset:\n!COCODataSet\nimage_dir: train2017\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/architectures/fcos.py",
"new_path": "ppdet/modeling/architectures/fcos.py",
"diff": "@@ -107,7 +107,7 @@ class FCOS(object):\n'is_difficult': {'shape': [None, 1], 'dtype': 'int32', 'lod_level': 1}\n}\n# yapf: disable\n- if 'gt_bbox' in fields:\n+ if 'fcos_target' in fields:\ntargets_def = {\n'labels0': {'shape': [None, None, None, 1], 'dtype': 'int32', 'lod_level': 0},\n'reg_target0': {'shape': [None, None, None, 4], 'dtype': 'float32', 'lod_level': 0},\n@@ -152,16 +152,15 @@ class FCOS(object):\ndef build_inputs(\nself,\nimage_shape=[3, None, None],\n- fields=[\n- 'image', 'im_shape', 'im_id', 'gt_bbox', 'gt_class', 'is_crowd'\n- ], # for-train\n+ fields=['image', 'im_info', 'fcos_target'], # for-train\nuse_dataloader=True,\niterable=False):\ninputs_def = self._inputs_def(image_shape, fields)\n- if \"gt_bbox\" in fields:\n+ if \"fcos_target\" in fields:\nfor i in range(len(self.fcos_head.fpn_stride)):\nfields.extend(\n['labels%d' % i, 'reg_target%d' % i, 'centerness%d' % i])\n+ fields.remove('fcos_target')\nfeed_vars = OrderedDict([(key, fluid.data(\nname=key,\nshape=inputs_def[key]['shape'],\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | support fcos on voc (#902) |
499,313 | 12.06.2020 11:13:59 | -28,800 | e77baea4741c82b6922d21e5047d4cddf4ff0fbd | check extra_conv needed in mobilenet_v3 | [
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/backbones/mobilenet_v3.py",
"new_path": "ppdet/modeling/backbones/mobilenet_v3.py",
"diff": "@@ -393,6 +393,8 @@ class MobileNetV3(object):\nself.end_points.append(conv)\n# extra block\n+ # check whether conv_extra is needed\n+ if self.block_stride < max(self.feature_maps):\nconv_extra = self._conv_bn_layer(\nconv,\nfilter_size=1,\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | check extra_conv needed in mobilenet_v3 (#933) |
499,333 | 17.06.2020 12:28:15 | -28,800 | 27fd71382a4f32db4c558ccb86a7b41c7916555d | add python version check for visualdl | [
{
"change_type": "MODIFY",
"old_path": "docs/tutorials/GETTING_STARTED.md",
"new_path": "docs/tutorials/GETTING_STARTED.md",
"diff": "@@ -41,8 +41,8 @@ list below can be viewed by `--help`\n| --draw_threshold | infer | Threshold to reserve the result for visualization | 0.5 | `--draw_threshold 0.7` |\n| --infer_dir | infer | Directory for images to perform inference on | None | |\n| --infer_img | infer | Image path | None | higher priority over --infer_dir |\n-| --use_vdl | train/infer | Whether to record the data with [VisualDL](https://github.com/paddlepaddle/visualdl), so as to display in VisualDL | False | |\n-| --vdl\\_log_dir | train/infer | VisualDL logging directory for image | train:`vdl_log_dir/scalar` infer: `vdl_log_dir/image` | |\n+| --use_vdl | train/infer | Whether to record the data with [VisualDL](https://github.com/paddlepaddle/visualdl), so as to display in VisualDL | False | VisualDL requires Python>=3.5 |\n+| --vdl\\_log_dir | train/infer | VisualDL logging directory for image | train:`vdl_log_dir/scalar` infer: `vdl_log_dir/image` | VisualDL requires Python>=3.5 |\n## Examples\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/infer.py",
"new_path": "tools/infer.py",
"diff": "@@ -24,6 +24,7 @@ if parent_path not in sys.path:\nimport glob\nimport numpy as np\n+import six\nfrom PIL import Image\nfrom paddle import fluid\n@@ -160,6 +161,7 @@ def main():\n# use VisualDL to log image\nif FLAGS.use_vdl:\n+ assert six.PY3, \"VisualDL requires Python >= 3.5\"\nfrom visualdl import LogWriter\nvdl_writer = LogWriter(FLAGS.vdl_log_dir)\nvdl_image_step = 0\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/train.py",
"new_path": "tools/train.py",
"diff": "@@ -26,6 +26,7 @@ import time\nimport numpy as np\nimport random\nimport datetime\n+import six\nfrom collections import deque\nfrom paddle.fluid import profiler\n@@ -224,6 +225,7 @@ def main():\n# use VisualDL to log data\nif FLAGS.use_vdl:\n+ assert six.PY3, \"VisualDL requires Python >= 3.5\"\nfrom visualdl import LogWriter\nvdl_writer = LogWriter(FLAGS.vdl_log_dir)\nvdl_loss_step = 0\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | add python version check for visualdl (#951) |
499,333 | 30.06.2020 19:18:07 | -28,800 | ce5ab17279c96a540b3d381d4379a35612e60dfe | support multi-batch for faster-rcnn & mask-rcnn | [
{
"change_type": "MODIFY",
"old_path": "configs/faster_reader.yml",
"new_path": "configs/faster_reader.yml",
"diff": "@@ -24,6 +24,10 @@ TrainReader:\n- !Permute\nto_bgr: false\nchannel_first: true\n+ batch_transforms:\n+ - !PadBatch\n+ pad_to_stride: -1.\n+ use_padded_im_info: false\nbatch_size: 1\nshuffle: true\nworker_num: 2\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/mask_reader.yml",
"new_path": "configs/mask_reader.yml",
"diff": "@@ -25,6 +25,10 @@ TrainReader:\n- !Permute\nto_bgr: false\nchannel_first: true\n+ batch_transforms:\n+ - !PadBatch\n+ pad_to_stride: -1.\n+ use_padded_im_info: false\nbatch_size: 1\nshuffle: true\nworker_num: 2\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | support multi-batch for faster-rcnn & mask-rcnn (#998) |
499,304 | 06.07.2020 15:27:15 | -28,800 | 2a3cafdcfc113dd222ce5193f98a045e6f72f5e2 | fix modelzoo and custom dataset docs error | [
{
"change_type": "MODIFY",
"old_path": "docs/MODEL_ZOO.md",
"new_path": "docs/MODEL_ZOO.md",
"diff": "@@ -196,7 +196,7 @@ results of image size 608/416/320 above. Deformable conv is added on stage 5 of\n| MobileNet_v1 | 300 | 64 | Cosine decay(40w) | - | 23.6 | [model](https://paddlemodels.bj.bcebos.com/object_detection/ssdlite_mobilenet_v1.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/ssd/ssdlite_mobilenet_v1.yml) |\n| MobileNet_v3 small | 320 | 64 | Cosine decay(40w) | - | 16.2 | [model](https://paddlemodels.bj.bcebos.com/object_detection/mobile_models/ssdlite_mobilenet_v3_small.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/ssd/ssdlite_mobilenet_v3_small.yml) |\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 large 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 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**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": "docs/tutorials/QUICK_STARTED.md",
"new_path": "docs/tutorials/QUICK_STARTED.md",
"diff": "@@ -43,9 +43,7 @@ visualdl --logdir vdl_fruit_dir/scalar/ --host <host_IP> --port <port_num>\nResult on VisualDL is shown below:\n-<div align=\"center\">\n- <img src='../images/visualdl_fruit.jpg' width='800'>\n-</div>\n+\nModel can be downloaded [here](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_fruit.tar)\n@@ -65,13 +63,8 @@ python -u tools/infer.py -c configs/yolov3_mobilenet_v1_fruit.yml \\\nInference images are shown below:\n-<div align=\"center\">\n- <img src='../../demo/orange_71.jpg' width='600'>\n-</div>\n+\n-\n-<div align=\"center\">\n- <img src='../images/orange_71_detection.jpg' width='600'>\n-</div>\n+\nFor detailed infomation of training and evalution, please refer to [GETTING_STARTED.md](GETTING_STARTED.md).\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix modelzoo and custom dataset docs error (#1019) |
499,304 | 06.07.2020 16:38:40 | -28,800 | a66dfe9c64aea16c9a0e5c15f5d5ac7576fe7e04 | fix softnms type error | [
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/ops.py",
"new_path": "ppdet/modeling/ops.py",
"diff": "@@ -610,7 +610,7 @@ class MultiClassSoftNMS(object):\nres.set_lod([out_offsets])\nif len(pred_res) == 0:\npred_res = np.array([[1]], dtype=np.float32)\n- res.set(np.vstack(pred_res), fluid.CPUPlace())\n+ res.set(np.vstack(pred_res).astype(np.float32), fluid.CPUPlace())\nreturn res\npred_result = create_tmp_var(\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix softnms type error (#1020) |
499,304 | 08.07.2020 12:44:45 | -28,800 | fb650fbb854b52ac5e9c62f8a496f0ad9da6e942 | fix cascade_cbr200 configs error | [
{
"change_type": "MODIFY",
"old_path": "configs/dcn/cascade_rcnn_cbr200_vd_fpn_dcnv2_nonlocal_softnms.yml",
"new_path": "configs/dcn/cascade_rcnn_cbr200_vd_fpn_dcnv2_nonlocal_softnms.yml",
"diff": "@@ -112,8 +112,8 @@ TrainReader:\nfields: ['image', 'im_info', 'im_id', 'gt_bbox', 'gt_class', 'is_crowd']\ndataset:\n!COCODataSet\n- image_dir: val2017\n- anno_path: annotations/instances_val2017.json\n+ image_dir: train2017\n+ anno_path: annotations/instances_train2017.json\ndataset_dir: dataset/coco\nsample_transforms:\n- !DecodeImage\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix cascade_cbr200 configs error (#1031) |
499,304 | 08.07.2020 18:33:55 | -28,800 | c8c51ac7836e71121b9825d080055710ee3e89dc | fix use cv2 in face_detection | [
{
"change_type": "MODIFY",
"old_path": "configs/face_detection/blazeface_nas.yml",
"new_path": "configs/face_detection/blazeface_nas.yml",
"diff": "@@ -98,10 +98,6 @@ EvalReader:\n- !DecodeImage\nto_rgb: true\n- !NormalizeBox {}\n- - !ResizeImage\n- interp: 1\n- target_size: 640\n- use_cv2: false\n- !Permute {}\n- !NormalizeImage\nis_scale: false\n@@ -111,7 +107,6 @@ EvalReader:\nTestReader:\ninputs_def:\n- image_shape: [3,640,640]\nfields: ['image', 'im_id', 'im_shape']\ndataset:\n!ImageFolder\n@@ -119,10 +114,6 @@ TestReader:\nsample_transforms:\n- !DecodeImage\nto_rgb: true\n- - !ResizeImage\n- interp: 1\n- target_size: 640\n- use_cv2: false\n- !Permute {}\n- !NormalizeImage\nis_scale: false\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/face_detection/blazeface_nas_v2.yml",
"new_path": "configs/face_detection/blazeface_nas_v2.yml",
"diff": "@@ -7,7 +7,7 @@ log_smooth_window: 20\nlog_iter: 20\nmetric: WIDERFACE\nsave_dir: output\n-weights: output/blazeface_nas/model_final\n+weights: output/blazeface_nas_v2/model_final\n# 1(label_class) + 1(background)\nnum_classes: 2\n@@ -98,10 +98,6 @@ EvalReader:\n- !DecodeImage\nto_rgb: true\n- !NormalizeBox {}\n- - !ResizeImage\n- interp: 1\n- target_size: 640\n- use_cv2: false\n- !Permute {}\n- !NormalizeImage\nis_scale: false\n@@ -111,7 +107,6 @@ EvalReader:\nTestReader:\ninputs_def:\n- image_shape: [3,640,640]\nfields: ['image', 'im_id', 'im_shape']\ndataset:\n!ImageFolder\n@@ -119,10 +114,6 @@ TestReader:\nsample_transforms:\n- !DecodeImage\nto_rgb: true\n- - !ResizeImage\n- interp: 1\n- target_size: 640\n- use_cv2: false\n- !Permute {}\n- !NormalizeImage\nis_scale: false\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/face_eval.py",
"new_path": "tools/face_eval.py",
"diff": "@@ -25,7 +25,7 @@ if parent_path not in sys.path:\nimport paddle.fluid as fluid\nimport numpy as np\n-from PIL import Image\n+import cv2\nfrom collections import OrderedDict\nimport ppdet.utils.checkpoint as checkpoint\n@@ -81,9 +81,10 @@ def face_eval_run(exe,\nif eval_mode == 'fddb':\nimage_path += '.jpg'\nassert os.path.exists(image_path)\n- image = Image.open(image_path).convert('RGB')\n+ image = cv2.imread(image_path)\n+ image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\nif multi_scale:\n- shrink, max_shrink = get_shrink(image.size[1], image.size[0])\n+ shrink, max_shrink = get_shrink(image.shape[0], image.shape[1])\ndet0 = detect_face(exe, compile_program, fetches, image, shrink)\ndet1 = flip_test(exe, compile_program, fetches, image, shrink)\n[det2, det3] = multi_scale_test(exe, compile_program, fetches,\n@@ -106,10 +107,10 @@ def face_eval_run(exe,\ndef detect_face(exe, compile_program, fetches, image, shrink):\n- image_shape = [3, image.size[1], image.size[0]]\n+ image_shape = [3, image.shape[0], image.shape[1]]\nif shrink != 1:\nh, w = int(image_shape[1] * shrink), int(image_shape[2] * shrink)\n- image = image.resize((w, h), Image.ANTIALIAS)\n+ image = cv2.resize(image, (w, h))\nimage_shape = [3, h, w]\nimg = face_img_process(image)\n@@ -133,13 +134,13 @@ def detect_face(exe, compile_program, fetches, image, shrink):\ndef flip_test(exe, compile_program, fetches, image, shrink):\n- img = image.transpose(Image.FLIP_LEFT_RIGHT)\n+ img = cv2.flip(image, 1)\ndet_f = detect_face(exe, compile_program, fetches, img, shrink)\ndet_t = np.zeros(det_f.shape)\n- # image.size: [width, height]\n- det_t[:, 0] = image.size[0] - det_f[:, 2]\n+ img_width = image.shape[1]\n+ det_t[:, 0] = img_width - det_f[:, 2]\ndet_t[:, 1] = det_f[:, 1]\n- det_t[:, 2] = image.size[0] - det_f[:, 0]\n+ det_t[:, 2] = img_width - det_f[:, 0]\ndet_t[:, 3] = det_f[:, 3]\ndet_t[:, 4] = det_f[:, 4]\nreturn det_t\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix use cv2 in face_detection (#1034) |
499,304 | 09.07.2020 13:20:03 | -28,800 | 4d7ce6432e043adae6b464d9d47355ad290b46ff | Add conv_decay and relu6 in mobilenet | [
{
"change_type": "MODIFY",
"old_path": "configs/ssd/ssdlite_mobilenet_v1.yml",
"new_path": "configs/ssd/ssdlite_mobilenet_v1.yml",
"diff": "@@ -22,7 +22,7 @@ SSD:\nscore_threshold: 0.01\nMobileNet:\n- norm_decay: 0.0\n+ conv_decay: 0.00004\nconv_group_scale: 1\nextra_block_filters: [[256, 512], [128, 256], [128, 256], [64, 128]]\nwith_extra_blocks: true\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/backbones/mobilenet.py",
"new_path": "ppdet/modeling/backbones/mobilenet.py",
"diff": "@@ -34,6 +34,7 @@ class MobileNet(object):\nArgs:\nnorm_type (str): normalization type, 'bn' and 'sync_bn' are supported\nnorm_decay (float): weight decay for normalization layer weights\n+ conv_decay (float): weight decay for convolution layer weights.\nconv_group_scale (int): scaling factor for convolution groups\nwith_extra_blocks (bool): if extra blocks should be added\nextra_block_filters (list): number of filter for each extra block\n@@ -43,6 +44,7 @@ class MobileNet(object):\ndef __init__(self,\nnorm_type='bn',\nnorm_decay=0.,\n+ conv_decay=0.,\nconv_group_scale=1,\nconv_learning_rate=1.0,\nwith_extra_blocks=False,\n@@ -51,6 +53,7 @@ class MobileNet(object):\nweight_prefix_name=''):\nself.norm_type = norm_type\nself.norm_decay = norm_decay\n+ self.conv_decay = conv_decay\nself.conv_group_scale = conv_group_scale\nself.conv_learning_rate = conv_learning_rate\nself.with_extra_blocks = with_extra_blocks\n@@ -70,6 +73,7 @@ class MobileNet(object):\nparameter_attr = ParamAttr(\nlearning_rate=self.conv_learning_rate,\ninitializer=fluid.initializer.MSRA(),\n+ regularizer=L2Decay(self.conv_decay),\nname=name + \"_weights\")\nconv = fluid.layers.conv2d(\ninput=input,\n@@ -139,6 +143,7 @@ class MobileNet(object):\nstride=1,\nnum_groups=int(num_groups),\npadding=0,\n+ act='relu6',\nname=name + \"_extra1\")\nnormal_conv = self._conv_norm(\ninput=pointwise_conv,\n@@ -147,6 +152,7 @@ class MobileNet(object):\nstride=2,\nnum_groups=int(num_groups),\npadding=1,\n+ act='relu6',\nname=name + \"_extra2\")\nreturn normal_conv\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | Add conv_decay and relu6 in mobilenet (#1038) |
499,304 | 09.07.2020 20:06:51 | -28,800 | c3aad6b6709f48d012d240f7703026449ada2e10 | add yolov3_darknet diou_loss model | [
{
"change_type": "MODIFY",
"old_path": "docs/MODEL_ZOO.md",
"new_path": "docs/MODEL_ZOO.md",
"diff": "@@ -149,11 +149,12 @@ The backbone models pretrained on ImageNet are available. All backbone models ar\n### YOLO v3 on Pascal VOC\n-| Backbone | Size | Image/gpu | Lr schd | Inf time (fps) | Box AP | Download | Configs |\n+| Backbone | Size | Image/gpu | Lr schd | Inf time (fps) | Box AP(0.5) | Download | Configs |\n| :----------- | :--: | :-------: | :-----: | :------------: | :----: | :----------------------------------------------------------: | :----: |\n| DarkNet53 | 608 | 8 | 270e | 54.977 | 83.5 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_darknet_voc.tar) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/yolov3_darknet_voc.yml) |\n| DarkNet53 | 416 | 8 | 270e | - | 83.6 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_darknet_voc.tar) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/yolov3_darknet_voc.yml) |\n| DarkNet53 | 320 | 8 | 270e | - | 82.2 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_darknet_voc.tar) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/yolov3_darknet_voc.yml) |\n+| DarkNet53 Diou-Loss | 608 | 8 | 270e | - | 83.5 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_darknet_voc_diouloss.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/yolov3_darknet_voc_diouloss.yml) |\n| MobileNet-V1 | 608 | 8 | 270e | 104.291 | 76.2 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/yolov3_mobilenet_v1_voc.yml) |\n| MobileNet-V1 | 416 | 8 | 270e | - | 76.7 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/yolov3_mobilenet_v1_voc.yml) |\n| MobileNet-V1 | 320 | 8 | 270e | - | 75.3 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/yolov3_mobilenet_v1_voc.yml) |\n@@ -169,6 +170,7 @@ improved performance mainly by using L1 loss in bounding box width and height re\nrandomly color distortion, randomly cropping, randomly expansion, randomly interpolation method, randomly flippling. YOLO v3 used randomly\nreshaped minibatch in training, inferences can be performed on different image sizes with the same model weights, and we provided evaluation\nresults of image size 608/416/320 above. Deformable conv is added on stage 5 of backbone.\n+- Compared with YOLOv3-DarkNet53, the average AP of YOLOv3-DarkNet53 with Diou-Loss increases about 2% in VOC dataset.\n- YOLO v3 enhanced model improves the precision to 43.6 involved with deformable conv, dropblock, IoU loss and IoU aware. See more details in [YOLOv3_ENHANCEMENT](./featured_model/YOLOv3_ENHANCEMENT.md)\n### RetinaNet\n@@ -212,7 +214,7 @@ results of image size 608/416/320 above. Deformable conv is added on stage 5 of\n### SSD on Pascal VOC\n-| Backbone | Size | Image/gpu | Lr schd | Inf time (fps) | Box AP | Download | Configs |\n+| Backbone | Size | Image/gpu | Lr schd | Inf time (fps) | Box AP(0.5) | Download | Configs |\n| :----------- | :--: | :-------: | :-----: | :------------: | :----: | :----------------------------------------------------------: | :----: |\n| MobileNet v1 | 300 | 32 | 120e | 159.543 | 73.2 | [model](https://paddlemodels.bj.bcebos.com/object_detection/ssd_mobilenet_v1_voc.tar) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/ssd/ssd_mobilenet_v1_voc.yml) |\n| VGG16 | 300 | 8 | 240e | 117.279 | 77.5 | [model](https://paddlemodels.bj.bcebos.com/object_detection/ssd_vgg16_300_voc.tar) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/ssd/ssd_vgg16_300_voc.yml) |\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | add yolov3_darknet diou_loss model (#1041) |
499,333 | 10.07.2020 15:43:47 | -28,800 | d30bb02e8763fd9316007fa7f3ac6c76129dfba1 | fix cascade_rcnn_cls_aware_r101_vd_fpn_ms_test | [
{
"change_type": "MODIFY",
"old_path": "configs/cascade_rcnn_cls_aware_r101_vd_fpn_ms_test.yml",
"new_path": "configs/cascade_rcnn_cls_aware_r101_vd_fpn_ms_test.yml",
"diff": "@@ -109,6 +109,11 @@ OptimizerBuilder:\nfactor: 0.0001\ntype: L2\n+\n+_READER_: 'faster_fpn_reader.yml'\n+TrainReader:\n+ batch_size: 2\n+\nEvalReader:\nbatch_size: 1\ninputs_def:\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix cascade_rcnn_cls_aware_r101_vd_fpn_ms_test (#1050) |
499,304 | 10.07.2020 20:37:14 | -28,800 | 315fd738295d5c6c845320ff6e47b7111b44df66 | add blazeface keypoint model and modify some comment | [
{
"change_type": "MODIFY",
"old_path": "docs/featured_model/FACE_DETECTION_en.md",
"new_path": "docs/featured_model/FACE_DETECTION_en.md",
"diff": "@@ -270,6 +270,12 @@ wget https://dataset.bj.bcebos.com/wider_face/wider_face_train_bbx_lmk_gt.txt\n(2)Use `configs/face_detection/blazeface_keypoint.yml` configuration file for training and evaluation, the method of use is the same as the previous section.\n+### Evaluation\n+\n+| Architecture | Size | Img/gpu | Lr schd | Easy Set | Medium Set | Hard Set | Download | Configs |\n+|:------------:|:----:|:-------:|:-------:|:---------:|:----------:|:---------:|:--------:|:--------:|\n+| BlazeFace Keypoint | 640 | 16 | 16w | 0.852 | 0.816 | 0.662 | [download](https://paddlemodels.bj.bcebos.com/object_detection/blazeface_keypoint.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/configs/face_detection/blazeface_keypoint.yml) |\n+\n\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/architectures/blazeface.py",
"new_path": "ppdet/modeling/architectures/blazeface.py",
"diff": "@@ -41,6 +41,7 @@ class BlazeFace(object):\noutput_decoder (object): `SSDOutputDecoder` instance\nmin_sizes (list|None): min sizes of generated prior boxes.\nmax_sizes (list|None): max sizes of generated prior boxes. Default: None.\n+ steps (list|None): step size of adjacent prior boxes on each feature map.\nnum_classes (int): number of output classes\nuse_density_prior_box (bool): whether or not use density_prior_box\ninstead of prior_box\n"
},
{
"change_type": "MODIFY",
"old_path": "ppdet/modeling/architectures/faceboxes.py",
"new_path": "ppdet/modeling/architectures/faceboxes.py",
"diff": "@@ -32,8 +32,8 @@ __all__ = ['FaceBoxes']\n@register\nclass FaceBoxes(object):\n\"\"\"\n- FaceBoxes: Sub-millisecond Neural Face Detection on Mobile GPUs,\n- see https://https://arxiv.org/abs/1708.05234\n+ FaceBoxes: A CPU Real-time Face Detector with High Accuracy.\n+ see https://arxiv.org/abs/1708.05234\nArgs:\nbackbone (object): backbone instance\n@@ -42,7 +42,8 @@ class FaceBoxes(object):\nthis attribute should be a list or tuple of integers.\nfixed_sizes (list|None): the fixed sizes of generated density prior boxes,\nthis attribute should a list or tuple of same length with `densities`.\n- num_classes (int): number of output classes\n+ num_classes (int): number of output classes.\n+ steps (list|None): step size of adjacent prior boxes on each feature map.\n\"\"\"\n__category__ = 'architecture'\n@@ -55,7 +56,7 @@ class FaceBoxes(object):\ndensities=[[4, 2, 1], [1], [1]],\nfixed_sizes=[[32., 64., 128.], [256.], [512.]],\nnum_classes=2,\n- steps=[8., 16., 32.]):\n+ steps=[16., 32., 64.]):\nsuper(FaceBoxes, self).__init__()\nself.backbone = backbone\nself.num_classes = num_classes\n@@ -116,7 +117,7 @@ class FaceBoxes(object):\nfixed_ratios=[1.],\nclip=False,\noffset=0.5,\n- steps=[self.steps[i]] * 2)\n+ steps=[self.steps[i]])\nnum_boxes = box.shape[2]\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | add blazeface keypoint model and modify some comment (#1048) |
499,333 | 16.07.2020 12:53:56 | -28,800 | 07baa6d3cb6503e0caa6d9585ea4e668f16d2f52 | fix python inference without resize | [
{
"change_type": "MODIFY",
"old_path": "deploy/python/infer.py",
"new_path": "deploy/python/infer.py",
"diff": "@@ -433,7 +433,7 @@ class Detector():\ndef preprocess(self, im):\n# process image by preprocess_ops\nim_info = {\n- 'scale': 1.,\n+ 'scale': [1., 1.],\n'origin_shape': None,\n'resize_shape': None,\n}\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix python inference without resize (#1070) |
499,311 | 16.07.2020 14:00:28 | -28,800 | c4219c2715ce41482401f8b519f6b4232a8bfaf3 | fix bug of image_shape of Resize is not define in yml | [
{
"change_type": "MODIFY",
"old_path": "deploy/cpp/include/preprocess_op.h",
"new_path": "deploy/cpp/include/preprocess_op.h",
"diff": "@@ -91,8 +91,10 @@ class Resize : public PreprocessOp {\narch_ = arch;\ninterp_ = item[\"interp\"].as<int>();\nmax_size_ = item[\"max_size\"].as<int>();\n- target_size_ = item[\"target_size\"].as<int>();\n+ if (item[\"image_shape\"].IsDefined()) {\nimage_shape_ = item[\"image_shape\"].as<std::vector<int>>();\n+ }\n+ target_size_ = item[\"target_size\"].as<int>();\n}\n// Compute best resize scale for x-dimension, y-dimension\n@@ -156,3 +158,4 @@ class Preprocessor {\n};\n} // namespace PaddleDetection\n+\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix bug of image_shape of Resize is not define in yml (#1064) |
499,333 | 16.07.2020 17:52:13 | -28,800 | 64a2a78ed2fc12ad3d929509d2ae6e81c6d881a3 | fix cpp inference without resize | [
{
"change_type": "MODIFY",
"old_path": "configs/face_detection/blazeface.yml",
"new_path": "configs/face_detection/blazeface.yml",
"diff": "@@ -96,11 +96,12 @@ EvalReader:\n- !DecodeImage\nto_rgb: true\n- !NormalizeBox {}\n- - !Permute {}\n- !NormalizeImage\n+ is_channel_first: false\nis_scale: false\n- mean: [104, 117, 123]\n+ mean: [123, 117, 104]\nstd: [127.502231, 127.502231, 127.502231]\n+ - !Permute {}\nbatch_size: 1\nTestReader:\n@@ -112,9 +113,10 @@ TestReader:\nsample_transforms:\n- !DecodeImage\nto_rgb: true\n- - !Permute {}\n- !NormalizeImage\n+ is_channel_first: false\nis_scale: false\n- mean: [104, 117, 123]\n+ mean: [123, 117, 104]\nstd: [127.502231, 127.502231, 127.502231]\n+ - !Permute {}\nbatch_size: 1\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/face_detection/blazeface_keypoint.yml",
"new_path": "configs/face_detection/blazeface_keypoint.yml",
"diff": "@@ -104,11 +104,12 @@ EvalReader:\n- !DecodeImage\nto_rgb: true\n- !NormalizeBox {}\n- - !Permute {}\n- !NormalizeImage\n+ is_channel_first: false\nis_scale: false\n- mean: [104, 117, 123]\n+ mean: [123, 117, 104]\nstd: [127.502231, 127.502231, 127.502231]\n+ - !Permute {}\nbatch_size: 1\nTestReader:\n@@ -120,9 +121,10 @@ TestReader:\nsample_transforms:\n- !DecodeImage\nto_rgb: true\n- - !Permute {}\n- !NormalizeImage\n+ is_channel_first: false\nis_scale: false\n- mean: [104, 117, 123]\n+ mean: [123, 117, 104]\nstd: [127.502231, 127.502231, 127.502231]\n+ - !Permute {}\nbatch_size: 1\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/face_detection/blazeface_nas.yml",
"new_path": "configs/face_detection/blazeface_nas.yml",
"diff": "@@ -98,11 +98,12 @@ EvalReader:\n- !DecodeImage\nto_rgb: true\n- !NormalizeBox {}\n- - !Permute {}\n- !NormalizeImage\n+ is_channel_first: false\nis_scale: false\n- mean: [104, 117, 123]\n+ mean: [123, 117, 104]\nstd: [127.502231, 127.502231, 127.502231]\n+ - !Permute {}\nbatch_size: 1\nTestReader:\n@@ -114,9 +115,10 @@ TestReader:\nsample_transforms:\n- !DecodeImage\nto_rgb: true\n- - !Permute {}\n- !NormalizeImage\n+ is_channel_first: false\nis_scale: false\n- mean: [104, 117, 123]\n+ mean: [123, 117, 104]\nstd: [127.502231, 127.502231, 127.502231]\n+ - !Permute {}\nbatch_size: 1\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/face_detection/blazeface_nas_v2.yml",
"new_path": "configs/face_detection/blazeface_nas_v2.yml",
"diff": "@@ -98,11 +98,12 @@ EvalReader:\n- !DecodeImage\nto_rgb: true\n- !NormalizeBox {}\n- - !Permute {}\n- !NormalizeImage\n+ is_channel_first: false\nis_scale: false\n- mean: [104, 117, 123]\n+ mean: [123, 117, 104]\nstd: [127.502231, 127.502231, 127.502231]\n+ - !Permute {}\nbatch_size: 1\nTestReader:\n@@ -114,9 +115,10 @@ TestReader:\nsample_transforms:\n- !DecodeImage\nto_rgb: true\n- - !Permute {}\n- !NormalizeImage\n+ is_channel_first: false\nis_scale: false\n- mean: [104, 117, 123]\n+ mean: [123, 117, 104]\nstd: [127.502231, 127.502231, 127.502231]\n+ - !Permute {}\nbatch_size: 1\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/face_detection/faceboxes.yml",
"new_path": "configs/face_detection/faceboxes.yml",
"diff": "@@ -97,11 +97,13 @@ EvalReader:\nsample_transforms:\n- !DecodeImage\nto_rgb: true\n- - !Permute {}\n+ - !NormalizeBox {}\n- !NormalizeImage\n+ is_channel_first: false\nis_scale: false\n- mean: [104, 117, 123]\n+ mean: [123, 117, 104]\nstd: [127.502231, 127.502231, 127.502231]\n+ - !Permute {}\nTestReader:\ninputs_def:\n@@ -112,9 +114,10 @@ TestReader:\nsample_transforms:\n- !DecodeImage\nto_rgb: true\n- - !Permute {}\n- !NormalizeImage\n+ is_channel_first: false\nis_scale: false\n- mean: [104, 117, 123]\n+ mean: [123, 117, 104]\nstd: [127.502231, 127.502231, 127.502231]\n+ - !Permute {}\nbatch_size: 1\n"
},
{
"change_type": "MODIFY",
"old_path": "configs/face_detection/faceboxes_lite.yml",
"new_path": "configs/face_detection/faceboxes_lite.yml",
"diff": "@@ -98,11 +98,13 @@ EvalReader:\n- !DecodeImage\nto_rgb: true\n- !NormalizeBox {}\n- - !Permute {}\n- !NormalizeImage\n+ is_channel_first: false\nis_scale: false\n- mean: [104, 117, 123]\n+ mean: [123, 117, 104]\nstd: [127.502231, 127.502231, 127.502231]\n+ - !Permute {}\n+\nTestReader:\ninputs_def:\n@@ -113,9 +115,10 @@ TestReader:\nsample_transforms:\n- !DecodeImage\nto_rgb: true\n- - !Permute {}\n- !NormalizeImage\n+ is_channel_first: false\nis_scale: false\n- mean: [104, 117, 123]\n+ mean: [123, 117, 104]\nstd: [127.502231, 127.502231, 127.502231]\n+ - !Permute {}\nbatch_size: 1\n"
},
{
"change_type": "MODIFY",
"old_path": "deploy/cpp/include/preprocess_op.h",
"new_path": "deploy/cpp/include/preprocess_op.h",
"diff": "@@ -50,6 +50,12 @@ class PreprocessOp {\nvirtual void Run(cv::Mat* im, ImageBlob* data) = 0;\n};\n+class InitInfo : public PreprocessOp{\n+ public:\n+ virtual void Init(const YAML::Node& item, const std::string& arch) {}\n+ virtual void Run(cv::Mat* im, ImageBlob* data);\n+};\n+\nclass Normalize : public PreprocessOp {\npublic:\nvirtual void Init(const YAML::Node& item, const std::string& arch) {\n@@ -127,6 +133,8 @@ class Preprocessor {\npublic:\nvoid Init(const YAML::Node& config_node, const std::string& arch) {\narch_ = arch;\n+ // initialize image info at first\n+ ops_[\"InitInfo\"] = std::make_shared<InitInfo>();\nfor (const auto& item : config_node) {\nauto op_name = item[\"type\"].as<std::string>();\nops_[op_name] = CreateOp(op_name);\n"
},
{
"change_type": "MODIFY",
"old_path": "deploy/cpp/src/preprocess_op.cc",
"new_path": "deploy/cpp/src/preprocess_op.cc",
"diff": "namespace PaddleDetection {\n+void InitInfo::Run(cv::Mat* im, ImageBlob* data) {\n+ data->ori_im_size_ = {\n+ static_cast<int>(im->rows),\n+ static_cast<int>(im->cols)\n+ };\n+ data->ori_im_size_f_ = {\n+ static_cast<float>(im->rows),\n+ static_cast<float>(im->cols),\n+ 1.0\n+ };\n+ data->eval_im_size_f_ = {\n+ static_cast<float>(im->rows),\n+ static_cast<float>(im->cols),\n+ 1.0\n+ };\n+ data->scale_factor_f_ = {1., 1., 1., 1.};\n+}\n+\nvoid Normalize::Run(cv::Mat* im, ImageBlob* data) {\ndouble e = 1.0;\nif (is_scale_) {\n@@ -44,20 +62,12 @@ void Permute::Run(cv::Mat* im, ImageBlob* data) {\n(data->im_data_).resize(rc * rh * rw);\nfloat* base = (data->im_data_).data();\nfor (int i = 0; i < rc; ++i) {\n- cv::extractChannel(*im, cv::Mat(rh, rw, CV_32FC1, base + i * rh * rw), i);\n+ int cur_c = to_bgr_ ? rc - i - 1 : i;\n+ cv::extractChannel(*im, cv::Mat(rh, rw, CV_32FC1, base + cur_c * rh * rw), i);\n}\n}\nvoid Resize::Run(cv::Mat* im, ImageBlob* data) {\n- data->ori_im_size_ = {\n- static_cast<int>(im->rows),\n- static_cast<int>(im->cols)\n- };\n- data->ori_im_size_f_ = {\n- static_cast<float>(im->rows),\n- static_cast<float>(im->cols),\n- 1.0\n- };\nauto resize_scale = GenerateScale(*im);\ncv::resize(\n*im, *im, cv::Size(), resize_scale.first, resize_scale.second, interp_);\n@@ -137,7 +147,7 @@ void PadStride::Run(cv::Mat* im, ImageBlob* data) {\n// Preprocessor op running order\nconst std::vector<std::string> Preprocessor::RUN_ORDER = {\n- \"Resize\", \"Normalize\", \"PadStride\", \"Permute\"\n+ \"InitInfo\", \"Resize\", \"Normalize\", \"PadStride\", \"Permute\"\n};\nvoid Preprocessor::Run(cv::Mat* im, ImageBlob* data) {\n"
}
] | Python | Apache License 2.0 | paddlepaddle/paddledetection | fix cpp inference without resize (#1073) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.