Beispiel #1
0
def run_differ_C(args):
    algorithm_list = ['ABPR', 'ABPR_10', 'ABPR_d', 'ABPR_sqrt']

    config_dict = {
        name: Config(os.path.join(relative_path_root, 'config',
                                  name + '.conf'))
        for name in algorithm_list
    }

    conf_path = os.path.join(relative_path_root, 'config',
                             'account_{}.conf'.format(args.dataset))
    print('Account configuration path: {}'.format(conf_path))

    conf_account = Config(conf_path)
    conf_account['output.setup'] = os.path.join(
        os.path.dirname(os.path.dirname(conf_account['output.setup'])),
        'varies_C/')

    account_data = AccountDAO(conf_account)

    for name, config in config_dict.items():
        if name.startswith('ABPR'):
            config.update_inferior(conf_account)
        else:
            config.update(conf_account)

    for C in range(1, 11):
        recSys_all = RecQMultiAlgo(config_dict,
                                   conf_account,
                                   account_data,
                                   C=C)
        # args.debug = True
        recSys_all.execute_all(debug=args.debug)
Beispiel #2
0
 def __init__(self, conf):
     self.config = Config(conf)
     self.userProfile = FileIO.loadDataSet(self.config,
                                           self.config['ratings'])
     self.itemProfile = defaultdict(dict)
     self.attackSize = float(self.config['attackSize'])
     self.fillerSize = float(self.config['fillerSize'])
     self.selectedSize = float(self.config['selectedSize'])
     self.targetCount = int(self.config['targetCount'])
     self.targetScore = float(self.config['targetScore'])
     self.threshold = float(self.config['threshold'])
     self.minCount = int(self.config['minCount'])
     self.maxCount = int(self.config['maxCount'])
     self.outputDir = self.config['outputDir']
     if not os.path.exists(self.outputDir):
         os.makedirs(self.outputDir)
     for user in self.userProfile:
         for item in self.userProfile[user]:
             self.itemProfile[item][user] = self.userProfile[user][item]
     self.spamProfile = defaultdict(dict)
     self.spamItem = defaultdict(list)  #items rated by spammers
     self.targetItems = []
     self.itemAverage = {}
     self.getAverageRating()
     self.selectTarget()
Beispiel #3
0
def run_differ_N(args):
    algorithm_list = ['ABPR', 'ABPR_10', 'ABPR_d', 'ABPR_sqrt', 'ABPR_t1']

    config_dict = {
        name: Config(os.path.join(relative_path_root, 'config',
                                  name + '.conf'))
        for name in algorithm_list
    }

    conf_path = os.path.join(relative_path_root, 'config',
                             'account_{}.conf'.format(args.dataset))
    print('Account configuration path: {}'.format(conf_path))

    conf_account = Config(conf_path)

    dirs = walk_dir('../account_data/lastfm-dataset-1K/differ_N')
    conf_account['account.data'] = os.path.join(
        os.path.dirname(conf_account['account.data']), 'differ_N/',
        os.path.basename(conf_account['account.data']))
    conf_account['output.setup'] = os.path.join(
        os.path.dirname(os.path.dirname(conf_account['output.setup'])),
        'varies_N/')

    if args.dataset == 'movie':
        conf_account['account.algorithm'] = 'PDAN'

    for dir in dirs:
        print("dir is {}".format(dir))
        conf_account['account.data'] = os.path.join(
            os.path.dirname(conf_account['account.data']), dir)
        # conf_account['output.setup'] = os.path.join(conf_account['output.setup'], dir)

        account_data = AccountDAO(conf_account)

        for name, config in config_dict.items():
            if name.startswith('ABPR'):
                config.update_inferior(conf_account)
            else:
                config.update(conf_account)

        recSys_all = RecQMultiAlgo(config_dict,
                                   conf_account,
                                   account_data,
                                   N=int(dir[1:]))

        args.debug = True
        recSys_all.execute_all(debug=args.debug)
