Example #1
0
if __name__ == '__main__':
    import utils
    from models import networks
    from Images import data_preprocess

    from torch.backends import cudnn
    torch.backends.cudnn.benchmark = True

    # get dataloader
    amazon_path = os.path.join(params.imgs_root_path, r'amazon\images')
    dslr_path = os.path.join(params.imgs_root_path, r'dslr\images')
    webcam_path = os.path.join(params.imgs_root_path, r'webcam\images')
    caltech_path = os.path.join(params.imgs_root_path, r'Clatech\clatech')

    # 不使用target domain
    amazon_dataloader = data_preprocess.get_dataloader(amazon_path,
                                                       params.images_name)
    # dslr_dataloader = data_preprocess.get_dataloader(dslr_path, params.images_name)
    caltech_dataloader = data_preprocess.get_dataloader(
        caltech_path, params.images_name)

    # 目标域带标签的
    # amazon_dataloader, dslr_dataloader = data_preprocess.get_src_tgt_dataloader(amazon_path, dslr_path, params.images_name)
    # 数据均衡后的dataloader
    # amazon_dataloader, dslr_dataloader = data_preprocess.data_balance_dataloader(amazon_path, dslr_path, params.images_name)

    # 初始化网络
    classifier = networks.Classifier(3 * params.imgs_size * params.imgs_size,
                                     len(params.images_name)).cuda()
    discriminator = networks.LargeDiscriminator(3 * params.imgs_size *
                                                params.imgs_size).cuda()
if __name__ == '__main__':
    from models import networks
    from Images import data_preprocess

    from torch.backends import cudnn

    torch.backends.cudnn.benchmark = True

    # get dataloader
    amazon_path = os.path.join(params.imgs_root_path, r'amazon\images')
    dslr_path = os.path.join(params.imgs_root_path, r'dslr\images')
    webcam_path = os.path.join(params.imgs_root_path, r'webcam\images')
    caltech_path = os.path.join(params.imgs_root_path, r'Clatech\clatech')

    # 不使用target domain
    amazon_dataloader = data_preprocess.get_dataloader(amazon_path,
                                                       params.images_name)
    dslr_dataloader = data_preprocess.get_dataloader(dslr_path,
                                                     params.images_name)
    webcam_dataloader = data_preprocess.get_dataloader(webcam_path,
                                                       params.images_name)
    caltech_dataloader = data_preprocess.get_dataloader(
        caltech_path, params.images_name)
    # 目标域带标签的
    # amazon_dataloader, dslr_dataloader = data_preprocess.get_src_tgt_dataloader(amazon_path, dslr_path, params.images_name)

    # 初始化网络
    classifier = networks.Classifier(3 * params.imgs_size * params.imgs_size,
                                     len(params.images_name)).cuda()
    discriminator = networks.LargeDiscriminator(3 * params.imgs_size *
                                                params.imgs_size).cuda()
Example #3
0
    torch.save(classifier.state_dict(), '../pth/classifier_src.pth')


if __name__ == '__main__':
    import utils
    from models import networks
    from Images import data_preprocess

    from torch.backends import cudnn
    torch.backends.cudnn.benchmark = True

    # get dataloader
    amazon_path = os.path.join(params.imgs_root_path, r'amazon\images')
    dslr_path = os.path.join(params.imgs_root_path, r'dslr\images')
    # 不使用target domain
    amazon_dataloader = data_preprocess.get_dataloader(amazon_path,
                                                       params.images_name)
    dslr_dataloader = data_preprocess.get_dataloader(dslr_path,
                                                     params.images_name)
    # 目标域带标签的
    # amazon_dataloader, dslr_dataloader = data_preprocess.get_src_tgt_dataloader(amazon_path, dslr_path, params.images_name)

    # 初始化网络
    classifier = networks.Classifier(3 * params.imgs_size * params.imgs_size,
                                     len(params.images_name)).cuda()
    discriminator = networks.LargeDiscriminator(3 * params.imgs_size *
                                                params.imgs_size).cuda()

    # if os.path.exists('../pth/classifier_src.pth'):
    #     classifier.load_state_dict(torch.load('../pth/classifier_src.pth'))
    # else:
    #     train_classifier(classifier, dslr_dataloader)