Exemple #1
0
def main(args):
    # Combine the default config with
    # the external config file and the set command
    if args.cfg is not None:
        cfg_from_file(args.cfg)
    if args.set_cfgs is not None:
        cfg_from_list(args.set_cfgs)
    cfg.DEBUG = args.debug
    cfg.GPU_ID = args.gpu_id
    cfg_print(cfg)

    # Loading the network
    caffe.set_mode_gpu()
    caffe.set_device(args.gpu_id)
    net = caffe.Net(args.prototxt, args.model, caffe.TEST)

    # Create the imdb
    imdb = get_imdb(args.db_name)

    # Set the network name
    net.name = args.net_name

    # Evaluate the network
    test_net(net,
             imdb,
             visualize=args.visualize,
             no_cache=args.no_cache,
             output_path=args.out_path)
Exemple #2
0
    def __init__(self):
        cfg_from_file('SSH/configs/wider.yml')
        cfg.GPU_ID = 0

        # Loading the network
        caffe.set_mode_gpu()
        caffe.set_device(0)
        self.net = caffe.Net('SSH/models/test_ssh.prototxt', 'SSH-FL-OHEM-ver2_iter_40000.caffemodel', caffe.TEST)
        self.net.name = 'SSH'
Exemple #3
0
def SSH_init():
    import caffe
    from utils.get_config import cfg, cfg_print, cfg_from_file

    cfg_from_file('./lib/SSH/SSH/configs/wider_pyramid.yml')
    cfg_print(cfg)

    caffe.set_mode_gpu()
    caffe.set_device(0)

    # loading network
    net = caffe.Net('./lib/SSH/SSH/models/test_ssh.prototxt',
                    './lib/SSH/data/SSH_models/SSH.caffemodel', caffe.TEST)
    net.name = 'SSH'

    return net
def main(args):
    # Combine the default config with
    # the external config file and the set command
    if args.cfg is not None:
        cfg_from_file(args.cfg)
    if args.set_cfgs is not None:
        cfg_from_list(args.set_cfgs)
    cfg.DEBUG = args.debug
    cfg.GPU_ID = args.gpu_id
    cfg_print(cfg)

    # Loading the network
    caffe.set_mode_gpu()
    caffe.set_device(args.gpu_id)
    net = caffe.Net(args.prototxt, args.model, caffe.TEST)

    # Create the imdb
    imdb = get_imdb(args.db_name)

    # Set the network name
    net.name = args.net_name

    # Evaluate the network
    test_net(net, imdb, visualize=args.visualize, no_cache=args.no_cache, output_path=args.out_path)
Exemple #5
0
            if showFullScreen == True:
                cv2.setWindowProperty(windowName, cv2.WND_PROP_FULLSCREEN,
                                      cv2.WINDOW_FULLSCREEN)
            else:
                cv2.setWindowProperty(windowName, cv2.WND_PROP_FULLSCREEN,
                                      cv2.WINDOW_NORMAL)


if __name__ == "__main__":

    # Parse arguments
    args = parser()

    # Load the external config
    if args.cfg is not None:
        cfg_from_file(args.cfg)
    # Print config file
    cfg_print(cfg)

    # Loading the network
    cfg.GPU_ID = args.gpu_id
    caffe.set_mode_gpu()
    caffe.set_device(args.gpu_id)
    assert os.path.isfile(
        args.prototxt), 'Please provide a valid path for the prototxt!'
    assert os.path.isfile(
        args.model), 'Please provide a valid path for the caffemodel!'

    print('Loading the network...', end="")
    net = caffe.Net(args.prototxt, args.model, caffe.TEST)
    net.name = 'SSH'
    parser.add_argument('--model',dest='model',help='SSH trained caffemodel',
                        default='data/SSH_models/SSH.caffemodel',type=str)
    parser.add_argument('--out_path',dest='out_path',help='Output path for saving the figure',
                        default='data/demo',type=str)
    parser.add_argument('--cfg',dest='cfg',help='Config file to overwrite the default configs',
                        default='SSH/configs/default_config.yml',type=str)
    return parser.parse_args()

if __name__ == "__main__":

    # Parse arguments
    args = parser()

    # Load the external config
    if args.cfg is not None:
        cfg_from_file(args.cfg)
    # Print config file
    cfg_print(cfg)

    # Loading the network
    cfg.GPU_ID = args.gpu_id
    caffe.set_mode_gpu()
    caffe.set_device(args.gpu_id)
    assert os.path.isfile(args.prototxt),'Please provide a valid path for the prototxt!'
    assert os.path.isfile(args.model),'Please provide a valid path for the caffemodel!'

    print('Loading the network...', end="")
    net = caffe.Net(args.prototxt, args.model, caffe.TEST)
    net.name = 'SSH'
    print('Done!')
Exemple #7
0
                        help='provide configure file',
                        default='configs/default.toml')
    parser.add_argument('--amend',
                        dest='set_cfgs',
                        help='provide amend cfgs',
                        default=None,
                        nargs=argparse.REMAINDER)
    return parser.parse_args()


if __name__ == '__main__':
    args = parser()

    # Load settings
    if args.conf_file:
        cfg_from_file(args.conf_file)

    # For train and test, usually we do not need cache; unless overridden by amend
    cfg.TEST.NO_CACHE = True
    if args.set_cfgs:
        cfg_from_list(args.set_cfgs)

    # Record logs into cfg
    cfg.LOG.CMD = ' '.join(sys.argv)
    cfg.LOG.TIME = datetime.datetime.now().strftime('%Y_%m_%d_%H_%M_%S')
    np.random.seed(int(cfg.RNG_SEED))

    if cfg.TENSORBOARD.ENABLE:
        tb.client = Tensorboard(hostname=cfg.TENSORBOARD.HOSTNAME,
                                port=cfg.TENSORBOARD.PORT)
        tb.sess = tb.client.create_experiment(cfg.NAME + '_' + cfg.LOG.TIME)
    parser.add_argument('--file_result', type=str, help='result of detection')
    parser.add_argument('--output_dir',
                        dest='output_dir',
                        help='Output path for saving the pictures',
                        default='data/output_dir',
                        type=str)

    return parser.parse_args(argv)


if __name__ == '__main__':

    args = parse_args(sys.argv[1:])

    cfg_file = 'SSH/configs/wider.yml'
    cfg_from_file(cfg_file)
    # Print config file
    cfg_print(cfg)

    # prototxt = 'SSH/models/test_ssh_resnet50_bn.prototxt'
    # caffemodel = 'data/SSH_models/SSH_resnet50_iter_84000.caffemodel'

    prototxt = 'SSH/models/test_ssh_pvanet.prototxt'
    caffemodel = 'data/SSH_models/SSH_pvanet_iter_84000.caffemodel'

    if not os.path.isfile(caffemodel):
        raise IOError(('{:s} not found.\nDid you run ./data/script/'
                       'fetch_faster_rcnn_models.sh?').format(caffemodel))

    image_dir = args.image_dir
    file_list = args.file_list
import cv2
import numpy as np

from SSH.test import detect_cv2, detect
from utils.get_config import cfg_from_file, cfg, cfg_print
import caffe
import os

cfg_from_file('SSH/configs/wider.yml')
cfg.GPU_ID = 0

caffe.set_mode_gpu()
caffe.set_device(0)
net = caffe.Net('SSH/models/test_ssh.prototxt',
                'SSH-FL-OHEM-ver2_iter_40000.caffemodel', caffe.TEST)
net.name = 'SSH'

in_path = 'gender/img_align_celeba/train/male'
out_path = 'gender/datas/train/male'

c = 0
N = len(os.listdir(in_path))
for fn in os.listdir(in_path):
    c = c + 1
    if c % 1000 == 0:
        print "{}/{}".format(c, N)
    image = cv2.imread(os.path.join(in_path, fn))
    boxes = detect_cv2(net, image)

    inds = np.where(boxes[:, -1] >= 0.5)[0]
    boxes = boxes[inds]