Beispiel #4
0
    def recommend(self, i, id, location, num):
        print(id + "\t" + num + "\t" + i + '\t' +
              urllib.unquote(location).decode('utf-8'))
        location = urllib.unquote(location).decode('utf-8')
        conf = Config('../config/UserKNN.conf')
        if num is None or num < 3:
            num = 3
        if int(i) == 1:
            sysRec = RecQ(conf)
            sysRec.execute()

        model_f = open(conf['model.file'])
        lr = []
        for line in model_f:
            l = line.split(' ')
            if str(l[0]) == str(id):
                lr.append(line)
                print("l:{}".format(l))
        l = []
        for r in lr:
            rs = str(r).split(' ')
            if len(l) < int(num):
                l.append(rs[1])
                print("r :{}".format(rs[1]))

        s = []
        lt = []
        with open(conf['stock.file']) as f:
            for ind, line in enumerate(f):
                if line.strip() <> '':
                    li = line.split("\t")
                    x = li[0]
                    e = li[1]
                    loc = li[2]
                    if len(l) == 0:
                        s.append(str(x))
                    else:
                        b_append = False
                        for k in l:
                            if e == k:
                                lt.append(str(x))
                            elif location == loc.decode('utf-8'):
                                b_append = True
                        if b_append:
                            s.append(str(x))
        le = len(s)
        print(le)
        if le > (int(num) - len(l)):
            ret = random.sample(s, int(num) - len(l))
            for r in ret:
                lt.append(r)
        else:
            for r in s:
                lt.append(r)
        return {"list": [lt], "code": 200}
Beispiel #5
0
def run_differ_L(args):
    # algorithm_list = ['ABPR', 'ABPR_10', 'ABPR_d', 'ABPR_sqrt', 'ABPR_t1', 'BPR', 'WRMF', 'ExpoMF', 'CoFactor',
    #                   'NeuMF', 'APR', 'CDAE', 'CFGAN']
    # algorithm_list = ['NeuMF', 'APR', 'CDAE', 'CFGAN']
    algorithm_list = ['ABPR', 'ABPR_10', 'ABPR_d', 'ABPR_sqrt', 'ABPR_t1']

    config_dict = {
        name: Config(os.path.join(relative_path_root, 'config',
                                  name + '.conf'))
        for name in algorithm_list
    }

    conf_path = os.path.join(relative_path_root, 'config',
                             'account_{}.conf'.format(args.dataset))
    print('Account configuration path: {}'.format(conf_path))

    conf_account = Config(conf_path)
    conf_account['output.setup'] = os.path.join(
        os.path.dirname(os.path.dirname(conf_account['output.setup'])),
        'varies_L/')

    account_data = AccountDAO(conf_account)

    for name, config in config_dict.items():
        if name.startswith('ABPR'):
            config.update_inferior(conf_account)
        else:
            config.update(conf_account)

    for L in range(0, 10):
        recSys_all = RecQMultiAlgo(config_dict,
                                   conf_account,
                                   account_data,
                                   L=L)
        # args.debug = True
        recSys_all.execute_all(debug=args.debug)
Beispiel #6
0
    print 'Baselines:'
    print 'b1. UserMean      b2. ItemMean      b3. MostPopular   b4. Rand'
    print '=' * 80
    algor = -1
    conf = -1
    order = raw_input('please enter the num of the algorithm to run it:')
    import time
    s = time.time()
    if order == '0':
        try:
            import seaborn as sns
        except ImportError:
            print '!!!To obtain nice data charts, ' \
                  'we strongly recommend you to install the third-party package <seaborn>!!!'
        conf = Config('../config/visual/visual.conf')
        Display(conf).render()
        exit(0)
    elif order == '1':
        conf = Config('../config/UserKNN.conf')

    elif order == '2':
        conf = Config('../config/ItemKNN.conf')

    elif order == '3':
        conf = Config('../config/BasicMF.conf')

    elif order == '4':
        conf = Config('../config/SlopeOne.conf')

    elif order == '5':
        116.280,
        103.530,
    ]
    path = '../data_preprocess/'
    Bboxes = [path + 'Bboxes_07.pkl', path + 'Bboxes_12.pkl']
    img_paths = [path + 'img_paths_07.pkl', path + 'img_paths_12.pkl']

    files = [img_paths, Bboxes]
    config = Config(True,
                    Mean,
                    files,
                    lr=0.001,
                    weight_decay=0.0005,
                    batch_size_per_GPU=1,
                    img_max=1000,
                    img_min=600,
                    roi_min_size=16,
                    roi_train_pre_nms=12000,
                    roi_train_post_nms=2000,
                    roi_test_pre_nms=6000,
                    roi_test_post_nms=300,
                    bias_lr_factor=2,
                    multi_scale_train=False)

    step = 0
    model = Faster_Rcnn
    x = 1
    pre_model_file = r'D:/BaiduNetdiskDownload/vgg16_cf.pth'
    pre_model_file = '/home/zhai/PycharmProjects/Demo35/py_Faster_tool/pre_model/vgg16_cf.pth'
    model_file = r''
    train(model, config, step, x, pre_model_file, model_file=model_file)
