def_c_value = cfg.getfloat('svm', 'def_c_value') # Opens a text file to note test results text_file = open("output2.txt", "a") text_file.write("Method used: " + params['method'] + "\n") text_file.write("-------------------------------------\n") # If c_iteration is True, iterates from 0.0001 to 10000 for c values. # Else, uses default c value stated in config.ini file if c_iteration is True: for i in range(-4, 5): BG_img = compute_BG_Image(params['folder'], train_indexes) trf, trl, trfc = train(train_indexes, BG_img, params) svm_param = ' -s 0 -t 0 -c ' + str(pow(10, i)) print "c value is: " + str(pow(10, i)) svm = train_svm(trf, trl, svm_param) trf2, trl2 = bootstrap(bootstrap_indexes, BG_img, params, trf, trl, trfc, svm) svm2 = train_svm(trf2, trl2, svm_param) svm_AP, svm_PR, svm_RC = sw_search(test_indexes, BG_img, params, svm2) ap_mean = np.mean(svm_AP) text_file.write("precision for c value " + str(pow(10, i)) + " is: " + str(ap_mean) + "\n") else: BG_img = compute_BG_Image(params['folder'], train_indexes) trf, trl, trfc = train(train_indexes, BG_img, params) svm_param = ' -s 0 -t 0 -c ' + str(def_c_value) svm = train_svm(trf, trl, svm_param)
# - Starts a new job # - Starts training positive and negative features ################################################################# if mode == 'train': details = raw_input("Please enter details about new job: ") BG_img = compute_BG_Image(params['folder'], train_indexes) job = push_new_job(method, BG_img, details) print job['job_id'] + ' job is created at ' + job['timestamp'] print 'Feature extraction method used: ' + job['method'] trf, trl, trfc = train(train_indexes, BG_img, params) push_train_features(job['job_id'], trf, trl) svm = train_svm(trf, trl,' -s 0 -t 0 -c 100') trf, trl = bootstrap(bootstrap_indexes, BG_img, params, trf, trl, trfc, svm) push_bootstrap_features(job['job_id'], trf, trl) svm2 = train_svm(trf, trl, '-s 0 -t 0 -c 100') ################################################################### # If bootstrap mode is selected: # - Lists last x jobs for user to choose which one to load # - Retrieves selected training features of selected job # - Start bootstrapping ################################################################### elif mode == 'bootstrap': old_job = find_old_job()
# - Starts a new job # - Starts training positive and negative features ################################################################# if mode == 'train': details = raw_input("Please enter details about new job: ") BG_img = compute_BG_Image(params['folder'], train_indexes) job = push_new_job(method, BG_img, details) print job['job_id'] + ' job is created at ' + job['timestamp'] print 'Feature extraction method used: ' + job['method'] trf, trl, trfc = train(train_indexes, BG_img, params) push_train_features(job['job_id'], trf, trl) svm = train_svm(trf, trl, ' -s 0 -t 0 -c 100') trf, trl = bootstrap(bootstrap_indexes, BG_img, params, trf, trl, trfc, svm) push_bootstrap_features(job['job_id'], trf, trl) svm2 = train_svm(trf, trl, '-s 0 -t 0 -c 100') ################################################################### # If bootstrap mode is selected: # - Lists last x jobs for user to choose which one to load # - Retrieves selected training features of selected job # - Start bootstrapping ################################################################### elif mode == 'bootstrap': old_job = find_old_job()
# Opens a text file to note test results text_file = open("output2.txt", "a") text_file.write("Method used: " + params['method'] + "\n") text_file.write("-------------------------------------\n") # If c_iteration is True, iterates from 0.0001 to 10000 for c values. # Else, uses default c value stated in config.ini file if c_iteration is True: for i in range(-4, 5): BG_img = compute_BG_Image(params['folder'], train_indexes) trf, trl, trfc = train(train_indexes, BG_img, params) svm_param = ' -s 0 -t 0 -c ' + str(pow(10, i)) print "c value is: " + str(pow(10, i)) svm = train_svm(trf, trl, svm_param) trf2, trl2 = bootstrap(bootstrap_indexes, BG_img, params, trf, trl, trfc, svm) svm2 = train_svm(trf2, trl2, svm_param) svm_AP, svm_PR, svm_RC = sw_search(test_indexes, BG_img, params, svm2) ap_mean = np.mean(svm_AP) text_file.write("precision for c value " + str(pow(10, i)) + " is: " + str(ap_mean) + "\n") else: BG_img = compute_BG_Image(params['folder'], train_indexes) trf, trl, trfc = train(train_indexes, BG_img, params) svm_param = ' -s 0 -t 0 -c ' + str(def_c_value) svm = train_svm(trf, trl, svm_param) trf2, trl2 = bootstrap(bootstrap_indexes, BG_img, params, trf, trl, trfc, svm)