Bläddra i källkod

Merge pull request #87 from michaelowenliu/develop

Add license
Liu Yi 3 år sedan
förälder
incheckning
f81809d127

+ 0 - 1
paddlers/custom_models/cd/backbones/resnet.py

@@ -33,7 +33,6 @@ from __future__ import print_function
 
 import paddle
 import paddle.nn as nn
-
 from paddle.utils.download import get_weights_path_from_url
 
 __all__ = []

+ 1 - 0
paddlers/custom_models/gan/generators/builder.py

@@ -13,6 +13,7 @@
 # limitations under the License.
 
 import copy
+
 from ....models.ppgan.utils.registry import Registry
 
 GENERATORS = Registry("GENERATOR")

+ 1 - 0
paddlers/custom_models/gan/generators/rcan.py

@@ -1,5 +1,6 @@
 # base on https://github.com/kongdebug/RCAN-Paddle
 import math
+
 import paddle
 import paddle.nn as nn
 

+ 2 - 0
paddlers/custom_models/seg/farseg.py

@@ -18,11 +18,13 @@ Apache License [see LICENSE for details]
 """
 
 import math
+
 import paddle.nn as nn
 import paddle.nn.functional as F
 from paddle.vision.models import resnet50
 from paddle import nn
 import paddle.nn.functional as F
+
 from .layers import (Identity, ConvReLU, kaiming_normal_init, constant_init)
 
 

+ 3 - 1
paddlers/datasets/coco.py

@@ -17,9 +17,11 @@ import copy
 import os
 import os.path as osp
 import random
-import numpy as np
 from collections import OrderedDict
+
+import numpy as np
 from paddle.io import Dataset
+
 from paddlers.utils import logging, get_num_workers, get_encoding, path_normalization, is_pic
 from paddlers.transforms import ImgDecoder, MixupImage
 from paddlers.tools import YOLOAnchorCluster

+ 1 - 0
paddlers/datasets/seg_dataset.py

@@ -16,6 +16,7 @@ import os.path as osp
 import copy
 
 from paddle.io import Dataset
+
 from paddlers.utils import logging, get_num_workers, get_encoding, path_normalization, is_pic
 
 

+ 3 - 1
paddlers/datasets/voc.py

@@ -18,10 +18,12 @@ import os
 import os.path as osp
 import random
 import re
-import numpy as np
 from collections import OrderedDict
 import xml.etree.ElementTree as ET
+
+import numpy as np
 from paddle.io import Dataset
+
 from paddlers.utils import logging, get_num_workers, get_encoding, path_normalization, is_pic
 from paddlers.transforms import ImgDecoder, MixupImage
 from paddlers.tools import YOLOAnchorCluster

+ 1 - 0
paddlers/deploy/predictor.py

@@ -18,6 +18,7 @@ import numpy as np
 from paddle.inference import Config
 from paddle.inference import create_predictor
 from paddle.inference import PrecisionType
+
 from paddlers.tasks import load_model
 from paddlers.utils import logging, Timer
 

+ 3 - 1
paddlers/tasks/classifier.py

@@ -14,11 +14,13 @@
 
 import math
 import os.path as osp
-import numpy as np
 from collections import OrderedDict
+
+import numpy as np
 import paddle
 import paddle.nn.functional as F
 from paddle.static import InputSpec
+
 import paddlers.models.ppcls as paddleclas
 import paddlers.custom_models.cls as cmcls
 import paddlers

+ 0 - 1
paddlers/tasks/image_restorer.py

@@ -14,7 +14,6 @@
 
 import os
 import time
-
 import datetime
 
 import paddle

+ 3 - 1
paddlers/tasks/load_model.py

@@ -13,10 +13,12 @@
 # limitations under the License.
 
 import os.path as osp
-import numpy as np
 import yaml
+
+import numpy as np
 import paddle
 import paddleslim
+
 import paddlers
 import paddlers.utils.logging as logging
 from paddlers.transforms import build_transforms

+ 2 - 0
paddlers/tasks/object_detector.py

@@ -18,9 +18,11 @@ import collections
 import copy
 import os
 import os.path as osp
+
 import numpy as np
 import paddle
 from paddle.static import InputSpec
+
 import paddlers.models.ppdet as ppdet
 from paddlers.models.ppdet.modeling.proposal_generator.target_layer import BBoxAssigner, MaskAssigner
 import paddlers

+ 3 - 1
paddlers/tasks/segmenter.py

@@ -14,12 +14,14 @@
 
 import math
 import os.path as osp
+from collections import OrderedDict
+
 import numpy as np
 import cv2
-from collections import OrderedDict
 import paddle
 import paddle.nn.functional as F
 from paddle.static import InputSpec
+
 import paddlers.models.ppseg as paddleseg
 import paddlers.custom_models.seg as cmseg
 import paddlers

+ 1 - 0
paddlers/tasks/utils/visualize.py

@@ -16,6 +16,7 @@ import os
 import cv2
 import numpy as np
 import time
+
 import paddlers.utils.logging as logging
 from paddlers.utils import is_pic
 from .det_metrics.coco_utils import loadRes

+ 2 - 0
paddlers/tools/yolo_cluster.py

@@ -14,9 +14,11 @@
 
 import copy
 import os
+
 import numpy as np
 from tqdm import tqdm
 from scipy.cluster.vq import kmeans
+
 from paddlers.utils import logging
 
 __all__ = ['YOLOAnchorCluster']

+ 3 - 1
paddlers/transforms/batch_operators.py

@@ -14,12 +14,14 @@
 
 import traceback
 import random
-import numpy as np
 try:
     from collections.abc import Sequence
 except Exception:
     from collections import Sequence
+
+import numpy as np
 from paddle.fluid.dataloader.collate import default_collate_fn
+
 from .operators import Transform, Resize, ResizeByShort, _Permute, interp_dict
 from .box_utils import jaccard_overlap
 from paddlers.utils import logging

+ 2 - 1
paddlers/transforms/functions.py

@@ -13,8 +13,9 @@
 # limitations under the License.
 
 import cv2
-import numpy as np
 import copy
+
+import numpy as np
 import shapely.ops
 from shapely.geometry import Polygon, MultiPolygon, GeometryCollection
 from sklearn.decomposition import PCA

+ 1 - 1
paddlers/transforms/operators.py

@@ -27,8 +27,8 @@ import numpy as np
 import cv2
 import imghdr
 from PIL import Image
-import paddlers
 
+import paddlers
 from .functions import normalize, horizontal_flip, permute, vertical_flip, center_crop, is_poly, \
     horizontal_flip_poly, horizontal_flip_rle, vertical_flip_poly, vertical_flip_rle, crop_poly, \
     crop_rle, expand_poly, expand_rle, resize_poly, resize_rle, de_haze, pca, select_bands, \

+ 2 - 0
paddlers/utils/checkpoint.py

@@ -14,8 +14,10 @@
 
 import os
 import os.path as osp
+
 import glob
 import paddle
+
 from . import logging
 from .download import download_and_decompress
 

+ 2 - 0
paddlers/utils/download.py

@@ -21,8 +21,10 @@ import time
 import hashlib
 import tarfile
 import zipfile
+
 import filelock
 import paddle
+
 from . import logging
 
 DOWNLOAD_RETRY_LIMIT = 3

+ 1 - 0
paddlers/utils/env.py

@@ -16,6 +16,7 @@ import os
 import platform
 import random
 import multiprocessing as mp
+
 import numpy as np
 import paddle
 

+ 1 - 0
paddlers/utils/logging.py

@@ -15,6 +15,7 @@
 import time
 import os
 import sys
+
 import colorama
 from colorama import init
 import paddle

+ 1 - 1
paddlers/utils/stats.py

@@ -13,9 +13,9 @@
 # limitations under the License.
 
 import collections
-import numpy as np
 import datetime
 
+import numpy as np
 
 class SmoothedValue(object):
     """Track a series of values and provide access to smoothed values over a