Beispiel #8
0
    print 'Advanced Recommenders:'
    print 'a1. MEM'



    print 'Baselines:'
    print 'b1. MostPop   b2. Rand'
    print '='*80
    algor = -1
    conf = -1
    order = raw_input('Please enter the num of the algorithm to run it:')
    import time
    s = time.time()
    if order=='1':
        conf = Config('./config/BPR.conf')

    elif order=='2':
        conf = Config('./config/FISM.conf')

    elif order == 'b1':
        conf = Config('./config/MostPop.conf')

    elif order == 'b2':
        conf = Config('./config/rand.conf')

    elif order == 'a1':
        conf = Config('./config/MEM.conf')

    else:
        print 'Error num!'
Beispiel #9
0
    algor = -1
    conf = -1
    order = input('please enter the num of the method to run it:')
    import time
    s = time.time()
    # if order == 0:
    #     try:
    #         import seaborn as sns
    #     except ImportError:
    #         print '!!!To obtain nice data charts, ' \
    #               'we strongly recommend you to install the third-party package <seaborn>!!!'
    #     conf = Config('../config/visual/visual.conf')
    #     Display(conf).render()
    #     exit(0)
    if order == 1:
        conf = Config('../config/DegreeSAD.conf')

    elif order == 2:
        conf = Config('../config/CoDetector.conf')

    elif order == 3:
        conf = Config('../config/SemiSAD.conf')

    elif order == 4:
        conf = Config('../config/PCASelectUsers.conf')

    elif order == 5:
        conf = Config('../config/FAP.conf')

    else:
        print 'Error num!'
        with tf.Session(config=config) as sess:
            self.init(sess, self.Name, tf.global_variables(), W)
            constant_graph = graph_util.convert_variables_to_constants(
                sess, sess.graph_def, self.out)
            with tf.gfile.FastGFile('./models/YOLOv3_tiny_3l_20_run_model.pb',
                                    mode='wb') as f:
                f.write(constant_graph.SerializeToString())
        print('finish')


if __name__ == "__main__":
    files = None
    cfg_file = r'D:\PycharmProjects\daknet_demo\train\brand_20_classes_train\cfg\yolov3-tiny_3l_brand_20.cfg'
    weights_file = r'D:\PycharmProjects\daknet_demo\train\brand_20_classes_train\backup\yolov3-tiny_3l_brand_20_25000.weights'

    config = Config(files,
                    cfg_file,
                    weights_file,
                    num_cls=20,
                    img_size=(416, 416),
                    ignore_thresh=0.5,
                    stride=[32, 16, 8],
                    equal_scale=False)

    yolov3 = YOLOv3(config)
    # yolov3.test()
    # yolov3.test_coco()
    # yolov3.test_tiny()
    # yolov3.test_vedio()
    yolov3.save_pb()
Beispiel #11
0
    print '0. Analyze the input data.(Configure the visual.conf in config/visual first.)'
    print '1. UserKNN   2. ItemKNN   3. BasicMF   4. SlopeOne   5. RSTE   6. UserMean'
    print '7. ItemMean   8. SVD   9. PMF   10. TrustMF   11. SocialMF   12. SoRec   13.SoReg   14.SVD++'
    algor = -1
    conf = -1
    print '-' * 80
    order = input('please enter the num of the algorithm to run it:')
    import time
    s = time.clock()
    if order == 0:
        try:
            import seaborn as sns
        except ImportError:
            print '!!!To obtain nice data charts, ' \
                  'we strongly recommend you to install the third-party package <seaborn>!!!'
        conf = Config('../config/visual/visual.conf')
        Display(conf).render()
        exit(0)
    elif order == 1:
        conf = Config('../config/UserKNN.conf')

    elif order == 2:
        conf = Config('../config/ItemKNN.conf')

    elif order == 3:
        conf = Config('../config/BasicMF.conf')

    elif order == 4:
        conf = Config('../config/SlopeOne.conf')

    elif order == 5:
Beispiel #12
0
    print('Baselines:')
    print('b1. UserMean      b2. ItemMean      b3. MostPopular   b4. Rand')

    print('=' * 80)
    algor = -1
    conf = -1
    order = input('please enter the num of the algorithm to run it:')
    import time
    s = time.time()
    if order == '0':
        try:
            import seaborn as sns
        except ImportError:
            print('!!!To obtain nice data charts, ' \
                  'we strongly recommend you to install the third-party package <seaborn>!!!')
        conf = Config('../config/visual/visual.conf')
        Display(conf).render()
        exit(0)

    algorthms = {
        '1': 'UserKNN',
        '2': 'ItemKNN',
        '3': 'BasicMF',
        '4': 'SlopeOne',
        '5': 'SVD',
        '6': 'PMF',
        '7': 'SVD++',
        '8': 'EE',
        '9': 'BPR',
        '10': 'WRMF',
        '11': 'ExpoMF',
Beispiel #13
0
                              0: 'batch'
                          },
                          'out2': {
                              0: 'batch'
                          }
                      })


if __name__ == "__main__":
    font = cv2.FONT_HERSHEY_SIMPLEX
    files = None

    cfg_file = r'yolo-fastest-1.1_body/yolo-fastest-1.1_body.cfg'
    weights_file = r'yolo-fastest-1.1_body/yolo-fastest-1.1_body.weights'

    config = Config(files, cfg_file, weights_file, equal_scale=False)

    model = YOLOv3(config)
    print(model)
    model.eval()
    # model.eval()
    model_static = model.state_dict()
    print(len(model_static))
    vars_shapes = []
    keys = []
    for key in model_static.keys():
        if 'num_batches_tracked' in key:
            continue
        v = model_static[key]
        vars_shapes.append(v.shape)
        keys.append(key)
    Mean = [123.68, 116.78, 103.94]
    Mean = [
        123.675,
        116.280,
        103.530,
    ]
    config = Config(
        False,
        Mean,
        None,
        lr=0.00125,
        weight_decay=0.0001,
        num_cls=80,
        img_max=1333,
        img_min=800,
        anchor_scales=[[32], [64], [128], [256], [512]],
        anchor_ratios=[[0.5, 1, 2], [0.5, 1, 2], [0.5, 1, 2], [0.5, 1, 2],
                       [0.5, 1, 2]],
        fast_n_sample=512,
        roi_min_size=[1, 1, 1, 1, 1],
        roi_train_pre_nms=12000,
        roi_train_post_nms=2000,
        roi_test_pre_nms=6000,
        roi_test_post_nms=1000,
    )
    model = Mask_Rcnn
    model_file = '../train_one_GPU/models/Mask_Rcnn_cascade_50_90000_1.pth'

    test(model, config, model_file)

#  Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.254
Beispiel #15
0
                                   + '\t' + gender + '\t' + action
                except:
                    print("error:" + str(line))

    @staticmethod
    def read_mapper_output(file, separator='\t'):
        for line in file:
            l = line.rstrip().split(separator)
            if len(l) > 5:
                user = l[0]
                item = l[1]
                weight = l[6]
                yield (user + "|" + item, weight)

    def reduce(self):
        rate_f = file(self.config['ratings'], 'w')
        data = self.read_mapper_output(open(self.config['process.log.file']))
        for user, group in groupby(data, itemgetter(0)):
            total_count = sum(int(count) for item, count in group)
            # print("%s%s%d" % (user, '\t', total_count))
            u = user.split('|')
            print >> rate_f, u[1], u[0], total_count


