Exemplo n.º 1
0
def get_model():
    print('[+] loading model... ', end='', flush=True)
    model = models.densenet201_finetune(num_classes=NB_CLASSES, drop_rate=0.20)
    if use_gpu:
        model.cuda()
    print('done')
    return model
def get_model():
    print('[+] loading model... ', end='', flush=True)
    model = models.densenet201_finetune(NB_CLASSES)
    if use_gpu:
        model.cuda()
    print('done')
    return model
Exemplo n.º 3
0
def get_model(name):
    print('[+] loading model... ', end='', flush=True)
    if name == 'densenet201':
        model = models.densenet201_finetune(NB_CLASSES)
    elif name == 'inceptionresnetv2':
        model = models.inceptionresnetv2_finetune(NB_CLASSES)
    if name == 'senet154':
        model = models.senet154_finetune(NB_CLASSES)
    if name == 'nasnetlarge':
        model = models.nasnetlarge_finetune(NB_CLASSES)
    if name == 'inceptionv4':
        model = models.inceptionv4_finetune(NB_CLASSES)
    if name == 'se_resnext101_32x4d':
        model = models.se_resnext101_32x4d_finetune(NB_CLASSES)

    if use_gpu:
        model.cuda()
    print('done')
    return model
def get_model(model_name):
    print('Loading model: %s' % (model_name))
    if model_name.startswith("densenet"):
        model = models.densenet201_finetune(NB_CLASSES)
    elif model_name.startswith("squeezenet"):
        model = models.squeezenet11_finetune(NB_CLASSES)
    elif model_name.startswith("resnet"):
        model = models.resnet152_finetune(NB_CLASSES)
    else:
        print("Error: Model not found!")
        exit(-1)

    # Multi-GPU scaling
    if torch.cuda.device_count() > 1:
        print("Parallelizing model over %d GPUs!" % (torch.cuda.device_count()))
        model = nn.DataParallel(model)
    model.to(device)

    print('Model loaded successfully!')
    return model