+ 2 - 0
paddlers/utils/utils.py

@@ -20,7 +20,9 @@ import math
 import imghdr
 import chardet
 import json
+
 import numpy as np
+
 from . import logging
 import platform
 import paddlers

+ 5 - 3
tools/coco2mask.py

@@ -15,14 +15,16 @@
 import os
 import os.path as osp
 import shutil
-import cv2
-import numpy as np
 import json
 import argparse
+from collections import defaultdict
+
+import cv2
+import numpy as np
 import glob
 from tqdm import tqdm
 from PIL import Image
-from collections import defaultdict
+
 from utils import Timer
 
 

+ 15 - 7
tools/coco_tools/json_AnnoSta.py

@@ -1,10 +1,17 @@
-# -*- coding: utf-8 -*- 
-# @File             : json_annotations_sta.py
-# @Author           : zhaoHL
-# @Contact          : huilin16@qq.com
-# @Time Create First: 2021/8/1 10:25
-# @Contributor      : zhaoHL
-# @Time Modify Last : 2021/8/1 10:25
+# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 '''
 @File Description:
 # json文件annotations信息,生成统计结果csv,对象框shape、对象看shape比例、对象框起始位置、对象结束位置、对象结束位置、对象类别、单个图像对象数量的分布
@@ -22,6 +29,7 @@ python ./coco_tools/json_AnnoSta.py \
 import os
 import json
 import argparse
+
 import numpy as np
 import pandas as pd
 import seaborn as sns

+ 15 - 7
tools/coco_tools/json_Img2Json.py

@@ -1,10 +1,17 @@
-# -*- coding: utf-8 -*- 
-# @File             : json_getTest.py
-# @Author           : zhaoHL
-# @Contact          : huilin16@qq.com
-# @Time Create First: 2021/8/1 10:25
-# @Contributor      : zhaoHL
-# @Time Modify Last : 2021/8/1 10:25
+# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 '''
 @File Description:
 # 根据test影像文件夹生成test.json