if __name__ == '__main__':
    # clean()
    # reduce()
    config = Config('../config/UserKNN.conf')
    p = process(config)
    p.clean()
    print('==========', datetime.now() - start_time)
    joblib.dump(Res, 'Faster_vgg16_1.pkl')
    GT = joblib.load('../mAP/voc_GT.pkl')
    AP = mAP(Res, GT, 20, iou_thresh=0.5, use_07_metric=True, e=0.05)
    print(AP)
    AP = AP.mean()
    print(AP)


if __name__ == "__main__":
    Mean = [123.68, 116.78, 103.94]
    Mean = [
        123.675,
        116.280,
        103.530,
    ]
    model = Faster_Rcnn
    config = Config(False,
                    Mean,
                    None,
                    img_max=1000,
                    img_min=600,
                    roi_min_size=16)
    model_file = '../train_one_GPU/models/vgg16_90000_2.pth'
    test(model, config, model_file)

# [0.73909475 0.78086676 0.7028246  0.60206878 0.61172184 0.82720654
#  0.83681608 0.85766458 0.55384811 0.77337219 0.63840307 0.83138268
#  0.84698006 0.76642416 0.7870849  0.44357723 0.75472496 0.67486161
#  0.81124731 0.74521005]
# 0.7292690138425238
    cv2.imshow('a', im)
    cv2.waitKey(2000)
    return im


if __name__ == "__main__":
    from datetime import datetime
    from tool.config import Config

    Mean = [123.68, 116.78, 103.94]
    path = '/home/zhai/PycharmProjects/Demo35/pytorch_Faster_tool/data_preprocess/'
    Bboxes = [path + 'coco_bboxes_2017.pkl']
    img_paths = [path + 'coco_imgpaths_2017']
    masks = [path + 'coco_mask_2017.pkl']
    files = [img_paths, Bboxes, masks]
    config = Config(True, Mean, files, lr=0.00125, img_max=1000, img_min=600)
    dataset = Read_Data(config)

    dataloader = DataLoader(dataset, batch_size=1, num_workers=16, collate_fn=lambda x: x)
    dataloader = DataLoader(dataset, batch_size=2, collate_fn=func,
                            shuffle=True, drop_last=True, pin_memory=False, num_workers=1)
    c = 0
    for i in range(2):
        for imgs, bboxes, num_b, num_H, num_W, masks in dataloader:
            # imgs, bboxes, num_b, num_H, num_W, masks = x
            c += 1
            print(datetime.now(), c, masks.shape, imgs.shape)
            # print(img.shape, bboxes.shape, masks.shape)
            for j in range(imgs.shape[0]):
                x = imgs[j]
                H = num_H[j]
Beispiel #18
0
import sys
sys.path.append("..")
from tool.config import Config
from tool.file import FileIO
from algorithm.SoReg import SoReg

if __name__ == '__main__':

    print'='*80
    print'this is the algorithm of the test'
    algor = -1
    conf = -1
    conf = Config('../conf/SoReg.conf')
    trainset = []
    testset = []
    relation = []
    ui={}
    vj={}
    user_item_avg={}
    trainset = FileIO.loadDataSet(conf,conf['ratings'],bTest=False)
    testset =   FileIO.loadDataSet(conf,conf['testset'],bTest=True)
    relation = FileIO.loadRelationship(conf,conf['social'])
    ui,vj,user_item_avg=SoReg.buildmodel(trainset,relation)
    SoReg.pred(testset,ui,vj,user_item_avg)
#sotre the data
Beispiel #19
0
    print 'Hybrid Recommenders:\n'

    print 'Advanced Recommenders:'
    print 'a1. MEM   a2. SocialMR   a3. HME   a4. CUNE'
    print 'a5. Song2vec'

    print 'Baselines:'
    print 'b1. MostPop   b2. Rand'
    print '=' * 80
    algor = -1
    conf = -1
    order = raw_input('Please enter the num of the algorithm to run it:')
    import time
    s = time.time()
    if order == '1':
        conf = Config('./config/BPR.conf')

    elif order == '2':
        conf = Config('./config/FISM.conf')

    elif order == '3':
        conf = Config('./config/WRMF.conf')

    elif order == '4':
        conf = Config('./config/IPF.conf')

    elif order == '5':
        conf = Config('./config/UserKNN.conf')

    elif order == 'b1':
        conf = Config('./config/MostPop.conf')
