diff --git a/ppdet/model_zoo/tests/__init__.py b/ppdet/model_zoo/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..6f0ea85344b7e0c679730356928c8749cf71cd66 --- /dev/null +++ b/ppdet/model_zoo/tests/__init__.py @@ -0,0 +1,13 @@ +# Copyright (c) 2021 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. diff --git a/ppdet/model_zoo/tests/test_get_model.py b/ppdet/model_zoo/tests/test_get_model.py new file mode 100644 index 0000000000000000000000000000000000000000..e07217fa09fcefcac7bba1c94d18610df071bbe1 --- /dev/null +++ b/ppdet/model_zoo/tests/test_get_model.py @@ -0,0 +1,49 @@ +# Copyright (c) 2021 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. + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import os +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' + + +class TestGetConfigFile(unittest.TestCase): + def test_main(self): + try: + cfg_file = ppdet.model_zoo.get_config_file(MODEL_NAME) + assert os.path.isfile(cfg_file) + except: + self.assertTrue(False) + + +class TestGetModel(unittest.TestCase): + def test_main(self): + try: + model = ppdet.model_zoo.get_model(MODEL_NAME) + assert isinstance(model, paddle.nn.Layer) + except: + self.assertTrue(False) + + +if __name__ == '__main__': + unittest.main() diff --git a/ppdet/model_zoo/tests/test_list_model.py b/ppdet/model_zoo/tests/test_list_model.py new file mode 100644 index 0000000000000000000000000000000000000000..8f91afe0058ff32fae7e1006bb8b4c4de9500fef --- /dev/null +++ b/ppdet/model_zoo/tests/test_list_model.py @@ -0,0 +1,68 @@ +# Copyright (c) 2021 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. + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import unittest +import ppdet + + +class TestListModel(unittest.TestCase): + def setUp(self): + self._filter = [] + + def test_main(self): + try: + ppdet.model_zoo.list_model(self._filter) + self.assertTrue(True) + except: + self.assertTrue(False) + + +class TestListModelYOLO(TestListModel): + def setUp(self): + self._filter = ['yolo'] + + +class TestListModelRCNN(TestListModel): + def setUp(self): + self._filter = ['rcnn'] + + +class TestListModelSSD(TestListModel): + def setUp(self): + self._filter = ['ssd'] + + +class TestListModelMultiFilter(TestListModel): + def setUp(self): + self._filter = ['yolo', 'darknet'] + + +class TestListModelError(unittest.TestCase): + def setUp(self): + self._filter = ['xxx'] + + def test_main(self): + try: + ppdet.model_zoo.list_model(self._filter) + self.assertTrue(False) + except ValueError: + self.assertTrue(True) + + +if __name__ == '__main__': + unittest.main() diff --git a/ppdet/modeling/layers.py b/ppdet/modeling/layers.py index 75e554559fb1a54dd328b56c6f26ba70f4be4b90..67e51ef7fd6e963fd4dea1c61b6dc492339834e9 100644 --- a/ppdet/modeling/layers.py +++ b/ppdet/modeling/layers.py @@ -248,38 +248,6 @@ class LiteConv(nn.Layer): return out -@register -@serializable -class AnchorGeneratorRPN(object): - def __init__(self, - anchor_sizes=[32, 64, 128, 256, 512], - aspect_ratios=[0.5, 1.0, 2.0], - stride=[16.0, 16.0], - variance=[1.0, 1.0, 1.0, 1.0], - anchor_start_size=None): - super(AnchorGeneratorRPN, self).__init__() - self.anchor_sizes = anchor_sizes - self.aspect_ratios = aspect_ratios - self.stride = stride - self.variance = variance - self.anchor_start_size = anchor_start_size - - def __call__(self, input, level=None): - anchor_sizes = self.anchor_sizes if ( - level is None or self.anchor_start_size is None) else ( - self.anchor_start_size * 2**level) - stride = self.stride if ( - level is None or self.anchor_start_size is None) else ( - self.stride[0] * (2.**level), self.stride[1] * (2.**level)) - anchor, var = ops.anchor_generator( - input=input, - anchor_sizes=anchor_sizes, - aspect_ratios=self.aspect_ratios, - stride=stride, - variance=self.variance) - return anchor, var - - @register @serializable class AnchorGeneratorSSD(object): diff --git a/ppdet/modeling/tests/test_ops.py b/ppdet/modeling/tests/test_ops.py index c08bcca4b17bc4907db0a141203c80d8da54e9ee..d951b90dd0b9e9bac705bc605a7f88dcd4e88fc7 100644 --- a/ppdet/modeling/tests/test_ops.py +++ b/ppdet/modeling/tests/test_ops.py @@ -169,6 +169,8 @@ class TestCollectFpnProposals(LayerTest): max_level=5, post_nms_top_n=2000) + paddle.disable_static() + class TestDistributeFpnProposals(LayerTest): def test_distribute_fpn_proposals(self): @@ -231,6 +233,8 @@ class TestDistributeFpnProposals(LayerTest): refer_level=4, refer_scale=224) + paddle.disable_static() + class TestROIAlign(LayerTest): def test_roi_align(self): @@ -289,6 +293,8 @@ class TestROIAlign(LayerTest): rois=rois, output_size=(7, 7)) + paddle.disable_static() + class TestROIPool(LayerTest): def test_roi_pool(self): @@ -347,6 +353,8 @@ class TestROIPool(LayerTest): rois=rois, output_size=(7, 7)) + paddle.disable_static() + class TestIoUSimilarity(LayerTest): def test_iou_similarity(self): @@ -473,6 +481,8 @@ class TestYoloBox(LayerTest): 32, scale_x_y=1.2) + paddle.disable_static() + class TestPriorBox(LayerTest): def test_prior_box(self): @@ -530,42 +540,7 @@ class TestPriorBox(LayerTest): clip=True, flip=True) - -class TestAnchorGenerator(LayerTest): - def test_anchor_generator(self): - b, c, h, w = 2, 48, 16, 16 - input_np = np.random.rand(2, 48, 16, 16).astype('float32') - with self.static_graph(): - input = paddle.static.data( - name='input', shape=[b, c, h, w], dtype='float32') - - anchor, var = ops.anchor_generator( - input=input, - anchor_sizes=[64, 128, 256, 512], - aspect_ratios=[0.5, 1.0, 2.0], - variance=[0.1, 0.1, 0.2, 0.2], - stride=[16.0, 16.0], - offset=0.5) - anchor_np, var_np = self.get_static_graph_result( - feed={'input': input_np, }, - fetch_list=[anchor, var], - with_lod=False) - - with self.dynamic_graph(): - inputs_dy = base.to_variable(input_np) - - anchor_dy, var_dy = ops.anchor_generator( - input=inputs_dy, - anchor_sizes=[64, 128, 256, 512], - aspect_ratios=[0.5, 1.0, 2.0], - variance=[0.1, 0.1, 0.2, 0.2], - stride=[16.0, 16.0], - offset=0.5) - anchor_dy_np = anchor_dy.numpy() - var_dy_np = var_dy.numpy() - - self.assertTrue(np.array_equal(anchor_np, anchor_dy_np)) - self.assertTrue(np.array_equal(var_np, var_dy_np)) + paddle.disable_static() class TestMulticlassNms(LayerTest): @@ -726,6 +701,8 @@ class TestMatrixNMS(LayerTest): keep_top_k=200, return_index=True) + paddle.disable_static() + class TestBoxCoder(LayerTest): def test_box_coder(self): @@ -788,6 +765,8 @@ class TestBoxCoder(LayerTest): self.assertRaises(TypeError, ops.box_coder, prior_box, prior_box_var, target_box) + paddle.disable_static() + class TestGenerateProposals(LayerTest): def test_generate_proposals(self): diff --git a/ppdet/modeling/tests/test_transfrom.py b/ppdet/modeling/tests/test_transfrom.py deleted file mode 100644 index b98710467e31747342d71b9050e3188ecbac4f5a..0000000000000000000000000000000000000000 --- a/ppdet/modeling/tests/test_transfrom.py +++ /dev/null @@ -1,240 +0,0 @@ -from __future__ import print_function -import random -import unittest -import numpy as np -import copy -# add python path of PadleDetection to sys.path -import os -import sys -parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 4))) -if parent_path not in sys.path: - sys.path.append(parent_path) - -from ppdet.data.transform import * - - -def gen_sample(h, w, nt, nc, random_score=True, channel_first=False): - im = np.random.randint(0, 256, size=(h, w, 3)).astype('float32') - if channel_first: - im = im.transpose((2, 0, 1)) - gt_bbox = np.random.random(size=(nt, 4)).astype('float32') - gt_class = np.random.randint(0, nc, size=(nt, 1)).astype('int32') - if random_score: - gt_score = np.random.random(size=(nt, 1)) - else: - gt_score = np.ones(shape=(nt, 1)).astype('float32') - is_crowd = np.zeros_like(gt_class) - sample = { - 'image': im, - 'gt_bbox': gt_bbox, - 'gt_class': gt_class, - 'gt_score': gt_score, - 'is_crowd': is_crowd, - 'h': h, - 'w': w - } - return sample - - -class TestTransformOp(unittest.TestCase): - def setUp(self): - self.h, self.w = np.random.randint(1, 1024, size=2) - self.nt = np.random.randint(1, 50) - self.nc = 80 - - def assertAllClose(self, x, y, msg, atol=1e-5, rtol=1e-3): - self.assertTrue(np.allclose(x, y, atol=atol, rtol=rtol), msg=msg) - - -class TestResizeOp(TestTransformOp): - def test_resize(self): - sample = gen_sample(self.h, self.w, self.nt, self.nc) - orig_op = Resize(target_dim=608, interp=2) - curr_op = ResizeOp(target_size=608, keep_ratio=False, interp=2) - orig_res = orig_op(copy.deepcopy(sample)) - curr_res = curr_op(copy.deepcopy(sample)) - fields = ['image', 'gt_bbox', 'gt_class', 'gt_score'] - for k in fields: - self.assertAllClose(orig_res[k], curr_res[k], msg=k) - - -# only for specified random seed -# class TestMixupOp(TestTransformOp): -# def setUp(self): -# self.h, self.w = np.random.randint(1024, size=2) -# self.nt = np.random.randint(50) -# self.nc = 80 - -# def test_mixup(self): -# curr_sample = [gen_sample(self.h, self.w, self.nt, self.nc) for _ in range(2)] -# orig_sample = copy.deepcopy(curr_sample[0]) -# orig_sample['mixup'] = copy.deepcopy(curr_sample[1]) -# orig_op = MixupImage(alpha=1.5, beta=1.5) -# curr_op = MixupOp(alpha=1.5, beta=1.5) -# orig_res = orig_op(orig_sample) -# curr_res = curr_op(curr_sample) -# fields = ['image', 'gt_bbox', 'gt_class', 'gt_score'] -# for k in fields: -# self.assertAllClose(orig_res[k], curr_res[k], msg=k) - -# only for specified random seed -# class TestRandomDistortOp(TestTransformOp): - -# def test_random_distort(self): -# sample = gen_sample(self.h, self.w, self.nt, self.nc) -# orig_op = ColorDistort(hsv_format=True, random_apply=False) -# curr_op = RandomDistortOp(random_apply=False) -# orig_res = orig_op(copy.deepcopy(sample)) -# curr_res = curr_op(copy.deepcopy(sample)) -# fields = ['image', 'gt_bbox', 'gt_class', 'gt_score'] -# for k in fields: -# self.assertAllClose(orig_res[k], curr_res[k], msg=k) - -# only for specified random seed -# class TestRandomExpandOp(TestTransformOp): - -# def test_random_expand(self): -# sample = gen_sample(self.h, self.w, self.nt, self.nc) -# orig_op = RandomExpand(fill_value=[123.675, 116.28, 103.53]) -# curr_op = RandomExpandOp(fill_value=[123.675, 116.28, 103.53]) -# orig_res = orig_op(copy.deepcopy(sample)) -# curr_res = curr_op(copy.deepcopy(sample)) -# fields = ['image', 'gt_bbox', 'gt_class', 'gt_score'] -# for k in fields: -# self.assertAllClose(orig_res[k], curr_res[k], msg=k) - -# only for specified random seed -# class TestRandomCropOp(TestTransformOp): - -# def test_random_crop(self): -# sample = gen_sample(self.h, self.w, self.nt, self.nc) -# orig_op = RandomCrop() -# curr_op = RandomCropOp() -# orig_res = orig_op(copy.deepcopy(sample)) -# curr_res = curr_op(copy.deepcopy(sample)) -# fields = ['image', 'gt_bbox', 'gt_class', 'gt_score'] -# for k in fields: -# self.assertAllClose(orig_res[k], curr_res[k], msg=k) - -# only for specified random seed -# class TestRandomFlipOp(TestTransformOp): - -# def test_random_flip(self): -# sample = gen_sample(self.h, self.w, self.nt, self.nc) -# orig_op = RandomFlipImage(is_normalized=False) -# curr_op = RandomFlipOp() -# orig_res = orig_op(copy.deepcopy(sample)) -# curr_res = curr_op(copy.deepcopy(sample)) -# fields = ['image', 'gt_bbox', 'gt_class', 'gt_score'] -# for k in fields: -# self.assertAllClose(orig_res[k], curr_res[k], msg=k) - -# only for specified random seed -# class TestBatchRandomResizeOp(TestTransformOp): - -# def test_batch_random_resize(self): -# sample = [gen_sample(self.h, self.w, self.nt, self.nc) for _ in range(10)] -# orig_op = RandomShape(sizes=[320, 352, 384, 416, 448, 480, 512, 544, 576, 608], random_inter=True, resize_box=True) -# curr_op = BatchRandomResizeOp(target_size=[320, 352, 384, 416, 448, 480, 512, 544, 576, 608], random_size=True, random_interp=True, keep_ratio=False) -# orig_ress = orig_op(copy.deepcopy(sample)) -# curr_ress = curr_op(copy.deepcopy(sample)) -# fields = ['image', 'gt_bbox', 'gt_class', 'gt_score'] -# for orig_res, curr_res in zip(orig_ress, curr_ress): -# for k in fields: -# self.assertAllClose(orig_res[k], curr_res[k], msg=k) - - -class TestNormalizeBoxOp(TestTransformOp): - def test_normalize_box(self): - sample = gen_sample(self.h, self.w, self.nt, self.nc) - orig_op = NormalizeBox() - curr_op = NormalizeBoxOp() - orig_res = orig_op(copy.deepcopy(sample)) - curr_res = curr_op(copy.deepcopy(sample)) - fields = ['image', 'gt_bbox', 'gt_class', 'gt_score'] - for k in fields: - self.assertAllClose(orig_res[k], curr_res[k], msg=k) - - -class TestPadBoxOp(TestTransformOp): - def test_pad_box(self): - sample = gen_sample(self.h, self.w, self.nt, self.nc) - orig_op = PadBox(num_max_boxes=50) - curr_op = PadBoxOp(num_max_boxes=50) - orig_res = orig_op(copy.deepcopy(sample)) - curr_res = curr_op(copy.deepcopy(sample)) - fields = ['image', 'gt_bbox', 'gt_class', 'gt_score'] - for k in fields: - self.assertAllClose(orig_res[k], curr_res[k], msg=k) - - -class TestBboxXYXY2XYWHOp(TestTransformOp): - def test_bbox_xyxy2xywh(self): - sample = gen_sample(self.h, self.w, self.nt, self.nc) - orig_op = BboxXYXY2XYWH() - curr_op = BboxXYXY2XYWHOp() - orig_res = orig_op(copy.deepcopy(sample)) - curr_res = curr_op(copy.deepcopy(sample)) - fields = ['image', 'gt_bbox', 'gt_class', 'gt_score'] - for k in fields: - self.assertAllClose(orig_res[k], curr_res[k], msg=k) - - -class TestNormalizeImageOp(TestTransformOp): - def test_normalize_image(self): - sample = gen_sample(self.h, self.w, self.nt, self.nc) - orig_op = NormalizeImage( - mean=[0.485, 0.456, 0.406], - std=[0.229, 0.224, 0.225], - is_scale=True, - is_channel_first=False) - curr_op = NormalizeImageOp( - mean=[0.485, 0.456, 0.406], - std=[0.229, 0.224, 0.225], - is_scale=True) - orig_res = orig_op(copy.deepcopy(sample)) - curr_res = curr_op(copy.deepcopy(sample)) - fields = ['image', 'gt_bbox', 'gt_class', 'gt_score'] - for k in fields: - self.assertAllClose(orig_res[k], curr_res[k], msg=k) - - -class TestPermuteOp(TestTransformOp): - def test_permute(self): - sample = gen_sample(self.h, self.w, self.nt, self.nc) - orig_op = Permute(to_bgr=False, channel_first=True) - curr_op = PermuteOp() - orig_res = orig_op(copy.deepcopy(sample)) - curr_res = curr_op(copy.deepcopy(sample)) - fields = ['image', 'gt_bbox', 'gt_class', 'gt_score'] - for k in fields: - self.assertAllClose(orig_res[k], curr_res[k], msg=k) - - -class TestGt2YoloTargetOp(TestTransformOp): - def test_gt2yolotarget(self): - sample = [ - gen_sample( - self.h, self.w, self.nt, self.nc, channel_first=True) - for _ in range(10) - ] - orig_op = Gt2YoloTarget( - anchor_masks=[[6, 7, 8], [3, 4, 5], [0, 1, 2]], - anchors=[[10, 13], [16, 30], [33, 23], [30, 61], [62, 45], - [59, 119], [116, 90], [156, 198], [373, 326]], - downsample_ratios=[32, 16, 8]) - curr_op = Gt2YoloTargetOp( - anchor_masks=[[6, 7, 8], [3, 4, 5], [0, 1, 2]], - anchors=[[10, 13], [16, 30], [33, 23], [30, 61], [62, 45], - [59, 119], [116, 90], [156, 198], [373, 326]], - downsample_ratios=[32, 16, 8]) - orig_ress = orig_op(copy.deepcopy(sample)) - curr_ress = curr_op(copy.deepcopy(sample)) - fields = ['image', 'gt_bbox', 'gt_class', 'gt_score'] - for orig_res, curr_res in zip(orig_ress, curr_ress): - for k in fields: - self.assertAllClose(orig_res[k], curr_res[k], msg=k) - - -if __name__ == "__main__": - unittest.main() diff --git a/ppdet/modeling/tests/test_yolov3_loss.py b/ppdet/modeling/tests/test_yolov3_loss.py index 885ae734077487f0f238c0273268391b46823ab8..8037da84d2df484d8bfb7e7646cda62c267850e7 100644 --- a/ppdet/modeling/tests/test_yolov3_loss.py +++ b/ppdet/modeling/tests/test_yolov3_loss.py @@ -29,7 +29,7 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 4))) if parent_path not in sys.path: sys.path.append(parent_path) -from ppdet.modeling.loss import YOLOv3Loss +from ppdet.modeling.losses import YOLOv3Loss from ppdet.data.transform.op_helper import jaccard_overlap import random import numpy as np diff --git a/scripts/build_wheel.sh b/scripts/build_wheel.sh new file mode 100644 index 0000000000000000000000000000000000000000..d3505869b6b0ab9771e4a43ddd33ed0d19da3e63 --- /dev/null +++ b/scripts/build_wheel.sh @@ -0,0 +1,143 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021 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. + +#================================================= +# Utils +#================================================= + + +# directory config +DIST_DIR="dist" +BUILD_DIR="build" +EGG_DIR="paddledet.egg-info" + +CFG_DIR="configs" +TEST_DIR=".tests" + +# command line log config +RED='\033[0;31m' +BLUE='\033[0;34m' +GREEN='\033[1;32m' +BOLD='\033[1m' +NONE='\033[0m' + +function python_version_check() { + PY_MAIN_VERSION=`python -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $1}'` + PY_SUB_VERSION=`python -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $2}'` + echo -e "find python version ${PY_MAIN_VERSION}.${PY_SUB_VERSION}" + if [ $PY_MAIN_VERSION -ne "3" -o $PY_SUB_VERSION -lt "5" ]; then + echo -e "${RED}FAIL:${NONE} please use Python >= 3.5 !" + exit 1 + fi +} + +function init() { + echo -e "${BLUE}[init]${NONE} removing building directory..." + rm -rf $DIST_DIR $BUILD_DIR $EGG_DIR $TEST_DIR + if [ `pip list | grep paddledet | wc -l` -gt 0 ]; then + echo -e "${BLUE}[init]${NONE} uninstalling paddledet..." + pip uninstall -y paddledet + fi + echo -e "${BLUE}[init]${NONE} ${GREEN}init success\n" +} + +function build_and_install() { + echo -e "${BLUE}[build]${NONE} building paddledet wheel..." + python setup.py sdist bdist_wheel + if [ $? -ne 0 ]; then + echo -e "${RED}[FAIL]${NONE} build paddledet wheel failed !" + exit 1 + fi + echo -e "${BLUE}[build]${NONE} ${GREEN}build paddldet wheel success\n" + + echo -e "${BLUE}[install]${NONE} installing paddledet..." + cd $DIST_DIR + find . -name "paddledet*.whl" | xargs pip install + if [ $? -ne 0 ]; then + cd .. + echo -e "${RED}[FAIL]${NONE} install paddledet wheel failed !" + exit 1 + fi + echo -e "${BLUE}[install]${NONE} ${GREEN}paddledet install success\n" + cd .. +} + +function unittest() { + if [ -d $TEST_DIR ]; then + rm -rf $TEST_DIR + fi; + + echo -e "${BLUE}[unittest]${NONE} run unittests..." + + # NOTE: perform unittests under TEST_DIR to + # make sure installed paddledet is used + mkdir $TEST_DIR + cp -r $CFG_DIR $TEST_DIR + cd $TEST_DIR + + if [ $? != 0 ]; then + exit 1 + fi + find "../ppdet" -name 'tests' -type d -print0 | \ + xargs -0 -I{} -n1 bash -c \ + 'python -m unittest discover -v -s {}' + + # clean TEST_DIR + cd .. + rm -rf $TEST_DIR + echo -e "${BLUE}[unittest]${NONE} ${GREEN}unittests success\n${NONE}" +} + +function cleanup() { + if [ -d $TEST_DIR ]; then + rm -rf $TEST_DIR + fi + + rm -rf $BUILD_DIR $EGG_DIR + pip uninstall -y paddledet +} + +function abort() { + echo -e "${RED}[FAIL]${NONE} build wheel and unittest failed ! + please check your code" 1>&2 + + cur_dir=`basename "$pwd"` + if [ cur_dir==$TEST_DIR -o cur_dir==$DIST_DIR ]; then + cd .. + fi + + rm -rf $BUILD_DIR $EGG_DIR $DIST_DIR $TEST_DIR + pip uninstall -y paddledet +} + +python_version_check + +trap 'abort' 0 +set -e + +init +build_and_install +unittest +cleanup + +PADDLE_VERSION=`python -c "import paddle; print(paddle.version.full_version)"` +PADDLE_COMMIT=`python -c "import paddle; print(paddle.version.commit)"` +echo -e "\n${GREEN}paddledet wheel compiled and checked success !${NONE} + ${BLUE}paddle version:${NONE} $PADDLE_VERSION + ${BLUE}paddle commit:${NONE} $PADDLE_COMMIT\n" +echo -e "${GREEN}wheel saved under${NONE} ${RED}${BOLD}./dist" + +trap : 0 diff --git a/setup.py b/setup.py index 939afe85bfc392cdbaaf8b4ac86dc4333e150b50..179983fa56d8d7ef443685bcd3bd4458623ab221 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,6 @@ import os.path as osp import glob import shutil from setuptools import find_packages, setup -from paddle.utils import cpp_extension def readme():