Esempio n. 1
0
def run(FLAGS, cfg):
    # build trainer
    trainer = Trainer(cfg, mode='test')

    # load weights
    trainer.load_weights(cfg.weights, 'resume')

    # get inference images
    images = get_test_images(FLAGS.infer_dir, FLAGS.infer_img)

    # inference
    trainer.predict(images,
                    draw_threshold=FLAGS.draw_threshold,
                    output_dir=FLAGS.output_dir)
Esempio n. 2
0
    def test_infer_mstest(self):
        cfg = load_config(self.mstest_cfg_file)
        trainer = Trainer(cfg, mode='test')

        cfg.weights = 'https://paddledet.bj.bcebos.com/models/faster_rcnn_r34_fpn_1x_coco.pdparams'
        trainer.load_weights(cfg.weights)
        tests_img_root = os.path.join(os.path.dirname(__file__), 'imgs')

        # input images to predict
        imgs = ['coco2017_val2017_000000000139.jpg', 'coco2017_val2017_000000000724.jpg']
        imgs = [os.path.join(tests_img_root, img) for img in imgs]
        trainer.predict(imgs,
                        draw_threshold=0.5,
                        output_dir='output',
                        save_txt=True)