Beispiel #20
0
from algorithm.rating.UserKNN import UserKNN
from algorithm.rating.ItemKNN import ItemKNN
from tool.config import Config

if __name__ == '__main__':
    print '=' * 80
    print '   RecQ: An effective python-based recommender algorithm library.   '
    print '=' * 80

    print '1. UserKNN   2. ItemKNN'
    algor = 0
    order = input('please enter the num of the algorithm to run it:')
    import time
    s = time.clock()
    if order == 1:
        conf = Config('../config/UserKNN')
        algor = UserKNN(conf)
    elif order == 2:
        conf = Config('../config/itemKNN')
        algor = ItemKNN(conf)
    else:
        print 'Error num!'
        exit()
    algor.execute()
    e = time.clock()
    print "Run time: %f s" % (e - s)
Beispiel #21
0
    print 'Baselines:'
    print 'b1. UserMean      b2. ItemMean'
    print '=' * 80
    algor = -1
    conf = -1
    order = raw_input('please enter the num of the algorithm to run it:')
    import time
    s = time.time()
    if order == '0':
        try:
            import seaborn as sns
        except ImportError:
            print '!!!To obtain nice data charts, ' \
                  'we strongly recommend you to install the third-party package <seaborn>!!!'
        conf = Config('../config/visual/visual.conf')
        Display(conf).render()
        exit(0)
    elif order == '1':
        conf = Config('../config/UserKNN.conf')

    elif order == '2':
        conf = Config('../config/ItemKNN.conf')

    elif order == '3':
        conf = Config('../config/BasicMF.conf')

    elif order == '4':
        conf = Config('../config/SlopeOne.conf')

    elif order == '5':
Beispiel #22
0
                if (i) % 1000 == 0:
                    print(datetime.now(), c, i, c / i)

        print(c)
        print(c / m)


a = [chr(ord('0') + i) for i in range(10)]
b = [chr(ord('a') + i) for i in range(26)]
c = [chr(ord('A') + i) for i in range(26)]
chars = a + b + c
chars_dic = {}
for i in range(len(chars)):
    chars_dic[i] = chars[i]
    chars_dic[chars[i]] = i
if __name__ == "__main__":
    Mean = np.array([123.68, 116.78, 103.94], dtype=np.float32)
    path = '/home/zhai/PycharmProjects/Demo35/CRNN/'
    # files = [path + 'voc_07.tf', path + 'voc_12.tf']
    files = [path + 'mnt.tf']
    # files=[path+'coco_train2017_scale.tf']
    config = Config(True, Mean, files, num_cls=62, lr=0.01, batch_size_per_GPU=64, gpus=1)

    crnn = CRNN(config)

    crnn.test()
# 1x
# 0.8914260920456495
# 2x
# 0.9035560085074227
Beispiel #23
0
    algorithm_list = ['DMF', 'CFGAN']
    algorithm_list = ['ABPR', 'BPR', 'WRMF', 'ExpoMF', 'CoFactor', 'CUNE_BPR']
    algorithm_list = ['ABPR', 'ABPR_10', 'ABPR_d', 'ABPR_sqrt', 'ABPR_t1', 'BPR', 'WRMF', 'ExpoMF', 'CoFactor', 'CUNE_BPR']
    algorithm_list = ['NeuMF', 'APR', 'CDAE', 'DMF', 'CFGAN']
    algorithm_list = ['ABPR', 'ABPR_10', 'ABPR_d', 'ABPR_sqrt', 'ABPR_t1', 'BPR', 'WRMF', 'ExpoMF', 'CoFactor',
                      'NeuMF', 'APR', 'CDAE', 'CFGAN']

    # algorithm_list = ['ABPR', 'ABPR_10', 'ABPR_d', 'ABPR_sqrt', 'ABPR_t1', 'BPR', 'WRMF', 'ExpoMF', 'CoFactor',
    #                   'CUNE_BPR']

    # algorithm_list = ['NeuMF', 'APR', 'CDAE']
    # algorithm_list = ['ABPR', 'ABPR_sqrt']


    config_dict = {name: Config(os.path.join(relative_path_root, 'config', name + '.conf')) for name in algorithm_list}

    conf_path = os.path.join(relative_path_root, 'config', 'account_{}.conf'.format(args.dataset))
    print('Account configuration path: {}'.format(conf_path))
    conf_account = Config(conf_path)
    account_data = AccountDAO(conf_account)

    for name, config in config_dict.items():
        if name.startswith('ABPR'):
            config.update_inferior(conf_account)
        else:
            config.update(conf_account)

    recSys_all = RecQMultiAlgo(config_dict, conf_account, account_data)

    # args.debug = True