@@ -16,6 +23,7 @@ python ./coco_tools/json_Img2Json.py \
 import os, cv2
 import json
 import argparse
+
 from tqdm import tqdm
 
 

+ 14 - 7
tools/coco_tools/json_ImgSta.py

@@ -1,10 +1,17 @@
-# -*- coding: utf-8 -*- 
-# @File             : json_images_sta.py
-# @Author           : zhaoHL
-# @Contact          : huilin16@qq.com
-# @Time Create First: 2021/8/1 10:25
-# @Contributor      : zhaoHL
-# @Time Modify Last : 2021/8/1 10:25
+# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 '''
 @File Description:
 # 统计json文件images信息,生成统计结果csv,同时生成图像shape、图像shape比例的二维分布图

+ 14 - 7
tools/coco_tools/json_InfoShow.py

@@ -1,10 +1,17 @@
-# -*- coding: utf-8 -*- 
-# @File             : json_infoShow.py
-# @Author           : zhaoHL
-# @Contact          : huilin16@qq.com
-# @Time Create First: 2021/8/1 10:25
-# @Contributor      : zhaoHL
-# @Time Modify Last : 2021/8/1 10:25
+# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 '''
 @File Description:
 # 输出json文件基本信息

+ 14 - 7
tools/coco_tools/json_Merge.py

@@ -1,10 +1,17 @@
-# -*- coding: utf-8 -*- 
-# @File             : json_merge.py
-# @Author           : zhaoHL
-# @Contact          : huilin16@qq.com
-# @Time Create First: 2021/8/1 10:25
-# @Contributor      : zhaoHL
-# @Time Modify Last : 2021/8/1 10:25
+# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 '''
 @File Description:
 # 合并json文件,可以通过merge_keys控制合并的字段, 默认合并'images', 'annotations'字段

+ 15 - 7
tools/coco_tools/json_Split.py

@@ -1,10 +1,17 @@
-# -*- coding: utf-8 -*- 
-# @File             : json_split.py
-# @Author           : zhaoHL
-# @Contact          : huilin16@qq.com
-# @Time Create First: 2021/8/1 10:25
-# @Contributor      : zhaoHL
-# @Time Modify Last : 2021/8/1 10:25
+# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 '''
 @File Description:
 # json数据集划分,可以通过val_split_rate、val_split_num控制划分比例或个数, keep_val_inTrain可以设定是否在train中保留val相关信息
@@ -16,6 +23,7 @@ python ./coco_tools/json_Split.py \
 
 import json
 import argparse
+
 import pandas as pd
 
 def get_annno(df_img_split, df_anno):

+ 3 - 1
tools/mask2geojson.py

@@ -13,11 +13,13 @@
 # limitations under the License.
 
 import codecs
+import argparse
+
 import cv2
 import numpy as np
-import argparse
 import geojson
 from geojson import Polygon, Feature, FeatureCollection
+
 from utils import Raster, Timer
 
 

+ 4 - 3
tools/mask2shp.py

@@ -14,11 +14,10 @@
 
 import os
 import os.path as osp
-import numpy as np
 import argparse
-from PIL import Image
-from utils import Raster, Timer
 
+import numpy as np
+from PIL import Image
 try:
     from osgeo import gdal, ogr, osr
 except ImportError:
@@ -26,6 +25,8 @@ except ImportError:
     import ogr
     import osr
 
+from utils import Raster, Timer
+
 
 def _mask2tif(mask_path, tmp_path, proj, geot):
     mask = np.asarray(Image.open(mask_path))

+ 3 - 3
tools/matcher.py

@@ -12,16 +12,16 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import numpy as np
-import cv2
 import argparse
-from utils import Raster, raster2uint8, Timer
 
+import numpy as np
+import cv2
 try:
     from osgeo import gdal
 except ImportError:
     import gdal
 
+from utils import Raster, raster2uint8, Timer
 
 class MatchError(Exception):
     def __str__(self):

+ 4 - 3
tools/oif.py

@@ -12,13 +12,14 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import numpy as np
-import pandas as pd
 import itertools
 import argparse
-from utils import Raster, Timer
 from easydict import EasyDict as edict
 
+import numpy as np
+import pandas as pd
+
+from utils import Raster, Timer
 
 def _calcOIF(rgb, stds, rho):
     r, g, b = rgb

+ 2 - 0
tools/spliter.py

@@ -16,7 +16,9 @@ import os
 import os.path as osp
 import argparse
 from math import ceil
+
 from PIL import Image
+
 from utils import Raster, Timer
 
 

+ 3 - 1
tools/utils/raster.py

@@ -13,8 +13,10 @@
 # limitations under the License.
 
 import os.path as osp
-import numpy as np
 from typing import List, Tuple, Union
+
+import numpy as np
+
 from paddlers.transforms.functions import to_uint8 as raster2uint8
 
 try: