def main(self): for fold in self.walk_dir(config.POSITIVE_DIR): if not os.path.exists(config.TRAIN_DIR + fold): os.makedirs(config.TRAIN_DIR + fold) print "Reading training images..." faces = [] labels = [] pos_count = 0 neg_count = 0 count = 0 List = UserData.UserData() pose_list = config.LIST_DIR + fold + '.pkl' folder_path = config.POSITIVE_DIR List.WriteList(pose_list, folder_path) List.ReadList(pose_list, folder_path) # Read all positive images for filename in self.walk_files(config.POSITIVE_DIR + fold, '*.pgm'): faces.append(self.prepare_image(filename)) labels.append(config.POSITIVE_LABEL) pos_count += 1 # Read all negative images for filename in self.walk_files(config.NEGATIVE_DIR, '*.pgm'): faces.append(self.prepare_image(filename)) labels.append(config.NEGATIVE_LABEL) neg_count += 1 print 'Read', pos_count, 'positive images and', neg_count, 'negative images.' # Train model print 'Training model...' model = cv2.createEigenFaceRecognizer() model.train(np.asarray(faces), np.asarray(labels)) # Save model results trainfile = os.path.join(config.TRAIN_DIR + fold, config.TRAINING_FILE) model.save(trainfile) print 'Training data saved to', config.TRAIN_DIR + fold, config.TRAINING_FILE # Save mean and eignface images which summarize the face recognition model. meanfile = os.path.join(config.TRAIN_DIR + fold, MEAN_FILE) positivefile = os.path.join(config.TRAIN_DIR + fold, POSITIVE_EIGENFACE_FILE) negativefile = os.path.join(config.TRAIN_DIR + fold, NEGATIVE_EIGENFACE_FILE) mean = model.getMat("mean").reshape(faces[0].shape) cv2.imwrite(meanfile, self.normalize(mean, 0, 255, dtype=np.uint8)) eigenvectors = model.getMat("eigenvectors") pos_eigenvector = eigenvectors[:, 0].reshape(faces[0].shape) cv2.imwrite( positivefile, self.normalize(pos_eigenvector, 0, 255, dtype=np.uint8)) neg_eigenvector = eigenvectors[:, 1].reshape(faces[0].shape) cv2.imwrite( negativefile, self.normalize(neg_eigenvector, 0, 255, dtype=np.uint8)) count += 1 else: execfile('admin.py')
def ReadCardID(self): global ID global camera global door global led User = UserData.UserData() ID = User.UserID() camera = config.get_camera() door = hardware.Door() led = hardware.Led()
async def stop(ctx: commands.Context): dm = ctx.guild is None if not dm: if ctx.guild.id not in allowed_channels: return if ctx.channel.id not in allowed_channels[ctx.guild.id]: return if ctx.author.id in users: user = users[ctx.author.id] else: if not dm: user = UserData.UserData(ctx.guild.id, ctx.channel.id) else: user = UserData.UserData(None, ctx.channel.id) users[ctx.author.id] = user if (dm and user.can_dm()) or not dm: user.toggle_pause() if user.paused(): await ctx.send("I will stop messaging you") else: await ctx.send("I will resume messaging you")
async def dmme(ctx: commands.Context): dm = ctx.guild is None if not dm: if ctx.guild.id not in allowed_channels: return if ctx.channel.id not in allowed_channels[ctx.guild.id]: return if ctx.author.id in users: user = users[ctx.author.id] else: if not dm: user = UserData.UserData(ctx.guild.id, ctx.channel.id) else: user = UserData.UserData(None, ctx.channel.id) users[ctx.author.id] = user if user.paused(): await stop(ctx) user.toggle_dm() if user.can_dm(): await ctx.send("I will now be able to send you direct messages") else: await ctx.send("I will no longer be able to send you direct messages")
async def total(ctx: commands.Context): dm = ctx.guild is None if not dm: if ctx.guild.id not in allowed_channels: return if ctx.channel.id not in allowed_channels[ctx.guild.id]: return if ctx.author.id in users: user = users[ctx.author.id] else: if not dm: user = UserData.UserData(ctx.guild.id, ctx.channel.id) else: user = UserData.UserData(None, ctx.channel.id) users[ctx.author.id] = user if user.paused(): await stop(ctx) if (dm and user.can_dm()) or not dm: await ctx.send("In total you've drank %i times" % user.times_drunk()) else: await ctx.send("You have not enabled direct messages. Enable them with ``%sdmme`` first" % prefix) return
async def sip(ctx: commands.Context, *time): dm = ctx.guild is None if not dm: if ctx.guild.id not in allowed_channels: return elif ctx.channel.id not in allowed_channels[ctx.guild.id]: return if ctx.author.id in users: user = users[ctx.author.id] else: if not dm: user = UserData.UserData(ctx.guild.id, ctx.channel.id) else: user = UserData.UserData(None, ctx.channel.id) users[ctx.author.id] = user if time.__len__() > 0: time = datetime_formatting.read_timedelta(list(time)) else: time = user.drink_break if user.paused(): await stop(ctx) if (dm and user.can_dm()) or not dm: if not dm: user.update_channel(ctx.guild.id, ctx.channel.id) else: user.update_channel(None, ctx.channel.id) user.set_break(time) user.drink() time = user.next_drink() - datetime.datetime.now() await ctx.send("Great! I will remind you to drink again in %s" % datetime_formatting.neat_timedelta(time)) else: await ctx.send("You have not enabled direct messages. Enable them with ``%sdmme`` first" % prefix) return await remind(ctx.author.id)
def configure( self, num_of_movie_need_rating=60, knn_sim_metric="correlation", knn_n_neighbor=10, df_user=None, df_app_user=None, df_data=None, df_ratmat=None, df_app_data=None, df_movie=None,df_movie_genre=None): """Instantiates, wire and configure all the object comprising of the system. Args: num_of_movie_need_rating: minimum amount of rating required for a user knn_sim_metric: KNN metric option, default: "correlation" knn_n_neighbor: number of K nearest users for KNN df_user: optional custom data set for base user df_app_user: optional custom data set for app user df_data: optional custom data set for base user rating data df_ratmat: optional custom data set for userxrating matrix df_app_data: optional custom data set for app user rating data df_movie: optional custom data set for movie information df_movie_genre: optional custom data set for movie by genre information """ self.num_of_movie_need_rating = num_of_movie_need_rating # configure model objects self.knn_n_neighbor = knn_n_neighbor knn = Knn.Knn(knn_sim_metric) genre = Genre.Genre() # configure backend data objects movie_data = md.MovieData(df_movie=df_movie, df_movie_genre=df_movie_genre) user_data = ud.UserData(df_user=df_user) app_user_data = ud.AppUserData(user_data, df_app_user=df_app_user) rating_data = rd.RatingData(df_data=df_data, df_ratmat=df_ratmat, df_app_data=df_app_data) # configure backend service objects user_service = us.UserService(user_data, app_user_data) movie_service = ms.MovieService(movie_data, rating_data) recommend_service = cs.RecommendService(rating_data, movie_data, user_data, app_user_data, knn, genre) rating_service = rs.RatingService(rating_data, movie_data, user_data, app_user_data) # app reference to backend service end points self.bs_movie = bs.MovieService(movie_service) self.bs_user = bs.UserService(user_service) self.bs_recommend = bs.RecommendService(recommend_service) self.bs_rating = bs.RatingService(rating_service) # configure frontend UI object and passes over backend end points self.fe = UI.UI(self, num_of_movie_need_rating) self.fe.configure(self.bs_movie, self.bs_user, self.bs_recommend, self.bs_rating)
def parseLine(line): p = list(map(lambda s: s.strip().replace("\"", ""), line.split(","))) try: return UserData(int(p[0]), str(p[1]), p[2] == 'True', p[3] == 'True', int(p[4]), int(p[5]), \ int(p[6]), int(p[7]), int(p[8]), float(p[9]), float(p[10]), float(p[11]), float(p[12]), \ float(p[13]), float(p[14]), float(p[15]), float(p[16]), float(p[17]), float(p[18]), float(p[19]), \ float(p[20]), float(p[21]), float(p[22]), float(p[23]), float(p[24]), float(p[25]), float(p[26]), \ float(p[27]), float(p[28]), float(p[29]), float(p[30]), float(p[31]), float(p[32]), float(p[33]), \ float(p[34]), float(p[35]), float(p[36]), float(p[37]), float(p[38]), float(p[39]), float(p[40]), \ float(p[41]), float(p[42]), float(p[43]), float(p[44]), float(p[45]), float(p[46]), float(p[47]), \ float(p[48]), float(p[49]), float(p[50]), float(p[51]), float(p[52]), float(p[53]), float(p[54]), \ float(p[55]), float(p[56]), float(p[57]), float(p[58]), float(p[59]), float(p[60]), float(p[61]), \ float(p[62]), float(p[63]), float(p[64]), float(p[65]), float(p[66]), float(p[67]), float(p[68]), \ float(p[69]), float(p[70]), float(p[71]), float(p[72]), float(p[73]), float(p[74]), float(p[75]), \ float(p[76]), float(p[77]), float(p[78]), float(p[79]), float(p[80]), float(p[81]), float(p[82]), \ float(p[83]), float(p[84]), float(p[85]), float(p[86]), float(p[87]), float(p[88]), float(p[89]), \ float(p[90]), float(p[91]), float(p[92]), float(p[93]), float(p[94]), float(p[95]), float(p[96]), \ float(p[97]), float(p[98]), float(p[99])) except: return None #drop entries where float(x) returns an error (i.e. blank spaces)
with open('mamem-phase2-fall17-export.json', encoding='utf-8') as data_file: # Load dataset into list of users data = json.load(data_file) # Go over users in data set and store participants of MAMEM user_data_list = [] print('Processing of users', end='') for uid, user in data['users'].items(): # Check whether user is participant for entry in dfn.user_filter: # go over known participants if uid == entry.uid: # uid matches print('.', end='') user_data_list.append( ud.UserData(uid, entry.mid, user, entry.setup_date)) print('finished.') # Sort user data list same as filter list sorted_user_data_list = [] for entry in dfn.user_filter: for user_data in user_data_list: if user_data.uid == entry.uid: sorted_user_data_list.append(user_data) break user_data_list = sorted_user_data_list # Initialize report rp.init_file()
#Trabajo practico del Instituto Tecnologico de Buenos Aires #Teoria de circuitos- DiseƱo de filtros analogicos #Autores: # Matias Larroque Legajo:56597 # Lucero Guadalupe Fernanadez Legajo:57485 # Manuel Mollon Legajo:58023 # Ezequiel Vijande Legajo:58057 # # #Fecha de entrega:25/10/2018 # # # El siguiente programa consiste en la realizacion de una interfaz grafica que permite que un usuario ingrese # los parametros necesarios para realizar la plantilla de un filtro analogico. La interfaz grafica permite # la eleccion del tipo de filtro(Pasa-Bajos, Pasa-Altos, Pasa-Banda,Rechaza-Banda) asi como tambien la aproximacion # que el usuario desea emplear(Algunas opciones son Butterworth y Chebycheff). Luego de seleccionar el tipo de filtro y # aproximacion deseada, se deben establecer los parametros de la plantilla que se desea. import ApGUI as ap import UserData as u import Manager as M data = u.UserData() interfaz = ap.ApGUI() Controller = M.Manager(data, interfaz) while ((Controller.getState()) != M.EXIT): interfaz.Update() Controller.Dispatch(interfaz.GetEvent())
def interface(user, obj: examSystemData.Exam): logger.logger.info('Entered User Interface') obj_user_data = UserData.UserData() obj_questions = QuestionAndSolutions.QuestionData(obj) obj_solutions = QuestionAndSolutions.SolutionData() permmision = 0 # 1 - C, 2 - L, 3 - C print('You can :') if user == 'Coordinator': print_coordinator_menu() logger.logger.info('Entered Coordinator User Interface') permmision = 1 elif user == 'Lecturer': print_leturer_menu() logger.logger.info('Entered Lecturer User Interface') permmision = 2 elif user == 'Student': print_student_menu() logger.logger.info('Entered Student User Interface') permmision = 3 while True: choice = input() if choice == '1' and permmision == 1: logger.logger.info('Entered Main Menu') lecturer_first_name, lecturer_last_name = input( 'enter lecturer first name + last name with a whitespace between : ' ).split() obj_user_data.add_lecturer(lecturer_first_name, lecturer_last_name) logger.logger.info('Added Lecturer To User System') elif choice == '2' and permmision == 1: lecturer_first_name, lecturer_name_change = input( 'enter lecturer first name + the change with a whitespace between : ' ).split() obj_user_data.edit_lecturer_info(lecturer_first_name, lecturer_name_change) logger.logger.info('Edited Lecturer`s info In User System') elif choice == '3' and permmision == 1: obj_solutions.add_sol(input('Add A solution : ')) logger.logger.info('Added Solution To DataBase') elif choice == '4' and permmision == 1: list_of_values = input( 'enter with - Difficulity, Topic, sub_topic, Code, Format : ' ).split() obj_questions.add_question(list_of_values) logger.logger.info('Added Question To DataBase') elif choice == '5' and permmision == 1: question = int(input("What answer would you want to edit?")) new_sol = input('Enter Your Edit') obj_solutions.edit_sol(question, new_sol) logger.logger.info('Edited Solution In DataBase') elif choice == '6' and (permmision == 1 or permmision == 2): key = input( 'enter what you want to change, Difficulity, Topic, sub_topic, Code, Format : ' ) num = int(input('Enter questions number : ')) value = input('enter your new value : ') obj_questions.edit_question(num, key, value) logger.logger.info('Edited Question In DataBase') elif choice == '7' and (permmision == 1 or permmision == 2 or permmision == 3): obj_questions.print_sorted_question_list_by_diff() logger.logger.info('Printed Question List By Diff') elif choice == '8' and (permmision == 1 or permmision == 2 or permmision == 3): key = input('enter your filter-by-criteria : ') value = input('enter your filter-by-value : ') obj_questions.print_filtered_question_list(key, value) logger.logger.info('Printed Question List By Criteria') elif choice == '0': logger.logger.info('Exited User Interface') break else: print('Invalid Choice, Try Again') logger.logger.warning('Bad Input')
def UserID(self): global ID User = UserData.UserData() ID = User.TrainData()
""" Payroll Processing page """ from tkinter import * from UserData import * from GuiValues import * ud = UserData() gv = GuiValues() # Create our frame # self = Tk() class PayrollProcessing(Frame): def __init__(self, parent, controller): Frame.__init__(self, parent) self.controller = controller # Object list payrollDesc = Label(self, text="Will process payroll for current pay cycle") timecardDesc = Label(self, text="Takes you to import timecards") salesDesc = Label(self, text="Takes you to import sales reports") spacer = Label(self, text=" ") # button employeesButton = Button(self, text="Employee's",
from UserData import * getUser = UserData() def test(): print getUser.verify("fenglin", "newP") ''' print getUser.signUp("fegli1", "password","*****@*****.**") print getUser.setInformation("Feng", "Lin", "1996-08-06", "Windish") ''' print getUser.changeUserEmail("*****@*****.**") if __name__ == "__main__": test()
conn = DBConn(outputFile) # Loop through all users in our loaded list for u in APITools.loadUsersFromCsv(userList): # Build and also encode all odd characters to a URL-safe format jsonurl = urllib.parse.quote("http://localhost:4444/api/v3/u/" + str(u) + "/blob", safe=':/') print(u.rstrip()) try: # Attempt to get the JSON blob for a user blob = APITools.getDataForUser(jsonurl) # Create a UserData object to hold information about the active user uData = UserData() uData.processBlob(blob) # Add their competitive rank to the global list if they placed cr = uData.getCompRank() if cr is not None: complist.append(cr) # Get the hero distribution for the user dist = uData.getHeroDist() if dist is not None: # Calculate the standard deviation of the list # Note: a std of 0.0 is a "one-trick" std = Calculators.getHeroStd(dist[1])
from UserData import * from WhereToTypes import * from Destination import * mattsProfile = UserData( "Matt Gaylor", 24 ) venice = Destination( "Venice", "Italy", TravelledState.HasBeen, 0, 0, 1 ) shanghai = Destination( "Shanghai", "China", TravelledState.HasBeen, 2, 2, 1 ) lima = Destination( "Lima", "Peru", TravelledState.WantsToGo, 3, 3 ) anywhereButHere = Destination( "", "Outside of Natalie's Living Room", TravelledState.WantsToGo, 3, 3 ) georgia = Destination( "Georgia", "USA", TravelledState.WantsToGo, 3, 3 ) singapore = Destination( "", "Singapore", TravelledState.WantsToGo, 3, 3 ) mattsProfile.AddDestination( venice ) mattsProfile.AddDestination( shanghai ) mattsProfile.AddDestination( lima ) mattsProfile.AddDestination( anywhereButHere ) mattsProfile.AddDestination( georgia ) mattsProfile.AddDestination( singapore ) mattsProfile.ToString() mattsProfile.RegisterTrip( singapore ) mattsProfile.RegisterTrip( venice ) mattsProfile.ToString() heaven = Destination( "Nigels", "Butthole", TravelledState.WantsToGo, 3, 3, 68 ) mattsProfile.RegisterTrip( heaven ) mattsProfile.ToString()
def ListPose(self): pose_list = config.LIST_DIR + ID + '.pkl' folder_path = config.POSITIVE_DIR + ID List = UserData.UserData() List.WriteList(pose_list, folder_path)