From 84c8958daef9043da0d32d1d0e221a329e39f9a1 Mon Sep 17 00:00:00 2001 From: Manuel Garcia <31109774+Mandroide@users.noreply.github.com> Date: Wed, 7 Jul 2021 22:05:18 -0400 Subject: [PATCH] Optimize imports (#3601) Besides removing unnecessary imports, this also fixes the missing logger module in test_architectures.py within the static directory. --- .../dota_coco/dota_generate_test_result.py | 31 ++++++++++--------- dataset/dota_coco/dota_to_coco.py | 3 -- deploy/benchmark/log_parser_excel.py | 1 - deploy/python/benchmark_utils.py | 2 -- deploy/python/det_keypoint_unite_infer.py | 2 +- deploy/python/infer.py | 2 -- deploy/python/preprocess.py | 1 - deploy/python/visualize.py | 1 - docs/tutorials/FAQ.md | 6 ++-- ppdet/core/workspace.py | 1 - ppdet/data/reader.py | 8 ++--- ppdet/data/source/dataset.py | 2 +- ppdet/data/transform/autoaugment_utils.py | 2 -- ppdet/data/transform/keypoint_operators.py | 1 - ppdet/data/transform/mot_operators.py | 1 - ppdet/data/transform/operators.py | 5 ++- ppdet/engine/callbacks.py | 5 ++- ppdet/engine/trainer.py | 4 +-- ppdet/ext_op/setup.py | 2 +- ppdet/ext_op/test.py | 3 -- ppdet/metrics/coco_utils.py | 2 +- ppdet/metrics/json_results.py | 2 -- ppdet/metrics/keypoint_metrics.py | 2 -- ppdet/model_zoo/model_zoo.py | 2 -- ppdet/model_zoo/tests/test_get_model.py | 1 - ppdet/modeling/architectures/centernet.py | 1 - ppdet/modeling/architectures/meta_arch.py | 1 - ppdet/modeling/architectures/s2anet.py | 1 - ppdet/modeling/backbones/blazenet.py | 2 -- ppdet/modeling/backbones/darknet.py | 3 +- ppdet/modeling/backbones/ghostnet.py | 6 ++-- ppdet/modeling/backbones/hrnet.py | 2 +- ppdet/modeling/backbones/mobilenet_v1.py | 1 - ppdet/modeling/backbones/senet.py | 3 +- ppdet/modeling/backbones/vgg.py | 1 - ppdet/modeling/bbox_utils.py | 2 -- ppdet/modeling/heads/bbox_head.py | 2 -- ppdet/modeling/heads/cascade_head.py | 9 ++---- ppdet/modeling/heads/centernet_head.py | 2 -- ppdet/modeling/heads/face_head.py | 5 +-- ppdet/modeling/heads/keypoint_hrhrnet_head.py | 2 +- ppdet/modeling/heads/mask_head.py | 3 -- ppdet/modeling/heads/ttf_head.py | 2 +- ppdet/modeling/layers.py | 1 - ppdet/modeling/losses/ctfocal_loss.py | 2 +- ppdet/modeling/losses/fcos_loss.py | 2 +- ppdet/modeling/losses/iou_aware_loss.py | 3 +- ppdet/modeling/losses/iou_loss.py | 4 +-- ppdet/modeling/losses/keypoint_loss.py | 2 +- .../modeling/mot/tracker/base_sde_tracker.py | 1 - ppdet/modeling/necks/blazeface_fpn.py | 3 -- ppdet/modeling/necks/centernet_fpn.py | 2 -- ppdet/modeling/necks/fpn.py | 4 +-- ppdet/modeling/necks/hrfpn.py | 3 +- ppdet/modeling/necks/ttf_fpn.py | 1 - ppdet/modeling/necks/yolo_fpn.py | 1 - ppdet/modeling/ops.py | 7 +---- ppdet/modeling/post_process.py | 2 +- .../proposal_generator/anchor_generator.py | 3 -- .../proposal_generator/proposal_generator.py | 4 --- ppdet/modeling/proposal_generator/rpn_head.py | 3 -- ppdet/modeling/proposal_generator/target.py | 3 -- ppdet/modeling/reid/fairmot_embedding_head.py | 1 - ppdet/modeling/tests/test_base.py | 1 - ppdet/modeling/tests/test_ops.py | 1 - ppdet/modeling/tests/test_yolov3_loss.py | 5 --- ppdet/optimizer.py | 3 -- ppdet/slim/distill.py | 7 ++--- ppdet/slim/quant.py | 1 - ppdet/utils/checkpoint.py | 1 - ppdet/utils/download.py | 4 +-- ppdet/utils/logger.py | 1 - ppdet/utils/stats.py | 1 - ppdet/utils/visualizer.py | 1 - ppdet/utils/voc_utils.py | 1 - .../application/christmas/blazeface/module.py | 3 +- static/application/christmas/solov2/module.py | 4 +-- .../solov2_blazeface/face_makeup_main.py | 2 -- .../christmas/solov2_blazeface/module.py | 4 +-- .../christmas/solov2_blazeface/processor.py | 2 +- static/application/christmas/test_main.py | 4 --- static/deploy/python/infer.py | 7 +++-- static/deploy/python/visualize.py | 1 - static/docs/conf.py | 5 --- static/ppdet/data/parallel_map.py | 1 - static/ppdet/data/shared_queue/queue.py | 1 - .../ppdet/data/shared_queue/sharedmemory.py | 2 -- .../ppdet/data/transform/autoaugment_utils.py | 2 -- .../ppdet/modeling/anchor_heads/fcos_head.py | 4 +-- .../modeling/anchor_heads/solov2_head.py | 1 - .../ppdet/modeling/anchor_heads/ttf_head.py | 1 - .../ppdet/modeling/anchor_heads/yolo_head.py | 3 +- .../ppdet/modeling/architectures/blazeface.py | 1 - .../architectures/cascade_rcnn_cls_aware.py | 1 - .../architectures/cornernet_squeeze.py | 1 - .../ppdet/modeling/architectures/faceboxes.py | 1 - static/ppdet/modeling/architectures/htc.py | 6 +--- static/ppdet/modeling/backbones/bfp.py | 4 --- static/ppdet/modeling/backbones/gc_block.py | 1 - static/ppdet/modeling/backbones/hourglass.py | 3 -- static/ppdet/modeling/backbones/hrfpn.py | 2 -- static/ppdet/modeling/backbones/hrnet.py | 2 -- .../ppdet/modeling/backbones/mobilenet_v3.py | 3 -- static/ppdet/modeling/backbones/res2net.py | 11 +------ .../ppdet/modeling/losses/diou_loss_yolo.py | 3 -- static/ppdet/modeling/losses/fcos_loss.py | 1 - .../ppdet/modeling/losses/iou_aware_loss.py | 3 -- static/ppdet/modeling/losses/iou_loss.py | 3 -- .../modeling/losses/ssd_with_lmk_loss.py | 1 - .../ppdet/modeling/roi_heads/htc_bbox_head.py | 4 +-- .../modeling/roi_heads/htc_semantic_head.py | 4 --- .../modeling/tests/test_architectures.py | 4 +-- static/ppdet/utils/bbox_utils.py | 2 -- static/ppdet/utils/eval_utils.py | 2 +- static/ppdet/utils/export_utils.py | 1 - static/ppdet/utils/oid_eval.py | 4 --- static/ppdet/utils/post_process.py | 1 - static/ppdet/utils/voc_eval.py | 2 -- static/ppdet/utils/voc_utils.py | 1 - static/ppdet/utils/widerface_eval_utils.py | 1 - static/slim/distillation/distill.py | 6 ++-- .../distill_pruned_model.py | 7 ++--- .../nas/search_space/blazefacespace_nas.py | 2 -- static/slim/nas/train_nas.py | 6 ++-- static/slim/prune/eval.py | 4 +-- static/slim/prune/export_model.py | 5 +-- static/slim/prune/infer.py | 5 +-- static/slim/prune/prune.py | 4 +-- static/slim/quantization/eval.py | 4 +-- static/slim/quantization/export_model.py | 5 +-- static/slim/quantization/infer.py | 6 ++-- static/slim/quantization/pact.py | 2 -- static/slim/quantization/train.py | 7 +++-- static/slim/sensitive/sensitive.py | 15 +++------ static/tools/anchor_cluster.py | 1 - static/tools/configure.py | 7 +++-- static/tools/eval.py | 5 +-- static/tools/export_model.py | 1 - static/tools/export_serving_model.py | 6 ++-- static/tools/face_eval.py | 1 - static/tools/infer.py | 5 +-- static/tools/train.py | 5 +-- static/tools/train_multi_machine.py | 5 +-- static/tools/x2coco.py | 2 -- tools/anchor_cluster.py | 3 +- tools/eval.py | 4 ++- tools/eval_mot.py | 6 ++-- tools/export_model.py | 5 ++- tools/infer.py | 5 ++- tools/infer_mot.py | 6 ++-- tools/train.py | 9 +++--- tools/x2coco.py | 2 -- 152 files changed, 153 insertions(+), 342 deletions(-) diff --git a/dataset/dota_coco/dota_generate_test_result.py b/dataset/dota_coco/dota_generate_test_result.py index 00569970a..44c8f1804 100644 --- a/dataset/dota_coco/dota_generate_test_result.py +++ b/dataset/dota_coco/dota_generate_test_result.py @@ -12,13 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys import os -import os.path as osp import re -import json import glob -import cv2 + import numpy as np from multiprocessing import Pool from functools import partial @@ -80,10 +77,10 @@ def py_cpu_nms_poly_fast(dets, thresh): polys = [] for i in range(len(dets)): - tm_polygon = [dets[i][0], dets[i][1], - dets[i][2], dets[i][3], - dets[i][4], dets[i][5], - dets[i][6], dets[i][7]] + tm_polygon = [ + dets[i][0], dets[i][1], dets[i][2], dets[i][3], dets[i][4], + dets[i][5], dets[i][6], dets[i][7] + ] polys.append(tm_polygon) polys = np.array(polys) order = scores.argsort()[::-1] @@ -124,7 +121,7 @@ def py_cpu_nms_poly_fast(dets, thresh): def poly2origpoly(poly, x, y, rate): origpoly = [] - for i in range(int(len(poly)/2)): + for i in range(int(len(poly) / 2)): tmp_x = float(poly[i * 2] + x) / float(rate) tmp_y = float(poly[i * 2 + 1] + y) / float(rate) origpoly.append(tmp_x) @@ -196,11 +193,14 @@ def merge_single(output_dir, nms, pred_class_lst): for det in nameboxnmsdict[imgname]: confidence = det[-1] bbox = det[0:-1] - outline = imgname + ' ' + str(confidence) + ' ' + ' '.join(map(str, bbox)) + outline = imgname + ' ' + str(confidence) + ' ' + ' '.join( + map(str, bbox)) f_out.write(outline + '\n') -def dota_generate_test_result(pred_txt_dir, output_dir='output', dota_version='v1.0'): +def dota_generate_test_result(pred_txt_dir, + output_dir='output', + dota_version='v1.0'): """ pred_txt_dir: dir of pred txt output_dir: dir of output @@ -228,7 +228,8 @@ def dota_generate_test_result(pred_txt_dir, output_dir='output', dota_version='v pred_classes_lst = [] for class_name in pred_classes.keys(): - print('class_name: {}, count: {}'.format(class_name, len(pred_classes[class_name]))) + print('class_name: {}, count: {}'.format(class_name, + len(pred_classes[class_name]))) pred_classes_lst.append((class_name, pred_classes[class_name])) # step2: merge @@ -241,7 +242,8 @@ def dota_generate_test_result(pred_txt_dir, output_dir='output', dota_version='v if __name__ == '__main__': parser = argparse.ArgumentParser(description='dota anno to coco') parser.add_argument('--pred_txt_dir', help='path of pred txt dir') - parser.add_argument('--output_dir', help='path of output dir', default='output') + parser.add_argument( + '--output_dir', help='path of output dir', default='output') parser.add_argument( '--dota_version', help='dota_version, v1.0 or v1.5 or v2.0', @@ -251,5 +253,6 @@ if __name__ == '__main__': args = parser.parse_args() # process - dota_generate_test_result(args.pred_txt_dir, args.output_dir, args.dota_version) + dota_generate_test_result(args.pred_txt_dir, args.output_dir, + args.dota_version) print('done!') diff --git a/dataset/dota_coco/dota_to_coco.py b/dataset/dota_coco/dota_to_coco.py index 0905df4e0..3aa557b8b 100644 --- a/dataset/dota_coco/dota_to_coco.py +++ b/dataset/dota_coco/dota_to_coco.py @@ -17,9 +17,6 @@ import os.path as osp import json import glob import cv2 -import numpy as np -from PIL import Image -import logging import argparse # add python path of PadleDetection to sys.path diff --git a/deploy/benchmark/log_parser_excel.py b/deploy/benchmark/log_parser_excel.py index b4d841d9d..2375e9634 100644 --- a/deploy/benchmark/log_parser_excel.py +++ b/deploy/benchmark/log_parser_excel.py @@ -13,7 +13,6 @@ # limitations under the License. import os -import sys import re import argparse import pandas as pd diff --git a/deploy/python/benchmark_utils.py b/deploy/python/benchmark_utils.py index 2bed99aa2..af7637288 100644 --- a/deploy/python/benchmark_utils.py +++ b/deploy/python/benchmark_utils.py @@ -12,9 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import argparse import os -import time import logging import paddle diff --git a/deploy/python/det_keypoint_unite_infer.py b/deploy/python/det_keypoint_unite_infer.py index 6470ecf08..c5d319d4a 100644 --- a/deploy/python/det_keypoint_unite_infer.py +++ b/deploy/python/det_keypoint_unite_infer.py @@ -13,7 +13,7 @@ # limitations under the License. import os -from PIL import Image + import cv2 import math import numpy as np diff --git a/deploy/python/infer.py b/deploy/python/infer.py index 6d56ee585..ba8706f21 100644 --- a/deploy/python/infer.py +++ b/deploy/python/infer.py @@ -13,12 +13,10 @@ # limitations under the License. import os -import time import yaml import glob from functools import reduce -from PIL import Image import cv2 import numpy as np import math diff --git a/deploy/python/preprocess.py b/deploy/python/preprocess.py index e6c0b8c1f..0e4052d9c 100644 --- a/deploy/python/preprocess.py +++ b/deploy/python/preprocess.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from PIL import Image import cv2 import numpy as np diff --git a/deploy/python/visualize.py b/deploy/python/visualize.py index ca9a12d9e..f15d1b7a6 100644 --- a/deploy/python/visualize.py +++ b/deploy/python/visualize.py @@ -19,7 +19,6 @@ import os import cv2 import numpy as np from PIL import Image, ImageDraw -from scipy import ndimage import math diff --git a/docs/tutorials/FAQ.md b/docs/tutorials/FAQ.md index 249621650..a9b289343 100644 --- a/docs/tutorials/FAQ.md +++ b/docs/tutorials/FAQ.md @@ -25,9 +25,9 @@ * PaddleDetection中提供的默认配置一般是采用8卡训练的配置,配置文件中的`batch_size`数为每卡的batch size,若训练的时候不是使用8卡或者对`batch_size`有修改,需要等比例的调小初始`learning_rate`来获得较好的收敛效果 -* 如果使用自定义数据集并且样本数比较少,建议增大`snapshot_epoch`数来增加第一次进行eval的时候的训练轮数来保证模型已经较好收敛 +* 如果使用自定义数据集并且样本数比较少,建议增大`snapshot_epoch`数来增加第一次进行eval的时候的训练轮数来保证模型已经较好收敛 -* 若使用自定义数据集训练,可以加载我们发布的COCO或VOC数据集上训练好的权重进行finetune训练来加快收敛速度,可以使用`-o pretrain_weights=xxx`的方式指定预训练权重,xxx可以是Model Zoo里发布的模型权重链接 +* 若使用自定义数据集训练,可以加载我们发布的COCO或VOC数据集上训练好的权重进行finetune训练来加快收敛速度,可以使用`-o pretrain_weights=xxx`的方式指定预训练权重,xxx可以是Model Zoo里发布的模型权重链接 @@ -93,4 +93,4 @@ https://github.com/PaddlePaddle/PaddleDetection/blob/b87a1ea86fa18ce69e44a17ad1b TestDataset: !ImageFolder anno_path: annotations/instances_val2017.json -``` \ No newline at end of file +``` diff --git a/ppdet/core/workspace.py b/ppdet/core/workspace.py index 5d6a5d9f7..e633746ed 100644 --- a/ppdet/core/workspace.py +++ b/ppdet/core/workspace.py @@ -21,7 +21,6 @@ import os import sys import yaml -import copy import collections try: diff --git a/ppdet/data/reader.py b/ppdet/data/reader.py index 253b9047c..c9ea09af2 100644 --- a/ppdet/data/reader.py +++ b/ppdet/data/reader.py @@ -13,21 +13,19 @@ # limitations under the License. import os -import copy import traceback import six import sys -import multiprocessing as mp if sys.version_info >= (3, 0): - import queue as Queue + pass else: - import Queue + pass import numpy as np from paddle.io import DataLoader, DistributedBatchSampler from paddle.fluid.dataloader.collate import default_collate_fn -from ppdet.core.workspace import register, serializable, create +from ppdet.core.workspace import register from . import transform from .shm_utils import _get_shared_memory_size_in_M diff --git a/ppdet/data/source/dataset.py b/ppdet/data/source/dataset.py index 96b81326a..b0d8726ed 100644 --- a/ppdet/data/source/dataset.py +++ b/ppdet/data/source/dataset.py @@ -14,7 +14,7 @@ import os import numpy as np -from collections import OrderedDict + try: from collections.abc import Sequence except Exception: diff --git a/ppdet/data/transform/autoaugment_utils.py b/ppdet/data/transform/autoaugment_utils.py index 78e3bb36b..cfa89d374 100644 --- a/ppdet/data/transform/autoaugment_utils.py +++ b/ppdet/data/transform/autoaugment_utils.py @@ -23,8 +23,6 @@ import inspect import math from PIL import Image, ImageEnhance import numpy as np -import os -import sys import cv2 from copy import deepcopy diff --git a/ppdet/data/transform/keypoint_operators.py b/ppdet/data/transform/keypoint_operators.py index f122e118f..a578f0854 100644 --- a/ppdet/data/transform/keypoint_operators.py +++ b/ppdet/data/transform/keypoint_operators.py @@ -27,7 +27,6 @@ import cv2 import numpy as np import math import copy -import os from ...modeling.keypoint_utils import get_affine_mat_kernel, warp_affine_joints, get_affine_transform, affine_transform from ppdet.core.workspace import serializable diff --git a/ppdet/data/transform/mot_operators.py b/ppdet/data/transform/mot_operators.py index e85805743..5af64bb44 100644 --- a/ppdet/data/transform/mot_operators.py +++ b/ppdet/data/transform/mot_operators.py @@ -31,7 +31,6 @@ import math from .operators import BaseOperator, register_op from .batch_operators import Gt2TTFTarget from ppdet.modeling.bbox_utils import bbox_iou_np_expand -from ppdet.core.workspace import serializable from ppdet.utils.logger import setup_logger logger = setup_logger(__name__) diff --git a/ppdet/data/transform/operators.py b/ppdet/data/transform/operators.py index 583761204..f59adbd1d 100644 --- a/ppdet/data/transform/operators.py +++ b/ppdet/data/transform/operators.py @@ -35,10 +35,9 @@ import os import copy import cv2 -from PIL import Image, ImageEnhance, ImageDraw +from PIL import Image, ImageDraw from ppdet.core.workspace import serializable -from ppdet.modeling.layers import AnchorGrid from ppdet.modeling import bbox_utils from ..reader import Compose @@ -46,7 +45,7 @@ from .op_helper import (satisfy_sample_constraint, filter_and_process, generate_sample_bbox, clip_bbox, data_anchor_sampling, satisfy_sample_constraint_coverage, crop_image_sampling, generate_sample_bbox_square, bbox_area_sampling, - is_poly, gaussian_radius, draw_gaussian, transform_bbox) + is_poly, transform_bbox) from ppdet.utils.logger import setup_logger logger = setup_logger(__name__) diff --git a/ppdet/engine/callbacks.py b/ppdet/engine/callbacks.py index b623e1988..70dbf3352 100644 --- a/ppdet/engine/callbacks.py +++ b/ppdet/engine/callbacks.py @@ -20,9 +20,7 @@ import os import sys import datetime import six -import numpy as np -import paddle import paddle.distributed as dist from ppdet.utils.checkpoint import save_model @@ -217,7 +215,8 @@ class VisualDLWriter(Callback): logger.error('visualdl not found, plaese install visualdl. ' 'for example: `pip install visualdl`.') raise e - self.vdl_writer = LogWriter(model.cfg.get('vdl_log_dir', 'vdl_log_dir/scalar')) + self.vdl_writer = LogWriter( + model.cfg.get('vdl_log_dir', 'vdl_log_dir/scalar')) self.vdl_loss_step = 0 self.vdl_mAP_step = 0 self.vdl_image_step = 0 diff --git a/ppdet/engine/trainer.py b/ppdet/engine/trainer.py index e1a9672f4..0cf2ae683 100644 --- a/ppdet/engine/trainer.py +++ b/ppdet/engine/trainer.py @@ -17,11 +17,9 @@ from __future__ import division from __future__ import print_function import os -import sys import copy import time -import random -import datetime + import numpy as np from PIL import Image diff --git a/ppdet/ext_op/setup.py b/ppdet/ext_op/setup.py index 6859f0cc2..c99f14fd0 100644 --- a/ppdet/ext_op/setup.py +++ b/ppdet/ext_op/setup.py @@ -1,4 +1,4 @@ -from paddle.utils.cpp_extension import CppExtension, CUDAExtension, setup +from paddle.utils.cpp_extension import CUDAExtension, setup if __name__ == "__main__": setup( diff --git a/ppdet/ext_op/test.py b/ppdet/ext_op/test.py index 83403edd3..bdd84e7e5 100644 --- a/ppdet/ext_op/test.py +++ b/ppdet/ext_op/test.py @@ -1,9 +1,6 @@ import numpy as np -import os import sys -import cv2 import time -import shapely from shapely.geometry import Polygon import paddle diff --git a/ppdet/metrics/coco_utils.py b/ppdet/metrics/coco_utils.py index 60f29155a..47b92bc62 100644 --- a/ppdet/metrics/coco_utils.py +++ b/ppdet/metrics/coco_utils.py @@ -150,7 +150,7 @@ def cocoapi_eval(jsonfile, results_flatten = list(itertools.chain(*results_per_category)) headers = ['category', 'AP'] * (num_columns // 2) results_2d = itertools.zip_longest( - * [results_flatten[i::num_columns] for i in range(num_columns)]) + *[results_flatten[i::num_columns] for i in range(num_columns)]) table_data = [headers] table_data += [result for result in results_2d] table = AsciiTable(table_data) diff --git a/ppdet/metrics/json_results.py b/ppdet/metrics/json_results.py index 94b3c827f..c703de63b 100755 --- a/ppdet/metrics/json_results.py +++ b/ppdet/metrics/json_results.py @@ -12,9 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. import six -import os import numpy as np -import cv2 def get_det_res(bboxes, bbox_nums, image_id, label_to_cat_id_map, bias=0): diff --git a/ppdet/metrics/keypoint_metrics.py b/ppdet/metrics/keypoint_metrics.py index a2bcccaf6..49f0c7a58 100644 --- a/ppdet/metrics/keypoint_metrics.py +++ b/ppdet/metrics/keypoint_metrics.py @@ -12,10 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import copy import os import json -from collections import OrderedDict from collections import defaultdict import numpy as np from pycocotools.coco import COCO diff --git a/ppdet/model_zoo/model_zoo.py b/ppdet/model_zoo/model_zoo.py index 17af46f79..27581ef79 100644 --- a/ppdet/model_zoo/model_zoo.py +++ b/ppdet/model_zoo/model_zoo.py @@ -12,9 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os import os.path as osp -import glob import pkg_resources try: diff --git a/ppdet/model_zoo/tests/test_get_model.py b/ppdet/model_zoo/tests/test_get_model.py index e07217fa0..8887185e0 100644 --- a/ppdet/model_zoo/tests/test_get_model.py +++ b/ppdet/model_zoo/tests/test_get_model.py @@ -21,7 +21,6 @@ import paddle import ppdet import unittest - # NOTE: weights downloading costs time, we choose # a small model for unittesting MODEL_NAME = 'ppyolo/ppyolo_tiny_650e_coco' diff --git a/ppdet/modeling/architectures/centernet.py b/ppdet/modeling/architectures/centernet.py index 719e4c20b..8fb90d030 100755 --- a/ppdet/modeling/architectures/centernet.py +++ b/ppdet/modeling/architectures/centernet.py @@ -16,7 +16,6 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import paddle from ppdet.core.workspace import register, create from .meta_arch import BaseArch diff --git a/ppdet/modeling/architectures/meta_arch.py b/ppdet/modeling/architectures/meta_arch.py index fb2f5bd1a..00085428d 100644 --- a/ppdet/modeling/architectures/meta_arch.py +++ b/ppdet/modeling/architectures/meta_arch.py @@ -2,7 +2,6 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import numpy as np import paddle import paddle.nn as nn from ppdet.core.workspace import register diff --git a/ppdet/modeling/architectures/s2anet.py b/ppdet/modeling/architectures/s2anet.py index 40b8c89ef..ecfc987f9 100644 --- a/ppdet/modeling/architectures/s2anet.py +++ b/ppdet/modeling/architectures/s2anet.py @@ -19,7 +19,6 @@ from __future__ import print_function import paddle from ppdet.core.workspace import register, create from .meta_arch import BaseArch -import numpy as np __all__ = ['S2ANet'] diff --git a/ppdet/modeling/backbones/blazenet.py b/ppdet/modeling/backbones/blazenet.py index d5f345e60..b8e040804 100644 --- a/ppdet/modeling/backbones/blazenet.py +++ b/ppdet/modeling/backbones/blazenet.py @@ -20,10 +20,8 @@ import paddle import paddle.nn as nn import paddle.nn.functional as F from paddle import ParamAttr -from paddle.regularizer import L2Decay from paddle.nn.initializer import KaimingNormal from ppdet.core.workspace import register, serializable -from numbers import Integral from ..shape_spec import ShapeSpec __all__ = ['BlazeNet'] diff --git a/ppdet/modeling/backbones/darknet.py b/ppdet/modeling/backbones/darknet.py index 9c78dbbb1..246529699 100755 --- a/ppdet/modeling/backbones/darknet.py +++ b/ppdet/modeling/backbones/darknet.py @@ -15,8 +15,7 @@ import paddle import paddle.nn as nn import paddle.nn.functional as F -from paddle import ParamAttr -from paddle.regularizer import L2Decay + from ppdet.core.workspace import register, serializable from ppdet.modeling.ops import batch_norm, mish from ..shape_spec import ShapeSpec diff --git a/ppdet/modeling/backbones/ghostnet.py b/ppdet/modeling/backbones/ghostnet.py index 16fb78c0e..91fa43d18 100644 --- a/ppdet/modeling/backbones/ghostnet.py +++ b/ppdet/modeling/backbones/ghostnet.py @@ -17,9 +17,9 @@ import paddle from paddle import ParamAttr import paddle.nn as nn import paddle.nn.functional as F -from paddle.nn import Conv2D, BatchNorm, AdaptiveAvgPool2D, Linear -from paddle.regularizer import L2Decay -from paddle.nn.initializer import Uniform, KaimingNormal +from paddle.nn import AdaptiveAvgPool2D, Linear +from paddle.nn.initializer import Uniform + from ppdet.core.workspace import register, serializable from numbers import Integral from ..shape_spec import ShapeSpec diff --git a/ppdet/modeling/backbones/hrnet.py b/ppdet/modeling/backbones/hrnet.py index 0955f8b22..b74002cec 100644 --- a/ppdet/modeling/backbones/hrnet.py +++ b/ppdet/modeling/backbones/hrnet.py @@ -21,7 +21,7 @@ from paddle.nn.initializer import Normal from numbers import Integral import math -from ppdet.core.workspace import register, serializable +from ppdet.core.workspace import register from ..shape_spec import ShapeSpec __all__ = ['HRNet'] diff --git a/ppdet/modeling/backbones/mobilenet_v1.py b/ppdet/modeling/backbones/mobilenet_v1.py index cecc6a5b5..8cf602832 100644 --- a/ppdet/modeling/backbones/mobilenet_v1.py +++ b/ppdet/modeling/backbones/mobilenet_v1.py @@ -16,7 +16,6 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import paddle import paddle.nn as nn import paddle.nn.functional as F from paddle import ParamAttr diff --git a/ppdet/modeling/backbones/senet.py b/ppdet/modeling/backbones/senet.py index a621c69b9..eb0bad33f 100644 --- a/ppdet/modeling/backbones/senet.py +++ b/ppdet/modeling/backbones/senet.py @@ -12,9 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import paddle import paddle.nn as nn -import paddle.nn.functional as F + from ppdet.core.workspace import register, serializable from .resnet import ResNet, Blocks, BasicBlock, BottleNeck diff --git a/ppdet/modeling/backbones/vgg.py b/ppdet/modeling/backbones/vgg.py index dd03872cb..9311efa23 100755 --- a/ppdet/modeling/backbones/vgg.py +++ b/ppdet/modeling/backbones/vgg.py @@ -4,7 +4,6 @@ import paddle import paddle.nn as nn import paddle.nn.functional as F from paddle import ParamAttr -from paddle.regularizer import L2Decay from paddle.nn import Conv2D, MaxPool2D from ppdet.core.workspace import register, serializable from ..shape_spec import ShapeSpec diff --git a/ppdet/modeling/bbox_utils.py b/ppdet/modeling/bbox_utils.py index fb5dda6ed..aa55538f3 100644 --- a/ppdet/modeling/bbox_utils.py +++ b/ppdet/modeling/bbox_utils.py @@ -14,8 +14,6 @@ import math import paddle -import paddle.nn.functional as F -import math import numpy as np diff --git a/ppdet/modeling/heads/bbox_head.py b/ppdet/modeling/heads/bbox_head.py index cd73dff5b..e4d7d6878 100644 --- a/ppdet/modeling/heads/bbox_head.py +++ b/ppdet/modeling/heads/bbox_head.py @@ -21,8 +21,6 @@ from paddle.nn.initializer import Normal, XavierUniform, KaimingNormal from paddle.regularizer import L2Decay from ppdet.core.workspace import register, create -from ppdet.modeling import ops - from .roi_extractor import RoIAlign from ..shape_spec import ShapeSpec from ..bbox_utils import bbox2delta diff --git a/ppdet/modeling/heads/cascade_head.py b/ppdet/modeling/heads/cascade_head.py index abd8305bf..935642bd6 100644 --- a/ppdet/modeling/heads/cascade_head.py +++ b/ppdet/modeling/heads/cascade_head.py @@ -15,16 +15,13 @@ import paddle import paddle.nn as nn import paddle.nn.functional as F -from paddle.nn.initializer import Normal, XavierUniform -from paddle.regularizer import L2Decay - -from ppdet.core.workspace import register, create -from ppdet.modeling import ops +from paddle.nn.initializer import Normal +from ppdet.core.workspace import register from .bbox_head import BBoxHead, TwoFCHead, XConvNormHead from .roi_extractor import RoIAlign from ..shape_spec import ShapeSpec -from ..bbox_utils import bbox2delta, delta2bbox, clip_bbox, nonempty_bbox +from ..bbox_utils import delta2bbox, clip_bbox, nonempty_bbox __all__ = ['CascadeTwoFCHead', 'CascadeXConvNormHead', 'CascadeHead'] diff --git a/ppdet/modeling/heads/centernet_head.py b/ppdet/modeling/heads/centernet_head.py index 00ac01ec2..aa3fbe2c3 100755 --- a/ppdet/modeling/heads/centernet_head.py +++ b/ppdet/modeling/heads/centernet_head.py @@ -12,12 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import numpy as np import math import paddle import paddle.nn as nn import paddle.nn.functional as F -from paddle import ParamAttr from paddle.nn.initializer import KaimingUniform from ppdet.core.workspace import register from ppdet.modeling.losses import CTFocalLoss diff --git a/ppdet/modeling/heads/face_head.py b/ppdet/modeling/heads/face_head.py index 83f34c26c..bb51f2eb9 100644 --- a/ppdet/modeling/heads/face_head.py +++ b/ppdet/modeling/heads/face_head.py @@ -14,11 +14,8 @@ import paddle import paddle.nn as nn -import paddle.nn.functional as F -from ppdet.core.workspace import register -from paddle.regularizer import L2Decay -from paddle import ParamAttr +from ppdet.core.workspace import register from ..layers import AnchorGeneratorSSD diff --git a/ppdet/modeling/heads/keypoint_hrhrnet_head.py b/ppdet/modeling/heads/keypoint_hrhrnet_head.py index 2cec010bb..869b1816e 100644 --- a/ppdet/modeling/heads/keypoint_hrhrnet_head.py +++ b/ppdet/modeling/heads/keypoint_hrhrnet_head.py @@ -14,7 +14,7 @@ import paddle import paddle.nn as nn -import paddle.nn.functional as F + from ppdet.core.workspace import register from .. import layers as L from ..backbones.hrnet import BasicBlock diff --git a/ppdet/modeling/heads/mask_head.py b/ppdet/modeling/heads/mask_head.py index 7d4e33e27..bfce2dc5b 100644 --- a/ppdet/modeling/heads/mask_head.py +++ b/ppdet/modeling/heads/mask_head.py @@ -16,12 +16,9 @@ import paddle import paddle.nn as nn import paddle.nn.functional as F from paddle.nn.initializer import KaimingNormal -from paddle.regularizer import L2Decay from ppdet.core.workspace import register, create -from ppdet.modeling import ops from ppdet.modeling.layers import ConvNormLayer - from .roi_extractor import RoIAlign diff --git a/ppdet/modeling/heads/ttf_head.py b/ppdet/modeling/heads/ttf_head.py index 4d1360b34..dfe97bdb7 100644 --- a/ppdet/modeling/heads/ttf_head.py +++ b/ppdet/modeling/heads/ttf_head.py @@ -16,7 +16,7 @@ import paddle import paddle.nn as nn import paddle.nn.functional as F from paddle import ParamAttr -from paddle.nn.initializer import Constant, Uniform, Normal +from paddle.nn.initializer import Constant, Normal from paddle.regularizer import L2Decay from ppdet.core.workspace import register from ppdet.modeling.layers import DeformableConvV2, LiteConv diff --git a/ppdet/modeling/layers.py b/ppdet/modeling/layers.py index 80501f075..fd3181265 100644 --- a/ppdet/modeling/layers.py +++ b/ppdet/modeling/layers.py @@ -21,7 +21,6 @@ import paddle import paddle.nn as nn from paddle import ParamAttr from paddle import to_tensor -from paddle.nn import Conv2D, BatchNorm2D, GroupNorm import paddle.nn.functional as F from paddle.nn.initializer import Normal, Constant, XavierUniform from paddle.regularizer import L2Decay diff --git a/ppdet/modeling/losses/ctfocal_loss.py b/ppdet/modeling/losses/ctfocal_loss.py index 9b51b51ee..6d5af94a2 100644 --- a/ppdet/modeling/losses/ctfocal_loss.py +++ b/ppdet/modeling/losses/ctfocal_loss.py @@ -17,7 +17,7 @@ from __future__ import division from __future__ import print_function import paddle -import paddle.nn.functional as F + from ppdet.core.workspace import register, serializable __all__ = ['CTFocalLoss'] diff --git a/ppdet/modeling/losses/fcos_loss.py b/ppdet/modeling/losses/fcos_loss.py index 8134548a1..c8d600573 100644 --- a/ppdet/modeling/losses/fcos_loss.py +++ b/ppdet/modeling/losses/fcos_loss.py @@ -15,7 +15,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import numpy as np + import paddle import paddle.nn as nn import paddle.nn.functional as F diff --git a/ppdet/modeling/losses/iou_aware_loss.py b/ppdet/modeling/losses/iou_aware_loss.py index 1e6aa8bf0..4a9e904dd 100644 --- a/ppdet/modeling/losses/iou_aware_loss.py +++ b/ppdet/modeling/losses/iou_aware_loss.py @@ -16,11 +16,10 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import paddle import paddle.nn.functional as F from ppdet.core.workspace import register, serializable from .iou_loss import IouLoss -from ..bbox_utils import xywh2xyxy, bbox_iou +from ..bbox_utils import bbox_iou @register diff --git a/ppdet/modeling/losses/iou_loss.py b/ppdet/modeling/losses/iou_loss.py index 297001cc5..9b8da6c05 100644 --- a/ppdet/modeling/losses/iou_loss.py +++ b/ppdet/modeling/losses/iou_loss.py @@ -19,9 +19,9 @@ from __future__ import print_function import numpy as np import paddle -import paddle.nn.functional as F + from ppdet.core.workspace import register, serializable -from ..bbox_utils import xywh2xyxy, bbox_iou +from ..bbox_utils import bbox_iou __all__ = ['IouLoss', 'GIoULoss', 'DIouLoss'] diff --git a/ppdet/modeling/losses/keypoint_loss.py b/ppdet/modeling/losses/keypoint_loss.py index d37ef5759..62b5a54a2 100644 --- a/ppdet/modeling/losses/keypoint_loss.py +++ b/ppdet/modeling/losses/keypoint_loss.py @@ -20,7 +20,7 @@ from itertools import cycle, islice from collections import abc import paddle import paddle.nn as nn -import paddle.nn.functional as F + from ppdet.core.workspace import register, serializable __all__ = ['HrHRNetLoss', 'KeyPointMSELoss'] diff --git a/ppdet/modeling/mot/tracker/base_sde_tracker.py b/ppdet/modeling/mot/tracker/base_sde_tracker.py index 294cf8be5..9c60ef5db 100644 --- a/ppdet/modeling/mot/tracker/base_sde_tracker.py +++ b/ppdet/modeling/mot/tracker/base_sde_tracker.py @@ -15,7 +15,6 @@ This code is borrow from https://github.com/nwojke/deep_sort/blob/master/deep_sort/track.py """ -import numpy as np from ppdet.core.workspace import register, serializable __all__ = ['TrackState', 'Track'] diff --git a/ppdet/modeling/necks/blazeface_fpn.py b/ppdet/modeling/necks/blazeface_fpn.py index f712372a1..c992e0408 100644 --- a/ppdet/modeling/necks/blazeface_fpn.py +++ b/ppdet/modeling/necks/blazeface_fpn.py @@ -12,15 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -import numpy as np -import math import paddle import paddle.nn.functional as F from paddle import ParamAttr import paddle.nn as nn from paddle.nn.initializer import KaimingNormal from ppdet.core.workspace import register, serializable -from ppdet.modeling.layers import ConvNormLayer from ..shape_spec import ShapeSpec __all__ = ['BlazeNeck'] diff --git a/ppdet/modeling/necks/centernet_fpn.py b/ppdet/modeling/necks/centernet_fpn.py index 0ecfbdd1d..089f1bbd6 100755 --- a/ppdet/modeling/necks/centernet_fpn.py +++ b/ppdet/modeling/necks/centernet_fpn.py @@ -15,8 +15,6 @@ import numpy as np import math import paddle -import paddle.nn.functional as F -from paddle import ParamAttr import paddle.nn as nn from paddle.nn.initializer import KaimingUniform from ppdet.core.workspace import register, serializable diff --git a/ppdet/modeling/necks/fpn.py b/ppdet/modeling/necks/fpn.py index 867b7dc45..0633fb5b2 100644 --- a/ppdet/modeling/necks/fpn.py +++ b/ppdet/modeling/necks/fpn.py @@ -12,13 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -import numpy as np -import paddle import paddle.nn as nn import paddle.nn.functional as F from paddle import ParamAttr from paddle.nn.initializer import XavierUniform -from paddle.regularizer import L2Decay + from ppdet.core.workspace import register, serializable from ppdet.modeling.layers import ConvNormLayer from ..shape_spec import ShapeSpec diff --git a/ppdet/modeling/necks/hrfpn.py b/ppdet/modeling/necks/hrfpn.py index 4b737c9fb..8df7cb1d6 100644 --- a/ppdet/modeling/necks/hrfpn.py +++ b/ppdet/modeling/necks/hrfpn.py @@ -16,8 +16,7 @@ import paddle import paddle.nn.functional as F from paddle import ParamAttr import paddle.nn as nn -from paddle.regularizer import L2Decay -from ppdet.core.workspace import register, serializable +from ppdet.core.workspace import register from ..shape_spec import ShapeSpec __all__ = ['HRFPN'] diff --git a/ppdet/modeling/necks/ttf_fpn.py b/ppdet/modeling/necks/ttf_fpn.py index 9c7f3924f..60cc69f80 100644 --- a/ppdet/modeling/necks/ttf_fpn.py +++ b/ppdet/modeling/necks/ttf_fpn.py @@ -17,7 +17,6 @@ import paddle.nn as nn import paddle.nn.functional as F from paddle import ParamAttr from paddle.nn.initializer import Constant, Uniform, Normal, XavierUniform -from paddle import ParamAttr from ppdet.core.workspace import register, serializable from paddle.regularizer import L2Decay from ppdet.modeling.layers import DeformableConvV2, ConvNormLayer, LiteConv diff --git a/ppdet/modeling/necks/yolo_fpn.py b/ppdet/modeling/necks/yolo_fpn.py index d3197f058..e8913131e 100644 --- a/ppdet/modeling/necks/yolo_fpn.py +++ b/ppdet/modeling/necks/yolo_fpn.py @@ -15,7 +15,6 @@ import paddle import paddle.nn as nn import paddle.nn.functional as F -from paddle import ParamAttr from ppdet.core.workspace import register, serializable from ppdet.modeling.layers import DropBlock from ..backbones.darknet import ConvBNLayer diff --git a/ppdet/modeling/ops.py b/ppdet/modeling/ops.py index 0b9cccf9b..6fa4d8ad3 100644 --- a/ppdet/modeling/ops.py +++ b/ppdet/modeling/ops.py @@ -21,12 +21,7 @@ from paddle.regularizer import L2Decay from paddle.fluid.framework import Variable, in_dygraph_mode from paddle.fluid import core from paddle.fluid.layer_helper import LayerHelper -from paddle.fluid.dygraph import layers -from paddle.fluid.data_feeder import check_variable_and_dtype, check_type, check_dtype, convert_dtype -import math -import six -import numpy as np -from functools import reduce +from paddle.fluid.data_feeder import check_variable_and_dtype, check_type, check_dtype __all__ = [ 'roi_pool', diff --git a/ppdet/modeling/post_process.py b/ppdet/modeling/post_process.py index 21a692298..698f95f03 100644 --- a/ppdet/modeling/post_process.py +++ b/ppdet/modeling/post_process.py @@ -17,7 +17,7 @@ import paddle import paddle.nn as nn import paddle.nn.functional as F from ppdet.core.workspace import register -from ppdet.modeling.bbox_utils import nonempty_bbox, rbox2poly, rbox2poly +from ppdet.modeling.bbox_utils import nonempty_bbox, rbox2poly from ppdet.modeling.layers import TTFBox from .transformers import bbox_cxcywh_to_xyxy try: diff --git a/ppdet/modeling/proposal_generator/anchor_generator.py b/ppdet/modeling/proposal_generator/anchor_generator.py index 8088ffa04..869367601 100644 --- a/ppdet/modeling/proposal_generator/anchor_generator.py +++ b/ppdet/modeling/proposal_generator/anchor_generator.py @@ -12,15 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -import numpy as np import math import paddle import paddle.nn as nn -import paddle.nn.functional as F from ppdet.core.workspace import register -from .. import ops @register diff --git a/ppdet/modeling/proposal_generator/proposal_generator.py b/ppdet/modeling/proposal_generator/proposal_generator.py index 12518e488..1fcb8b1e2 100644 --- a/ppdet/modeling/proposal_generator/proposal_generator.py +++ b/ppdet/modeling/proposal_generator/proposal_generator.py @@ -12,11 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import numpy as np - import paddle -import paddle.nn as nn -import paddle.nn.functional as F from ppdet.core.workspace import register, serializable from .. import ops diff --git a/ppdet/modeling/proposal_generator/rpn_head.py b/ppdet/modeling/proposal_generator/rpn_head.py index cf836bed4..1664d7839 100644 --- a/ppdet/modeling/proposal_generator/rpn_head.py +++ b/ppdet/modeling/proposal_generator/rpn_head.py @@ -16,11 +16,8 @@ import paddle import paddle.nn as nn import paddle.nn.functional as F from paddle.nn.initializer import Normal -from paddle.regularizer import L2Decay from ppdet.core.workspace import register -from ppdet.modeling import ops - from .anchor_generator import AnchorGenerator from .target_layer import RPNTargetAssign from .proposal_generator import ProposalGenerator diff --git a/ppdet/modeling/proposal_generator/target.py b/ppdet/modeling/proposal_generator/target.py index edd1386ea..c767408c6 100644 --- a/ppdet/modeling/proposal_generator/target.py +++ b/ppdet/modeling/proposal_generator/target.py @@ -12,12 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import six -import math import numpy as np import paddle from ..bbox_utils import bbox2delta, bbox_overlaps -import copy def rpn_anchor_target(anchors, diff --git a/ppdet/modeling/reid/fairmot_embedding_head.py b/ppdet/modeling/reid/fairmot_embedding_head.py index 19ca28080..72f8243ef 100755 --- a/ppdet/modeling/reid/fairmot_embedding_head.py +++ b/ppdet/modeling/reid/fairmot_embedding_head.py @@ -17,7 +17,6 @@ import math import paddle import paddle.nn as nn import paddle.nn.functional as F -from paddle import ParamAttr from paddle.nn.initializer import KaimingUniform, Uniform from ppdet.core.workspace import register from ppdet.modeling.heads.centernet_head import ConvLayer diff --git a/ppdet/modeling/tests/test_base.py b/ppdet/modeling/tests/test_base.py index cfd03fe0f..cbb9033b3 100644 --- a/ppdet/modeling/tests/test_base.py +++ b/ppdet/modeling/tests/test_base.py @@ -16,7 +16,6 @@ from __future__ import print_function import unittest import contextlib -import numpy as np import paddle import paddle.fluid as fluid diff --git a/ppdet/modeling/tests/test_ops.py b/ppdet/modeling/tests/test_ops.py index d951b90dd..d4b574748 100644 --- a/ppdet/modeling/tests/test_ops.py +++ b/ppdet/modeling/tests/test_ops.py @@ -24,7 +24,6 @@ import numpy as np import paddle import paddle.fluid as fluid -from paddle.fluid.framework import Program, program_guard from paddle.fluid.dygraph import base import ppdet.modeling.ops as ops diff --git a/ppdet/modeling/tests/test_yolov3_loss.py b/ppdet/modeling/tests/test_yolov3_loss.py index 8037da84d..cec8bc940 100644 --- a/ppdet/modeling/tests/test_yolov3_loss.py +++ b/ppdet/modeling/tests/test_yolov3_loss.py @@ -15,13 +15,9 @@ from __future__ import division import unittest -import numpy as np -from scipy.special import logit -from scipy.special import expit import paddle from paddle import fluid -from paddle.fluid import core # add python path of PadleDetection to sys.path import os import sys @@ -31,7 +27,6 @@ if parent_path not in sys.path: from ppdet.modeling.losses import YOLOv3Loss from ppdet.data.transform.op_helper import jaccard_overlap -import random import numpy as np diff --git a/ppdet/optimizer.py b/ppdet/optimizer.py index 034be2460..77eac91d3 100644 --- a/ppdet/optimizer.py +++ b/ppdet/optimizer.py @@ -17,14 +17,11 @@ from __future__ import division from __future__ import print_function import math -import copy import paddle import paddle.nn as nn import paddle.optimizer as optimizer -from paddle.optimizer.lr import CosineAnnealingDecay import paddle.regularizer as regularizer -from paddle import cos from ppdet.core.workspace import register, serializable diff --git a/ppdet/slim/distill.py b/ppdet/slim/distill.py index d5c9d7266..b808553dd 100644 --- a/ppdet/slim/distill.py +++ b/ppdet/slim/distill.py @@ -20,12 +20,11 @@ import paddle import paddle.nn as nn import paddle.nn.functional as F -from ppdet.core.workspace import register, serializable, load_config -from ppdet.core.workspace import create -from ppdet.utils.logger import setup_logger +from ppdet.core.workspace import register, create, load_config from ppdet.modeling import ops from ppdet.utils.checkpoint import load_pretrain_weight -from ppdet.modeling.losses import YOLOv3Loss +from ppdet.utils.logger import setup_logger + logger = setup_logger(__name__) diff --git a/ppdet/slim/quant.py b/ppdet/slim/quant.py index a1fe126ef..837055969 100644 --- a/ppdet/slim/quant.py +++ b/ppdet/slim/quant.py @@ -16,7 +16,6 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import paddle from paddle.utils import try_import from ppdet.core.workspace import register, serializable diff --git a/ppdet/utils/checkpoint.py b/ppdet/utils/checkpoint.py index 6a6f85677..329fa2194 100644 --- a/ppdet/utils/checkpoint.py +++ b/ppdet/utils/checkpoint.py @@ -20,7 +20,6 @@ from __future__ import unicode_literals import errno import os import time -import re import numpy as np import paddle import paddle.nn as nn diff --git a/ppdet/utils/download.py b/ppdet/utils/download.py index c4ecd079a..4e898b79d 100644 --- a/ppdet/utils/download.py +++ b/ppdet/utils/download.py @@ -29,10 +29,10 @@ import binascii import tarfile import zipfile -from .voc_utils import create_list from ppdet.core.workspace import BASE_KEY - from .logger import setup_logger +from .voc_utils import create_list + logger = setup_logger(__name__) __all__ = [ diff --git a/ppdet/utils/logger.py b/ppdet/utils/logger.py index 99b82f995..51e296205 100644 --- a/ppdet/utils/logger.py +++ b/ppdet/utils/logger.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import functools import logging import os import sys diff --git a/ppdet/utils/stats.py b/ppdet/utils/stats.py index 6e4d284b5..4cd36d91c 100644 --- a/ppdet/utils/stats.py +++ b/ppdet/utils/stats.py @@ -14,7 +14,6 @@ import collections import numpy as np -import datetime __all__ = ['SmoothedValue', 'TrainingStats'] diff --git a/ppdet/utils/visualizer.py b/ppdet/utils/visualizer.py index fc1c53164..505c416b0 100644 --- a/ppdet/utils/visualizer.py +++ b/ppdet/utils/visualizer.py @@ -20,7 +20,6 @@ from __future__ import unicode_literals import numpy as np from PIL import Image, ImageDraw import cv2 -import os import math from .colormap import colormap diff --git a/ppdet/utils/voc_utils.py b/ppdet/utils/voc_utils.py index 1a4f3268a..cd6d9f90e 100644 --- a/ppdet/utils/voc_utils.py +++ b/ppdet/utils/voc_utils.py @@ -20,7 +20,6 @@ import os import os.path as osp import re import random -import shutil __all__ = ['create_list'] diff --git a/static/application/christmas/blazeface/module.py b/static/application/christmas/blazeface/module.py index bb402a4aa..40656ff83 100644 --- a/static/application/christmas/blazeface/module.py +++ b/static/application/christmas/blazeface/module.py @@ -15,10 +15,9 @@ import os import time from functools import reduce -import base64 import cv2 import numpy as np -from paddlehub.module.module import moduleinfo, serving +from paddlehub.module.module import moduleinfo import blazeface.data_feed as D diff --git a/static/application/christmas/solov2/module.py b/static/application/christmas/solov2/module.py index 2ae8f33b1..333ec6384 100644 --- a/static/application/christmas/solov2/module.py +++ b/static/application/christmas/solov2/module.py @@ -15,11 +15,9 @@ import os import time from functools import reduce -import base64 import cv2 import numpy as np -from paddlehub.module.module import moduleinfo, serving - +from paddlehub.module.module import moduleinfo import solov2.processor as P import solov2.data_feed as D diff --git a/static/application/christmas/solov2_blazeface/face_makeup_main.py b/static/application/christmas/solov2_blazeface/face_makeup_main.py index 344f9b9e4..c86a17942 100644 --- a/static/application/christmas/solov2_blazeface/face_makeup_main.py +++ b/static/application/christmas/solov2_blazeface/face_makeup_main.py @@ -13,10 +13,8 @@ # limitations under the License. import os import cv2 -import json import math import numpy as np -import argparse HAT_SCALES = { '1.png': [3.0, 0.9, .0], diff --git a/static/application/christmas/solov2_blazeface/module.py b/static/application/christmas/solov2_blazeface/module.py index edf85ea23..1c63427e5 100644 --- a/static/application/christmas/solov2_blazeface/module.py +++ b/static/application/christmas/solov2_blazeface/module.py @@ -13,7 +13,6 @@ # limitations under the License. import os -import time import base64 import json @@ -21,8 +20,7 @@ import cv2 import numpy as np import paddle.nn as nn import paddlehub as hub -from paddlehub.module.module import moduleinfo, serving, Module - +from paddlehub.module.module import moduleinfo, serving import solov2_blazeface.processor as P diff --git a/static/application/christmas/solov2_blazeface/processor.py b/static/application/christmas/solov2_blazeface/processor.py index c8b357dba..702985db3 100644 --- a/static/application/christmas/solov2_blazeface/processor.py +++ b/static/application/christmas/solov2_blazeface/processor.py @@ -16,7 +16,7 @@ from __future__ import division import cv2 import numpy as np -from PIL import Image, ImageDraw +from PIL import Image import solov2_blazeface.face_makeup_main as face_makeup_main diff --git a/static/application/christmas/test_main.py b/static/application/christmas/test_main.py index 0b3516699..ed8f2c375 100644 --- a/static/application/christmas/test_main.py +++ b/static/application/christmas/test_main.py @@ -12,12 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import paddle import paddlehub as hub import cv2 -from PIL import Image -import numpy as np -import base64 img_file = 'demo_images/test.jpg' background = 'element_source/background/1.png' diff --git a/static/deploy/python/infer.py b/static/deploy/python/infer.py index 3f6e72a48..9b606aa44 100644 --- a/static/deploy/python/infer.py +++ b/static/deploy/python/infer.py @@ -16,7 +16,9 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) if parent_path not in sys.path: @@ -28,7 +30,6 @@ import yaml import ast from functools import reduce -from PIL import Image import cv2 import numpy as np import paddle @@ -508,7 +509,7 @@ def predict_video(detector, camera_id): fps = 30 width = int(capture.get(cv2.CAP_PROP_FRAME_WIDTH)) height = int(capture.get(cv2.CAP_PROP_FRAME_HEIGHT)) - fourcc = cv2.VideoWriter_fourcc(* 'mp4v') + fourcc = cv2.VideoWriter_fourcc(*'mp4v') if not os.path.exists(FLAGS.output_dir): os.makedirs(FLAGS.output_dir) out_path = os.path.join(FLAGS.output_dir, video_name) diff --git a/static/deploy/python/visualize.py b/static/deploy/python/visualize.py index 439bf686c..933356a4b 100644 --- a/static/deploy/python/visualize.py +++ b/static/deploy/python/visualize.py @@ -18,7 +18,6 @@ from __future__ import division import cv2 import numpy as np from PIL import Image, ImageDraw -from scipy import ndimage def visualize_box_mask(im, results, labels, mask_resolution=14, threshold=0.5): diff --git a/static/docs/conf.py b/static/docs/conf.py index 08e62a4cf..58c87db78 100644 --- a/static/docs/conf.py +++ b/static/docs/conf.py @@ -18,11 +18,6 @@ # import os import sys -# sys.path.insert(0, os.path.abspath('.')) - -import sphinx_rtd_theme -from recommonmark.parser import CommonMarkParser -from recommonmark.transform import AutoStructify sys.path.insert(0, os.path.abspath("..")) sys.path.insert(0, os.path.abspath("../../")) diff --git a/static/ppdet/data/parallel_map.py b/static/ppdet/data/parallel_map.py index 17ea51b43..fd64299b1 100644 --- a/static/ppdet/data/parallel_map.py +++ b/static/ppdet/data/parallel_map.py @@ -31,7 +31,6 @@ import uuid import logging import signal import threading -import traceback logger = logging.getLogger(__name__) diff --git a/static/ppdet/data/shared_queue/queue.py b/static/ppdet/data/shared_queue/queue.py index 52a40d741..3191d2c71 100644 --- a/static/ppdet/data/shared_queue/queue.py +++ b/static/ppdet/data/shared_queue/queue.py @@ -17,7 +17,6 @@ from __future__ import division from __future__ import print_function from __future__ import unicode_literals -import sys import six if six.PY3: import pickle diff --git a/static/ppdet/data/shared_queue/sharedmemory.py b/static/ppdet/data/shared_queue/sharedmemory.py index 1630c7b39..e92e84cb8 100644 --- a/static/ppdet/data/shared_queue/sharedmemory.py +++ b/static/ppdet/data/shared_queue/sharedmemory.py @@ -24,7 +24,6 @@ import os import time import math import struct -import sys import six if six.PY3: @@ -32,7 +31,6 @@ if six.PY3: else: import cPickle as pickle -import json import uuid import random import numpy as np diff --git a/static/ppdet/data/transform/autoaugment_utils.py b/static/ppdet/data/transform/autoaugment_utils.py index 78e3bb36b..cfa89d374 100644 --- a/static/ppdet/data/transform/autoaugment_utils.py +++ b/static/ppdet/data/transform/autoaugment_utils.py @@ -23,8 +23,6 @@ import inspect import math from PIL import Image, ImageEnhance import numpy as np -import os -import sys import cv2 from copy import deepcopy diff --git a/static/ppdet/modeling/anchor_heads/fcos_head.py b/static/ppdet/modeling/anchor_heads/fcos_head.py index a08e02976..43f8e42cf 100644 --- a/static/ppdet/modeling/anchor_heads/fcos_head.py +++ b/static/ppdet/modeling/anchor_heads/fcos_head.py @@ -20,8 +20,8 @@ import math import paddle.fluid as fluid from paddle.fluid.param_attr import ParamAttr -from paddle.fluid.initializer import Normal, Constant, NumpyArrayInitializer -from paddle.fluid.regularizer import L2Decay +from paddle.fluid.initializer import Normal, Constant + from ppdet.modeling.ops import ConvNorm, DeformConvNorm from ppdet.modeling.ops import MultiClassNMS diff --git a/static/ppdet/modeling/anchor_heads/solov2_head.py b/static/ppdet/modeling/anchor_heads/solov2_head.py index 590b428e8..990a18c9a 100644 --- a/static/ppdet/modeling/anchor_heads/solov2_head.py +++ b/static/ppdet/modeling/anchor_heads/solov2_head.py @@ -19,7 +19,6 @@ from __future__ import print_function import paddle from paddle import fluid from paddle.fluid.param_attr import ParamAttr -from paddle.fluid.regularizer import L2Decay from ppdet.modeling.ops import ConvNorm, DeformConvNorm, MaskMatrixNMS, DropBlock from ppdet.core.workspace import register diff --git a/static/ppdet/modeling/anchor_heads/ttf_head.py b/static/ppdet/modeling/anchor_heads/ttf_head.py index 54a474d9d..06e889204 100644 --- a/static/ppdet/modeling/anchor_heads/ttf_head.py +++ b/static/ppdet/modeling/anchor_heads/ttf_head.py @@ -25,7 +25,6 @@ from paddle.fluid.initializer import Normal, Constant, Uniform, Xavier from paddle.fluid.regularizer import L2Decay from ppdet.core.workspace import register from ppdet.modeling.ops import DeformConv, DropBlock, ConvNorm -from ppdet.modeling.losses import GiouLoss __all__ = ['TTFHead', 'TTFLiteHead'] diff --git a/static/ppdet/modeling/anchor_heads/yolo_head.py b/static/ppdet/modeling/anchor_heads/yolo_head.py index 49b211ff6..d11892c21 100644 --- a/static/ppdet/modeling/anchor_heads/yolo_head.py +++ b/static/ppdet/modeling/anchor_heads/yolo_head.py @@ -22,8 +22,7 @@ from paddle import fluid from paddle.fluid.param_attr import ParamAttr from paddle.fluid.regularizer import L2Decay -from ppdet.modeling.ops import MultiClassNMS, MultiClassSoftNMS, MatrixNMS -from ppdet.modeling.losses.yolo_loss import YOLOv3Loss +from ppdet.modeling.ops import MultiClassNMS, MultiClassSoftNMS from ppdet.core.workspace import register from ppdet.modeling.ops import DropBlock from .iou_aware import get_iou_aware_score diff --git a/static/ppdet/modeling/architectures/blazeface.py b/static/ppdet/modeling/architectures/blazeface.py index 7508a6b08..7db23732a 100644 --- a/static/ppdet/modeling/architectures/blazeface.py +++ b/static/ppdet/modeling/architectures/blazeface.py @@ -16,7 +16,6 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import numpy as np from collections import OrderedDict from paddle import fluid diff --git a/static/ppdet/modeling/architectures/cascade_rcnn_cls_aware.py b/static/ppdet/modeling/architectures/cascade_rcnn_cls_aware.py index 837d87e97..e863d627e 100644 --- a/static/ppdet/modeling/architectures/cascade_rcnn_cls_aware.py +++ b/static/ppdet/modeling/architectures/cascade_rcnn_cls_aware.py @@ -17,7 +17,6 @@ from __future__ import division from __future__ import print_function import numpy as np -import sys from collections import OrderedDict import copy diff --git a/static/ppdet/modeling/architectures/cornernet_squeeze.py b/static/ppdet/modeling/architectures/cornernet_squeeze.py index 61e17f0ce..0dde99a4b 100644 --- a/static/ppdet/modeling/architectures/cornernet_squeeze.py +++ b/static/ppdet/modeling/architectures/cornernet_squeeze.py @@ -21,7 +21,6 @@ from collections import OrderedDict from paddle import fluid from ppdet.core.workspace import register -import numpy as np from ppdet.utils.check import check_version __all__ = ['CornerNetSqueeze'] diff --git a/static/ppdet/modeling/architectures/faceboxes.py b/static/ppdet/modeling/architectures/faceboxes.py index 2d8abe6b9..f38c96f6c 100644 --- a/static/ppdet/modeling/architectures/faceboxes.py +++ b/static/ppdet/modeling/architectures/faceboxes.py @@ -16,7 +16,6 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import numpy as np from collections import OrderedDict from paddle import fluid diff --git a/static/ppdet/modeling/architectures/htc.py b/static/ppdet/modeling/architectures/htc.py index c20822f85..f4bdb5838 100644 --- a/static/ppdet/modeling/architectures/htc.py +++ b/static/ppdet/modeling/architectures/htc.py @@ -18,13 +18,9 @@ from __future__ import print_function from collections import OrderedDict import copy -import numpy as np import paddle.fluid as fluid -from paddle.fluid.param_attr import ParamAttr -from paddle.fluid.initializer import MSRA -from paddle.fluid.regularizer import L2Decay -from ppdet.experimental import mixed_precision_global_state + from ppdet.core.workspace import register from ppdet.utils.check import check_version diff --git a/static/ppdet/modeling/backbones/bfp.py b/static/ppdet/modeling/backbones/bfp.py index 6bafc68c9..6e6389ed8 100644 --- a/static/ppdet/modeling/backbones/bfp.py +++ b/static/ppdet/modeling/backbones/bfp.py @@ -16,14 +16,10 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import sys - from collections import OrderedDict from paddle import fluid from paddle.fluid.param_attr import ParamAttr -from paddle.fluid.initializer import Xavier -from paddle.fluid.regularizer import L2Decay from ppdet.core.workspace import register diff --git a/static/ppdet/modeling/backbones/gc_block.py b/static/ppdet/modeling/backbones/gc_block.py index fbd374223..06c122775 100755 --- a/static/ppdet/modeling/backbones/gc_block.py +++ b/static/ppdet/modeling/backbones/gc_block.py @@ -17,7 +17,6 @@ from __future__ import division from __future__ import print_function from __future__ import unicode_literals -import paddle import paddle.fluid as fluid from paddle.fluid import ParamAttr from paddle.fluid.initializer import ConstantInitializer diff --git a/static/ppdet/modeling/backbones/hourglass.py b/static/ppdet/modeling/backbones/hourglass.py index b38f79bb4..4dfd1c18f 100644 --- a/static/ppdet/modeling/backbones/hourglass.py +++ b/static/ppdet/modeling/backbones/hourglass.py @@ -20,10 +20,7 @@ from paddle import fluid from paddle.fluid.param_attr import ParamAttr from paddle.fluid.initializer import Uniform -import functools from ppdet.core.workspace import register -from .resnet import ResNet -import math __all__ = ['Hourglass'] diff --git a/static/ppdet/modeling/backbones/hrfpn.py b/static/ppdet/modeling/backbones/hrfpn.py index 174c6d10d..85fd403ba 100644 --- a/static/ppdet/modeling/backbones/hrfpn.py +++ b/static/ppdet/modeling/backbones/hrfpn.py @@ -20,8 +20,6 @@ from collections import OrderedDict from paddle import fluid from paddle.fluid.param_attr import ParamAttr -from paddle.fluid.initializer import Xavier -from paddle.fluid.regularizer import L2Decay from ppdet.core.workspace import register diff --git a/static/ppdet/modeling/backbones/hrnet.py b/static/ppdet/modeling/backbones/hrnet.py index bd86fb79b..d45d25916 100644 --- a/static/ppdet/modeling/backbones/hrnet.py +++ b/static/ppdet/modeling/backbones/hrnet.py @@ -28,8 +28,6 @@ from numbers import Integral from paddle.fluid.initializer import MSRA import math -from .name_adapter import NameAdapter - __all__ = ['HRNet'] diff --git a/static/ppdet/modeling/backbones/mobilenet_v3.py b/static/ppdet/modeling/backbones/mobilenet_v3.py index 96c425fd6..1dad8c26d 100644 --- a/static/ppdet/modeling/backbones/mobilenet_v3.py +++ b/static/ppdet/modeling/backbones/mobilenet_v3.py @@ -22,10 +22,7 @@ import paddle.fluid as fluid from paddle.fluid.param_attr import ParamAttr from paddle.fluid.regularizer import L2Decay -import math import numpy as np -from collections import OrderedDict - from ppdet.core.workspace import register from numbers import Integral diff --git a/static/ppdet/modeling/backbones/res2net.py b/static/ppdet/modeling/backbones/res2net.py index d30ce0b80..b15047cb8 100644 --- a/static/ppdet/modeling/backbones/res2net.py +++ b/static/ppdet/modeling/backbones/res2net.py @@ -16,20 +16,11 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -from collections import OrderedDict - from paddle import fluid -from paddle.fluid.param_attr import ParamAttr -from paddle.fluid.framework import Variable -from paddle.fluid.regularizer import L2Decay -from paddle.fluid.initializer import Constant from ppdet.core.workspace import register, serializable -from numbers import Integral - from .nonlocal_helper import add_space_nonlocal -from .name_adapter import NameAdapter -from .resnet import ResNet, ResNetC5 +from .resnet import ResNet __all__ = ['Res2Net', 'Res2NetC5'] diff --git a/static/ppdet/modeling/losses/diou_loss_yolo.py b/static/ppdet/modeling/losses/diou_loss_yolo.py index 9d83eecde..bb412438f 100644 --- a/static/ppdet/modeling/losses/diou_loss_yolo.py +++ b/static/ppdet/modeling/losses/diou_loss_yolo.py @@ -15,9 +15,6 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import numpy as np -from paddle.fluid.param_attr import ParamAttr -from paddle.fluid.initializer import NumpyArrayInitializer from paddle import fluid from ppdet.core.workspace import register, serializable diff --git a/static/ppdet/modeling/losses/fcos_loss.py b/static/ppdet/modeling/losses/fcos_loss.py index 7275874c6..260d05351 100644 --- a/static/ppdet/modeling/losses/fcos_loss.py +++ b/static/ppdet/modeling/losses/fcos_loss.py @@ -18,7 +18,6 @@ from __future__ import print_function from paddle import fluid from paddle.fluid.param_attr import ParamAttr -from paddle.fluid.initializer import Normal, Constant, NumpyArrayInitializer from ppdet.core.workspace import register, serializable INF = 1e8 diff --git a/static/ppdet/modeling/losses/iou_aware_loss.py b/static/ppdet/modeling/losses/iou_aware_loss.py index d0aeb9df3..d15c20e73 100644 --- a/static/ppdet/modeling/losses/iou_aware_loss.py +++ b/static/ppdet/modeling/losses/iou_aware_loss.py @@ -15,9 +15,6 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import numpy as np -from paddle.fluid.param_attr import ParamAttr -from paddle.fluid.initializer import NumpyArrayInitializer from paddle import fluid from ppdet.core.workspace import register, serializable diff --git a/static/ppdet/modeling/losses/iou_loss.py b/static/ppdet/modeling/losses/iou_loss.py index 590217000..ac098e966 100644 --- a/static/ppdet/modeling/losses/iou_loss.py +++ b/static/ppdet/modeling/losses/iou_loss.py @@ -16,9 +16,6 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np -from paddle.fluid.param_attr import ParamAttr -from paddle.fluid.initializer import NumpyArrayInitializer - from paddle import fluid from ppdet.core.workspace import register, serializable diff --git a/static/ppdet/modeling/losses/ssd_with_lmk_loss.py b/static/ppdet/modeling/losses/ssd_with_lmk_loss.py index 8cedee2d4..3da23c911 100644 --- a/static/ppdet/modeling/losses/ssd_with_lmk_loss.py +++ b/static/ppdet/modeling/losses/ssd_with_lmk_loss.py @@ -14,7 +14,6 @@ import paddle.fluid as fluid from paddle.fluid.layer_helper import LayerHelper -from paddle.fluid.framework import Variable import paddle.fluid.layers as layers from paddle.fluid.layers import (tensor, iou_similarity, bipartite_match, target_assign, box_coder) diff --git a/static/ppdet/modeling/roi_heads/htc_bbox_head.py b/static/ppdet/modeling/roi_heads/htc_bbox_head.py index d43c7d9b8..f633074a9 100644 --- a/static/ppdet/modeling/roi_heads/htc_bbox_head.py +++ b/static/ppdet/modeling/roi_heads/htc_bbox_head.py @@ -17,12 +17,10 @@ from __future__ import division from __future__ import print_function import paddle.fluid as fluid from paddle.fluid.param_attr import ParamAttr -from paddle.fluid.initializer import Normal, Xavier +from paddle.fluid.initializer import Normal from paddle.fluid.regularizer import L2Decay -from paddle.fluid.initializer import MSRA from ppdet.modeling.ops import MultiClassNMS -from ppdet.modeling.ops import ConvNorm from ppdet.modeling.losses import SmoothL1Loss from ppdet.core.workspace import register diff --git a/static/ppdet/modeling/roi_heads/htc_semantic_head.py b/static/ppdet/modeling/roi_heads/htc_semantic_head.py index 227889885..98bc18cba 100644 --- a/static/ppdet/modeling/roi_heads/htc_semantic_head.py +++ b/static/ppdet/modeling/roi_heads/htc_semantic_head.py @@ -17,12 +17,8 @@ from __future__ import division from __future__ import print_function from paddle import fluid -from paddle.fluid.param_attr import ParamAttr -from paddle.fluid.initializer import MSRA -from paddle.fluid.regularizer import L2Decay from ppdet.core.workspace import register -from ppdet.modeling.ops import ConvNorm __all__ = ['FusedSemanticHead'] diff --git a/static/ppdet/modeling/tests/test_architectures.py b/static/ppdet/modeling/tests/test_architectures.py index bbcbc1aaf..5786f9b56 100644 --- a/static/ppdet/modeling/tests/test_architectures.py +++ b/static/ppdet/modeling/tests/test_architectures.py @@ -17,10 +17,8 @@ from __future__ import division from __future__ import print_function import unittest -import numpy as np import paddle -import paddle.fluid as fluid import os import sys # add python path of PadleDetection to sys.path @@ -29,9 +27,9 @@ if parent_path not in sys.path: sys.path.append(parent_path) try: + from ppdet.utils.check import enable_static_mode, logger from ppdet.modeling.tests.decorator_helper import prog_scope from ppdet.core.workspace import load_config, merge_config, create - from ppdet.utils.check import enable_static_mode except ImportError as e: if sys.argv[0].find('static') >= 0: logger.error("Importing ppdet failed when running static model " diff --git a/static/ppdet/utils/bbox_utils.py b/static/ppdet/utils/bbox_utils.py index ff16e8b9d..c6204d73b 100644 --- a/static/ppdet/utils/bbox_utils.py +++ b/static/ppdet/utils/bbox_utils.py @@ -19,8 +19,6 @@ from __future__ import print_function import logging import numpy as np -import paddle.fluid as fluid - __all__ = ["bbox_overlaps", "box_to_delta"] logger = logging.getLogger(__name__) diff --git a/static/ppdet/utils/eval_utils.py b/static/ppdet/utils/eval_utils.py index d6769bbcf..d55e5008d 100644 --- a/static/ppdet/utils/eval_utils.py +++ b/static/ppdet/utils/eval_utils.py @@ -24,7 +24,7 @@ import time import paddle.fluid as fluid from .voc_eval import bbox_eval as voc_bbox_eval -from .post_process import mstest_box_post_process, mstest_mask_post_process, box_flip +from .post_process import mstest_box_post_process, mstest_mask_post_process __all__ = ['parse_fetches', 'eval_run', 'eval_results', 'json_eval_results'] diff --git a/static/ppdet/utils/export_utils.py b/static/ppdet/utils/export_utils.py index f2e280a8b..5d4f3790a 100644 --- a/static/ppdet/utils/export_utils.py +++ b/static/ppdet/utils/export_utils.py @@ -18,7 +18,6 @@ from __future__ import print_function import os import yaml -import numpy as np from collections import OrderedDict import logging diff --git a/static/ppdet/utils/oid_eval.py b/static/ppdet/utils/oid_eval.py index 0a5a0c534..c2a7e6da6 100644 --- a/static/ppdet/utils/oid_eval.py +++ b/static/ppdet/utils/oid_eval.py @@ -17,10 +17,6 @@ from __future__ import division from __future__ import print_function from __future__ import unicode_literals -import os -import sys -import numpy as np - from .coco_eval import bbox2out import logging diff --git a/static/ppdet/utils/post_process.py b/static/ppdet/utils/post_process.py index cf2519983..ad8f2f233 100644 --- a/static/ppdet/utils/post_process.py +++ b/static/ppdet/utils/post_process.py @@ -19,7 +19,6 @@ from __future__ import print_function import logging import numpy as np import cv2 -import paddle.fluid as fluid __all__ = ['nms'] diff --git a/static/ppdet/utils/voc_eval.py b/static/ppdet/utils/voc_eval.py index 4ffd91260..3d6c6b967 100644 --- a/static/ppdet/utils/voc_eval.py +++ b/static/ppdet/utils/voc_eval.py @@ -18,8 +18,6 @@ from __future__ import print_function from __future__ import unicode_literals import os -import sys -import numpy as np from ..data.source.voc import pascalvoc_label from .map_utils import DetectionMAP diff --git a/static/ppdet/utils/voc_utils.py b/static/ppdet/utils/voc_utils.py index 69fec1c16..735cc2aef 100644 --- a/static/ppdet/utils/voc_utils.py +++ b/static/ppdet/utils/voc_utils.py @@ -20,7 +20,6 @@ import os import os.path as osp import re import random -import shutil __all__ = ['create_list'] diff --git a/static/ppdet/utils/widerface_eval_utils.py b/static/ppdet/utils/widerface_eval_utils.py index e7447e8fe..e949a497c 100644 --- a/static/ppdet/utils/widerface_eval_utils.py +++ b/static/ppdet/utils/widerface_eval_utils.py @@ -20,7 +20,6 @@ import os import numpy as np from ppdet.data.source.widerface import widerface_label -from ppdet.utils.coco_eval import bbox2out import logging logger = logging.getLogger(__name__) diff --git a/static/slim/distillation/distill.py b/static/slim/distillation/distill.py index d19ef2eb4..dd98d5385 100644 --- a/static/slim/distillation/distill.py +++ b/static/slim/distillation/distill.py @@ -16,7 +16,9 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) if parent_path not in sys.path: @@ -27,11 +29,9 @@ FORMAT = '%(asctime)s-%(levelname)s: %(message)s' logging.basicConfig(level=logging.INFO, format=FORMAT) logger = logging.getLogger(__name__) -import numpy as np from collections import OrderedDict from paddleslim.dist.single_distiller import merge, l2_loss -import paddle from paddle import fluid try: diff --git a/static/slim/extensions/distill_pruned_model/distill_pruned_model.py b/static/slim/extensions/distill_pruned_model/distill_pruned_model.py index 9824024b4..02b112d22 100644 --- a/static/slim/extensions/distill_pruned_model/distill_pruned_model.py +++ b/static/slim/extensions/distill_pruned_model/distill_pruned_model.py @@ -16,7 +16,8 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 4))) @@ -28,13 +29,11 @@ FORMAT = '%(asctime)s-%(levelname)s: %(message)s' logging.basicConfig(level=logging.INFO, format=FORMAT) logger = logging.getLogger(__name__) -import numpy as np from collections import OrderedDict -from paddleslim.dist.single_distiller import merge, l2_loss +from paddleslim.dist.single_distiller import merge from paddleslim.prune import Pruner from paddleslim.analysis import flops -import paddle from paddle import fluid try: diff --git a/static/slim/nas/search_space/blazefacespace_nas.py b/static/slim/nas/search_space/blazefacespace_nas.py index 342a2c812..06b1edefc 100644 --- a/static/slim/nas/search_space/blazefacespace_nas.py +++ b/static/slim/nas/search_space/blazefacespace_nas.py @@ -17,8 +17,6 @@ from __future__ import division from __future__ import print_function import numpy as np -import paddle.fluid as fluid -from paddle.fluid.param_attr import ParamAttr from paddleslim.nas.search_space.search_space_base import SearchSpaceBase from paddleslim.nas.search_space.search_space_registry import SEARCHSPACE from ppdet.modeling.backbones.blazenet import BlazeNet diff --git a/static/slim/nas/train_nas.py b/static/slim/nas/train_nas.py index 12709c82d..d0836d4c3 100644 --- a/static/slim/nas/train_nas.py +++ b/static/slim/nas/train_nas.py @@ -16,7 +16,9 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) if parent_path not in sys.path: @@ -27,7 +29,6 @@ import numpy as np import datetime from collections import deque -import paddle from paddle import fluid import logging @@ -61,7 +62,6 @@ except ImportError as e: from paddleslim.analysis import flops, TableLatencyEvaluator from paddleslim.nas import SANAS -import search_space @register diff --git a/static/slim/prune/eval.py b/static/slim/prune/eval.py index fa76ac8bb..c87f86e38 100644 --- a/static/slim/prune/eval.py +++ b/static/slim/prune/eval.py @@ -16,14 +16,14 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) if parent_path not in sys.path: sys.path.append(parent_path) -import paddle import paddle.fluid as fluid from paddleslim.prune import Pruner from paddleslim.analysis import flops diff --git a/static/slim/prune/export_model.py b/static/slim/prune/export_model.py index d8fcdb8fc..d6f92a35e 100644 --- a/static/slim/prune/export_model.py +++ b/static/slim/prune/export_model.py @@ -16,13 +16,14 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) if parent_path not in sys.path: sys.path.append(parent_path) -import paddle from paddle import fluid import logging diff --git a/static/slim/prune/infer.py b/static/slim/prune/infer.py index 176cd22a1..63cb73ec7 100644 --- a/static/slim/prune/infer.py +++ b/static/slim/prune/infer.py @@ -16,7 +16,9 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) if parent_path not in sys.path: @@ -26,7 +28,6 @@ import glob import numpy as np from PIL import Image -import paddle from paddle import fluid from paddleslim.prune import Pruner from paddleslim.analysis import flops diff --git a/static/slim/prune/prune.py b/static/slim/prune/prune.py index a75c6d4cb..e1c559d85 100644 --- a/static/slim/prune/prune.py +++ b/static/slim/prune/prune.py @@ -16,7 +16,8 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) @@ -29,7 +30,6 @@ import datetime from collections import deque from paddleslim.prune import Pruner from paddleslim.analysis import flops -import paddle from paddle import fluid import logging diff --git a/static/slim/quantization/eval.py b/static/slim/quantization/eval.py index b16d8007d..a552cc944 100644 --- a/static/slim/quantization/eval.py +++ b/static/slim/quantization/eval.py @@ -16,14 +16,14 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) if parent_path not in sys.path: sys.path.append(parent_path) -import paddle import paddle.fluid as fluid import logging diff --git a/static/slim/quantization/export_model.py b/static/slim/quantization/export_model.py index 067c21c37..456b7acea 100644 --- a/static/slim/quantization/export_model.py +++ b/static/slim/quantization/export_model.py @@ -16,7 +16,9 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) if parent_path not in sys.path: @@ -27,7 +29,6 @@ FORMAT = '%(asctime)s-%(levelname)s: %(message)s' logging.basicConfig(level=logging.INFO, format=FORMAT) logger = logging.getLogger(__name__) -import paddle from paddle import fluid try: diff --git a/static/slim/quantization/infer.py b/static/slim/quantization/infer.py index 58c1dac71..453f54b73 100644 --- a/static/slim/quantization/infer.py +++ b/static/slim/quantization/infer.py @@ -16,17 +16,17 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) if parent_path not in sys.path: sys.path.append(parent_path) -import glob import numpy as np from PIL import Image -import paddle from paddle import fluid import logging diff --git a/static/slim/quantization/pact.py b/static/slim/quantization/pact.py index 554ad5b0f..fdc04f76a 100644 --- a/static/slim/quantization/pact.py +++ b/static/slim/quantization/pact.py @@ -12,10 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys import paddle import paddle.fluid as fluid -from paddleslim.quant import quant_aware, convert import numpy as np from paddle.fluid.layer_helper import LayerHelper diff --git a/static/slim/quantization/train.py b/static/slim/quantization/train.py index 12ed7ef50..046313e99 100644 --- a/static/slim/quantization/train.py +++ b/static/slim/quantization/train.py @@ -16,7 +16,9 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) if parent_path not in sys.path: @@ -28,7 +30,6 @@ import datetime from collections import deque import shutil -import paddle from paddle import fluid import logging @@ -58,7 +59,7 @@ except ImportError as e: else: raise e -from paddleslim.quant import quant_aware, convert +from paddleslim.quant import quant_aware from pact import pact, get_optimizer diff --git a/static/slim/sensitive/sensitive.py b/static/slim/sensitive/sensitive.py index a43506ebe..903aa9583 100644 --- a/static/slim/sensitive/sensitive.py +++ b/static/slim/sensitive/sensitive.py @@ -16,29 +16,22 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) if parent_path not in sys.path: sys.path.append(parent_path) -import time -import numpy as np -import datetime -from collections import deque - -import paddle from paddle import fluid -from ppdet.experimental import mixed_precision_context from ppdet.core.workspace import load_config, merge_config, create from ppdet.data.reader import create_reader -from ppdet.utils import dist_utils from ppdet.utils.eval_utils import parse_fetches, eval_run, eval_results -from ppdet.utils.stats import TrainingStats from ppdet.utils.cli import ArgsParser -from ppdet.utils.check import check_gpu, check_version, check_config, enable_static_mode +from ppdet.utils.check import check_version, check_config, enable_static_mode import ppdet.utils.checkpoint as checkpoint from paddleslim.prune import sensitivity import logging diff --git a/static/tools/anchor_cluster.py b/static/tools/anchor_cluster.py index e5fb7147b..76b707a88 100644 --- a/static/tools/anchor_cluster.py +++ b/static/tools/anchor_cluster.py @@ -29,7 +29,6 @@ logging.basicConfig(level=logging.INFO, format=FORMAT) logger = logging.getLogger(__name__) from scipy.cluster.vq import kmeans -import random import numpy as np from tqdm import tqdm diff --git a/static/tools/configure.py b/static/tools/configure.py index 64ff575b4..02515727e 100644 --- a/static/tools/configure.py +++ b/static/tools/configure.py @@ -17,7 +17,7 @@ from __future__ import print_function import os import sys from argparse import ArgumentParser, RawDescriptionHelpFormatter -import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) if parent_path not in sys.path: @@ -114,8 +114,9 @@ def list_modules(**kwargs): print("") max_len = max([len(mod.name) for mod in modules]) for mod in modules: - print(color_tty.green(mod.name.ljust(max_len)), - mod.doc.split('\n')[0]) + print( + color_tty.green(mod.name.ljust(max_len)), + mod.doc.split('\n')[0]) print("") diff --git a/static/tools/eval.py b/static/tools/eval.py index dfaf70dfe..9a7f37986 100644 --- a/static/tools/eval.py +++ b/static/tools/eval.py @@ -16,13 +16,14 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) if parent_path not in sys.path: sys.path.append(parent_path) -import paddle import paddle.fluid as fluid import logging diff --git a/static/tools/export_model.py b/static/tools/export_model.py index d6f6013b7..908039c8b 100644 --- a/static/tools/export_model.py +++ b/static/tools/export_model.py @@ -23,7 +23,6 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) if parent_path not in sys.path: sys.path.append(parent_path) -import paddle from paddle import fluid import logging diff --git a/static/tools/export_serving_model.py b/static/tools/export_serving_model.py index ae11a60ca..22eced7d8 100644 --- a/static/tools/export_serving_model.py +++ b/static/tools/export_serving_model.py @@ -16,14 +16,14 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) if parent_path not in sys.path: sys.path.append(parent_path) -import yaml -import paddle from paddle import fluid import logging diff --git a/static/tools/face_eval.py b/static/tools/face_eval.py index e47ded267..f0ac7343f 100644 --- a/static/tools/face_eval.py +++ b/static/tools/face_eval.py @@ -23,7 +23,6 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) if parent_path not in sys.path: sys.path.append(parent_path) -import paddle import paddle.fluid as fluid import numpy as np import cv2 diff --git a/static/tools/infer.py b/static/tools/infer.py index df831fd54..4f4c2e3fe 100644 --- a/static/tools/infer.py +++ b/static/tools/infer.py @@ -16,7 +16,9 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) if parent_path not in sys.path: @@ -27,7 +29,6 @@ import numpy as np import six from PIL import Image, ImageOps -import paddle from paddle import fluid import logging diff --git a/static/tools/train.py b/static/tools/train.py index 4417a9d9b..f07c12f08 100644 --- a/static/tools/train.py +++ b/static/tools/train.py @@ -16,7 +16,9 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) if parent_path not in sys.path: @@ -30,7 +32,6 @@ import six from collections import deque from paddle.fluid import profiler -import paddle from paddle import fluid from paddle.fluid.layers.learning_rate_scheduler import _decay_step_counter from paddle.fluid.optimizer import ExponentialMovingAverage diff --git a/static/tools/train_multi_machine.py b/static/tools/train_multi_machine.py index 31a7f706a..098845d0a 100644 --- a/static/tools/train_multi_machine.py +++ b/static/tools/train_multi_machine.py @@ -16,7 +16,9 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) if parent_path not in sys.path: @@ -33,7 +35,6 @@ import random import datetime import six from collections import deque -import paddle from paddle.fluid import profiler from paddle import fluid diff --git a/static/tools/x2coco.py b/static/tools/x2coco.py index ef2f0d717..a7765c78f 100644 --- a/static/tools/x2coco.py +++ b/static/tools/x2coco.py @@ -19,11 +19,9 @@ import glob import json import os import os.path as osp -import sys import shutil import xml.etree.ElementTree as ET from tqdm import tqdm -import re import numpy as np import PIL.ImageDraw diff --git a/tools/anchor_cluster.py b/tools/anchor_cluster.py index 87c7e9370..78ed3ea07 100644 --- a/tools/anchor_cluster.py +++ b/tools/anchor_cluster.py @@ -27,13 +27,12 @@ from ppdet.utils.logger import setup_logger logger = setup_logger('ppdet.anchor_cluster') from scipy.cluster.vq import kmeans -import random import numpy as np from tqdm import tqdm from ppdet.utils.cli import ArgsParser from ppdet.utils.check import check_gpu, check_version, check_config -from ppdet.core.workspace import load_config, merge_config, create +from ppdet.core.workspace import load_config, merge_config class BaseAnchorCluster(object): diff --git a/tools/eval.py b/tools/eval.py index 5df7a0774..bf75555c1 100755 --- a/tools/eval.py +++ b/tools/eval.py @@ -16,7 +16,9 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) if parent_path not in sys.path: diff --git a/tools/eval_mot.py b/tools/eval_mot.py index 59d8a7a43..cd608678a 100644 --- a/tools/eval_mot.py +++ b/tools/eval_mot.py @@ -15,7 +15,10 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys + +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) if parent_path not in sys.path: @@ -24,7 +27,6 @@ if parent_path not in sys.path: # ignore warning log import warnings warnings.filterwarnings('ignore') -import glob import paddle from paddle.distributed import ParallelEnv diff --git a/tools/export_model.py b/tools/export_model.py index 213be3d09..3420cf27f 100644 --- a/tools/export_model.py +++ b/tools/export_model.py @@ -15,7 +15,10 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys + +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) if parent_path not in sys.path: diff --git a/tools/infer.py b/tools/infer.py index 7ea0d2353..b24c205ff 100755 --- a/tools/infer.py +++ b/tools/infer.py @@ -15,7 +15,10 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys + +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) if parent_path not in sys.path: diff --git a/tools/infer_mot.py b/tools/infer_mot.py index 407e9aae4..044d1e685 100644 --- a/tools/infer_mot.py +++ b/tools/infer_mot.py @@ -15,7 +15,10 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys + +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) if parent_path not in sys.path: @@ -24,7 +27,6 @@ if parent_path not in sys.path: # ignore warning log import warnings warnings.filterwarnings('ignore') -import glob import paddle from paddle.distributed import ParallelEnv diff --git a/tools/train.py b/tools/train.py index 211322fd5..55aed43ee 100755 --- a/tools/train.py +++ b/tools/train.py @@ -16,22 +16,21 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os, sys +import os +import sys + # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) if parent_path not in sys.path: sys.path.append(parent_path) -import random -import numpy as np # ignore warning log import warnings warnings.filterwarnings('ignore') import paddle -from ppdet.core.workspace import load_config, merge_config, create -from ppdet.utils.checkpoint import load_weight +from ppdet.core.workspace import load_config, merge_config from ppdet.engine import Trainer, init_parallel_env, set_random_seed, init_fleet_env from ppdet.slim import build_slim_model diff --git a/tools/x2coco.py b/tools/x2coco.py index e92ab4be9..9164f9c8c 100644 --- a/tools/x2coco.py +++ b/tools/x2coco.py @@ -19,11 +19,9 @@ import glob import json import os import os.path as osp -import sys import shutil import xml.etree.ElementTree as ET from tqdm import tqdm -import re import numpy as np import PIL.ImageDraw -- GitLab