Beispiel #24
0
    print ('a4. CDAE   a5. DMF')

    s = time.time()
    
    print ('Baselines:')
    print ('b1. MostPop   b2. Rand')
    print ('='*80)
    algor = -1
    conf = -1
    order = input('Please enter the num of the algorithm to run it:')

    import time
    s = time.time()

    if order=='1':
        conf = Config('./config/BPR.conf')

    elif order=='2':
        conf = Config('./config/FISM.conf')

    elif order=='3':
        conf = Config('./config/WRMF.conf')

    elif order=='4':
        conf = Config('./config/IPF.conf')

    elif order=='5':
        conf = Config('./config/UserKNN.conf')

    elif order == 'b1':
        conf = Config('./config/MostPop.conf')
    path = r'../data_preprocess/'
    Bboxes = [path + 'coco_bboxes_2017.pkl']
    img_paths = [path + 'coco_imgpaths_2017.pkl']
    masks = [path + 'coco_mask_2017.pkl']
    files = [img_paths, Bboxes, masks]

    config = Config(True,
                    Mean,
                    files,
                    num_cls=80,
                    lr=0.00125,
                    weight_decay=0.0001,
                    batch_size_per_GPU=1,
                    img_max=1333,
                    img_min=800,
                    anchor_scales=[[32], [64], [128], [256], [512]],
                    anchor_ratios=[[0.5, 1, 2], [0.5, 1, 2], [0.5, 1, 2],
                                   [0.5, 1, 2], [0.5, 1, 2]],
                    fast_n_sample=512,
                    bias_lr_factor=2,
                    roi_min_size=[1, 1, 1, 1, 1],
                    roi_train_pre_nms=12000,
                    roi_train_post_nms=2000,
                    roi_test_pre_nms=6000,
                    roi_test_post_nms=1000,
                    multi_scale_train=True)
    step = 0
    model = Mask_Rcnn
    x = 1
    pre_model_file = r'D:\BaiduNetdiskDownload\pytorch_resnet_caffe/resnet50-caffe.pth'
    model_file = r''
    train(model, config, step, x, pre_model_file, model_file=model_file)
Beispiel #26
0
from algorithm.rating.SVD import SVD
from tool.config import Config

if __name__ == '__main__':
    print '=' * 80
    print '   RecQ: An effective python-based recommender algorithm library.   '
    print '=' * 80

    print '1. UserKNN   2. ItemKNN   3. BasicMF   4. SlopeOne   5. RSTE   6. UserMean'
    print '7. ItemMean   8. SVD'
    algor = 0
    order = input('please enter the num of the algorithm to run it:')
    import time
    s = time.clock()
    if order == 1:
        conf = Config('../config/UserKNN.conf')
        algor = UserKNN(conf)
    elif order == 2:
        conf = Config('../config/ItemKNN.conf')
        algor = ItemKNN(conf)
    elif order == 3:
        conf = Config('../config/BasicMF.conf')
        algor = BasicMF(conf)
    elif order == 4:
        conf = Config('../config/SlopeOne.conf')
        algor = SlopeOne(conf)
    elif order == 5:
        conf = Config('../config/RSTE.conf')
        algor = RSTE(conf)
    elif order == 6:
        conf = Config('../config/UserMean.conf')
