def submit(): global list_images global student_image global row global row2 student_admno = E4.get() student_name = E1.get() student_class = E2.get() student_rollno = E3.get() if ((student_admno == '') or (not student_admno.isdigit()) or (student_name == '') or (student_class not in classes) or (len(student_rollno) < 1) or (len(student_rollno) > 2) or (len(list_images) != 50) or (not student_rollno.isdigit())): showerror("Error Submit", "Something is wrong in your inputs..!!!") root.focus_set() elif (student_admno in unique_ids_list): showerror("Error Submit", "A student in this admission number already exists") root.focus_set() elif (askyesno( "Confirm Submit", "Hope you have entered right datas.\nAre you sure to submit ?") ): global root_label root.lift() root_label.destroy() root_label = Label(F0, text="Photo") root_label.pack(pady=5) root.geometry("400x300+500+50") E1.delete(0, END) E2.delete(0, END) E3.delete(0, END) E4.delete(0, END) f = open(unique_ids, "a") f.write(student_admno + '\n') f.close() for sheet in book.worksheets: sheet['A{0}'.format(row)] = student_admno sheet['B{0}'.format(row)] = student_name book.save(os.path.join("Database", "Students", "Attendence.xlsx")) row += 1 sheet2['A{0}'.format(row2)].value = student_admno sheet2['B{0}'.format(row2)].value = student_name sheet2['C{0}'.format(row2)] = "Students" book2.save(os.path.join("Database", "teachers_and_students.xlsx")) row2 += 1 cv2.imwrite( os.path.join("Database", "Students", "Images", student_class, student_rollno + ".jpg"), student_image) trainer.train(list_images, int(student_admno)) else: root.focus_set()
"baseline_ptcone20", "baseline_ptcone30", "baseline_ptcone40", "baseline_ptvarcone20", "baseline_ptvarcone30", "baseline_ptvarcone40", "baseline_eflowcone20_over_pt", "trk_vtx_type", ] options["training_split"] = 0.7 options["batch_size"] = 32 options["n_epochs"] = 10 options["n_layers"] = 3 options["hidden_neurons"] = 256 options["intrinsic_dimensions"] = 1024 # only matters for deep sets options["output_neurons"] = 2 options["device"] = args.device options["save_model"] = True options[ "model_save_path"] = options["output_folder"] + "test_gru_model.pth" options["train_BDT"] = True t0 = time.time() print("number of epochs planned:", options["n_epochs"]) print("input data:", options["input_data"].split("/")[-1]) print("batch_size:", options["batch_size"]) print("device:", args.device) print("architecture:", options["architecture_type"]) trainer.train(options) print("total runtime :", time.time() - t0) torch.cuda.empty_cache()
data_filepath = "../colores.csv" img_filepath = "../images/tanzania.jpg" x = np.genfromtxt(data_filepath, dtype=np.float128, delimiter=",", usecols=(0, 1, 2)) y = np.genfromtxt(data_filepath, dtype=np.string0, delimiter=",", usecols=(3)) class_array = [] new_y = [] for i in range(y.size): if y[i] not in class_array: class_array.append(y[i]) new_y.append([class_array.index(y[i])]) color_length = len(class_array) new_y = np.array(new_y, dtype=float128) x = x / 255. new_y = new_y / float(color_length - 1) NN = Neural_Network(3, 11, 1) trainer = trainer(NN) trainer.train(x, new_y) print(get_predominant_color(NN, img_filepath, class_array))
torch.cuda.manual_seed_all(random_seed) torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False np.random.seed(random_seed) # Setting the config for each stage train_config = get_config(mode='train') dev_config = get_config(mode='dev') test_config = get_config(mode='test') print(train_config) # Creating pytorch dataloaders train_data_loader = get_loader(train_config, shuffle=True) dev_data_loader = get_loader(dev_config, shuffle=False) test_data_loader = get_loader(test_config, shuffle=False) # Trainer is a wrapper for model training, validating and testing trainer = trainer(train_config, train_data_loader, dev_data_loader, test_data_loader, is_train=True) # Build the model trainer.build() # Train the model (test scores will be returned based on val performance) trainer.train()