parser.add_argument('--pretrainEpochs', help='number of epochs for pretraining', default=PRETRAINEPOCHS) parser.add_argument('--trainEpochs', '-e', help='number of epochs for training', default=TRAINEPOCHS) parser.add_argument('--batch_size', '-b', help='bastch size', default=BATCH_SIZE) parser.add_argument('--dropout', help='dropout probability', default=DROPOUT) parser.add_argument('--optim', help='optimiser', default=OPTIM) parser.add_argument('--lr', help='learning rate', default=LEARNING_RATE) parser.add_argument('--cuda', '-g', help='GPU option', default=CUDA, type=bool) parser.add_argument('--maneuvers', help='maneuvers option', default=MANEUVERS, type=bool) parser.add_argument('--modelLoc', help='trained prediction store/load location', default=MODELLOC) parser.add_argument('--pretrain_loss', help='pretrain loss algorithm', default=PRETRAIN_LOSS) parser.add_argument('--train_loss', help='train loss algorithm', default=TRAIN_LOSS) parser.add_argument('--list', '-l', action='append', help='DATASet', required=True) args = parser.parse_args() model = TnpModel(None) file_names = [] for i in args.list: folder = os.path.join(args.dir, DATA_FOLDER.format(i)) video = VIDEO.format(i) det = 'det.txt' if args.detection: sayVerbose(VERBOSE, "begin detection for {}...".format(folder)) model.YOLO_detect(folder, video, args.frames, det, "detectedFrames", args.conf, args.nms, args.cuda) sayVerbose(VERBOSE, "finished detection for {}...".format(folder)) if args.tracking:
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtCore import QThread, pyqtSignal from view.view import TrackNPredView from control.controller import Controller from model.model import TnpModel if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) Dialog = QtWidgets.QDialog() controller = Controller() view = TrackNPredView() ## to get attributes view.setupUi(Dialog) model = TnpModel(controller) controller.setView(view) controller.setModel(model) #show ui Dialog.show() sys.exit(app.exec_())
val_lst = apol_to_formatted(val_loc, files, output_dir, "val") create_data(output_dir, val_lst, args.dir, "val", threadid, class_type) test_loc = RAW_DATA output_dir = RAW_DATA + '/test_obs/formatted/' files = datasets_for_test test_lst = apol_to_formatted(test_loc, files, output_dir, "test") create_data(output_dir, test_lst, args.dir, "test", threadid, class_type) quit() print('using {} dataset.'.format(DATASET)) t0 = time.time() #ben: initialize time model = TnpModel(viewArgs) if args.cuda: print("using cuda...\n") else: print("using cpu...\n") if LOAD != '': model.load(LOAD) t1 = time.time() if TRAIN: model.train(viewArgs['dsId']) t2 = time.time() if EVAL:
# output_dir = RAW_DATA + '/val/formatted/' # files = [f for f in os.listdir(val_loc) if '.csv' in f] # val_lst = argo_to_formatted(val_loc, output_dir, "val") # create_data(output_dir, val_lst, args.dir, "val") # test_loc = RAW_DATA + '/test_obs/data/' # output_dir = RAW_DATA + '/test_obs/formatted/' # files = [f for f in os.listdir(test_loc) if '.csv' in f] # test_lst = argo_to_formatted(test_loc, files, output_dir, "test") # create_data(output_dir, test_lst, args.dir, "test") print('using {} dataset.'.format(DATASET)) t0 = time.time() model = TnpModel(viewArgs) if args.cuda: print("using cuda...\n") else: print("using cpu...\n") if LOAD != '': model.load(LOAD) t1 = time.time() # for i in range(5): # model.train(i) if TRAIN: model.train(0) t2 = time.time()
# ## path settings # args["dir"] = str(self.view.dataDir.text()) # args["frames"] = str(self.view.framesDir.text()) # ## detection settings # args["detection"] = str(self.view.detectionSelector.currentText()) # args["detConf"] = float(self.view.detConfidence.text()) # args["NMS"] = float(self.view.nmsInput.text()) # args["display"] = "False" ## prediction settings args["predAlgo"] = "Traphic" args["pretrainEpochs"] = 6 args["trainEpochs"] = 10 args["batch_size"] = 64 args["dropout"] = .5 args["optim"] = "Adam" args["lr"] = .0001 args["cuda"] = True args["maneuvers"] = False args["modelLoc"] = "resources/trained_models/Traphic_model.tar" args["pretrain_loss"] = '' args['train_loss'] = "MSE" args["dir"] = 'resources/data/TRAF' model = TnpModel() # model.train(args) model.evaluate(args)