Beispiel #27
0
    order = 6  # input('please enter the num of the method to run it:')
    import time

    s = time.clock()
    # if order == 0:
    #     try:
    #         import seaborn as sns
    #     except ImportError:
    #         print '!!!To obtain nice data charts, ' \
    #               'we strongly recommend you to install the third-party package <seaborn>!!!'
    #     conf = Config('../config/visual/visual.conf')
    #     Display(conf).render()
    #     exit(0)

    if order == 1:
        conf = Config('../config/DegreeSAD_tmp.conf')

    elif order == 2:
        conf = Config('../config/CoDetector.conf')

    elif order == 3:
        conf = Config('../config/BayesDetector.conf')

    elif order == 4:
        conf = Config('../config/SemiSAD.conf')

    elif order == 5:
        conf = Config('../config/PCASelectUsers.conf')

    elif order == 6:
        conf = Config('../config/FAP.conf')
Beispiel #28
0
    import time
    s = time.time()
    # if order == '0':
    #     try:
    #         import seaborn as sns
    #     except ImportError:
    #         print '!!!To obtain nice data charts, ' \
    #               'we strongly recommend you to install the third-party package <seaborn>!!!'
    #     conf = Config('../config/visual/visual.conf')
    #     Display(conf).render()
    #     exit(0)

    algorthms = {'1':'UserKNN','2':'ItemKNN','3':'BasicMF','4':'SlopeOne','5':'SVD','6':'PMF',
                 '7':'SVD++','8':'EE','9':'BPR','10':'WRMF','11':'ExpoMF',
                 's1':'RSTE','s2':'SoRec','s3':'SoReg','s4':'SocialMF','s5':'SBPR','s6':'SREE',
                 's7':'LOCABAL','s8':'SocialFD','s9':'TBPR','s10':'SEREC','a1':'CoFactor',
                 'a2':'CUNE_MF','a3':'CUNE_BPR','a4':'IF_BPR',
                 'd1':'APR','d2':'CDAE','d3':'DMF','d4':'NeuMF','d5':'CFGAN','d6':'IRGAN','d7':'RSGAN','d8':'NGCF',
                 'd9':'LightGCN', 'd10':'ESRF', 'd11':'DHCF', 'd12':'DiffNet','d13':'MHCN',
                 'b1':'UserMean','b2':'ItemMean','b3':'MostPopular','b4':'Rand'}

    try:
        conf = Config('../config/'+algorthms[order]+'.conf')
    except KeyError:
        print 'Error num!'
        exit(-1)
    recSys = RecQ(conf)
    recSys.execute()
    e = time.time()
    print "Run time: %f s" % (e - s)
Beispiel #29
0
    print 'Baselines:'
    print 'b1. UserMean      b2. ItemMean      b3. MostPopular   b4. Rand'

    print '=' * 80
    algor = -1
    conf = -1
    order = raw_input('please enter the num of the algorithm to run it:')
    import time
    s = time.time()
    if order == '0':
        try:
            import seaborn as sns
        except ImportError:
            print '!!!To obtain nice data charts, ' \
                  'we strongly recommend you to install the third-party package <seaborn>!!!'
        conf = Config('../config/visual/visual.conf')
        Display(conf).render()
        exit(0)
    elif order == '1':
        conf = Config('../config/UserKNN.conf')

    elif order == '2':
        conf = Config('../config/ItemKNN.conf')

    elif order == '3':
        conf = Config('../config/BasicMF.conf')

    elif order == '4':
        conf = Config('../config/SlopeOne.conf')

    elif order == '5':
Beispiel #30
0
    print 'Hybrid Recommenders:\n'

    print 'Advanced Recommenders:'
    print 'a1. MEM   a2. SocialMR   a3. HME'

    print 'Baselines:'
    print 'b1. MostPop   b2. Rand'
    print '=' * 80
    algor = -1
    conf = -1
    order = raw_input('Please enter the num of the algorithm to run it:')
    import time
    s = time.time()
    if order == '1':
        conf = Config('./config/BPR.conf')

    elif order == '2':
        conf = Config('./config/FISM.conf')

    elif order == '3':
        conf = Config('./config/WRMF.conf')

    elif order == 'b1':
        conf = Config('./config/MostPop.conf')

    elif order == 'b2':
        conf = Config('./config/rand.conf')

    elif order == 'a1':
        conf = Config('./config/MEM.conf')