def load_image(photo_name): root= Tk() root.geometry("500x400+300+300") root.wm_iconbitmap('img1.ico') f=os.listdir("/karishma/project") root.title('Scanned QR Code') photo=PhotoImage(file=photo_name) label=Label(root,image=photo,width=600,height=350) label.pack(anchor=N) r=read(photo_name) label_1=Label(root,text="Employee details :{}".format(r),font=("System", 3), justify = 'left') label_1.pack(anchor=S) root.mainloop()
def Controller(): mode = initialization() userID = 0 userName = "" userSession = -1 while 1: if mode == "NORMAL": mode = normal() elif mode == "AUTH": userList = auth( ) # auth() returns a list of the form [ID, Name, Session - True/False, Mode - Read/Set] userID = userList[0] userName = userList[1] userSession = userList[2] mode = userList[3] elif mode == "READ": readList = read( userID, userSession ) # read(userID, userSession) returns a list of the form [Session, Mode] userSession = readList[0] if userSession == False: userID = 0 userName = "" mode = readList[1] else: mode = "READ" elif mode == "SET": setList = set( userID, userSession ) # set(userID, userSession) returns a list of the form [Session, Mode] userSession = setList[0] if userSession == False: userID = 0 userName = "" mode = setList[1] else: mode = "SET" elif mode == "TEACHER": mode = teacher() elif mode == "ADMIN": mode = admin()
def train(self): """ Training: gather all required items for finding probabilities. """ docList = {} allwords = [] for folder in self.classes: print "Reading files in:", folder docList[folder], words = read(folder, self.basePath) allwords += words self.allWords = list(set(allwords)) self.vocab = len(self.allWords) self.docList = docList print "Data Loaded."
def Controller: mode = initialization() userID = 0 userName = "" userSession while 1: if mode == "NORMAL": mode = normal() elif mode == "AUTH": userList = auth() # auth() returns a list of the form [ID, Name, Session - True/False, Mode - Read/Set] userID = userList[0] userName = userList[1] userSession = userList[2] mode = userList[3] elif mode == "READ": readList = read(userID, userSession)# read(userID, userSession) returns a list of the form [Session, Mode] userSession = readList[0] if userSession == False: userID = 0 userName = "" mode = readList[1] else: mode = "READ" elif mode == "SET": setList = set(userID, userSession) # set(userID, userSession) returns a list of the form [Session, Mode] userSession = setList[0] if userSession == False: userID = 0 userName = "" mode = setList[1] else: mode = "SET" elif mode == "TEACHER": mode = teacher() elif mode == "ADMIN": mode = admin()
listCost.append(arrayCost) arrayGradient = (np.dot(np.transpose(X), arrayLoss) / X.shape[0]) + (λ * ω) arrayGradientSum += arrayGradient**2 arraySigma = np.sqrt(arrayGradientSum) ω -= η * arrayGradient / arraySigma if itera % 1000 == 0: print("iteration:{}, cost:{} ".format(itera, arrayCost)) return ω, listCost ## 讀入資料 arrayTrainX, arrayTrainY, mean_x, std_x = read(TRAIN_PATH, True) ## Training # Adagrad intLearningRate = 1.27 arrayW = np.zeros((arrayTrainX.shape[1], 1)) # (163, ) arrayW_ada, listCost_ada = Adagrad(X=arrayTrainX, Y=arrayTrainY, ω=arrayW, η=intLearningRate, Iteration=20000, λ=0) ## Save weight np.save('../Weight/weight_best.npy', arrayW_ada) np.save('../Weight/mean_x_best.npy', mean_x)
def init(): """Map Initializtion""" global time, config, pedes, num_out, generatorSet, count, statictics global Length, Width, length, width, row_start, col_start pedes = [] num_out = 0 count = 0 del pedes[:] statictics = [] time = 0 config = read("map") for i in range(0, length): for j in range(0, width): Map[i][j].set(config[i, j]) generatorSet = [] # North for i in range(125, 135): g = Generator(121, i, len(generatorSet)) generatorSet.append(g) for i in range(85, 100): g = Generator(121, i, len(generatorSet)) generatorSet.append(g) # East for i in range(110, 122): g = Generator(i, 134, len(generatorSet)) generatorSet.append(g) for i in range(75, 85): g = Generator(i, 134, len(generatorSet)) generatorSet.append(g) for i in range(35, 45): g = Generator(i, 134, len(generatorSet)) generatorSet.append(g) for i in range(15, 25): g = Generator(i, 134, len(generatorSet)) generatorSet.append(g) # South for i in range(125, 135): g = Generator(15, i, len(generatorSet)) generatorSet.append(g) for i in range(105, 115): g = Generator(15, i, len(generatorSet)) generatorSet.append(g) # West for i in range(90, 98): g = Generator(i, 80, len(generatorSet)) generatorSet.append(g) for i in range(35, 40): g = Generator(i, 80, len(generatorSet)) generatorSet.append(g) for i in range(0, length): for j in range(0, width): config[i, j] = Map[i][j].getstate() Length, Width = config.shape if row_start > Length: row_start = 0 if col_start > Width: col_start = 0 if row_start + length > Length: length = Length - row_start if col_start + width > Width: width = Width - col_start
#This code will take number of particles and number of states, and a hamiltoninan to create the ham matrix from numpy import * from math import * from sympy import * from optparse import OptionParser from read import * mat = read() quant = [2,2] mat.quantum(quant) #n = mat.size() #v = mat.ham() #eig = mat.energy() #teste = mat.clusterenergy(v) #tau0 = mat.tau0() #tau0 = zeros((2,2)) #tau0[0,0] = 4.0 #tau0[1,0] = 6.0 #tau0[1,1] = 2.0 #print tau0 #tau = mat.newtau(tau0)
""" Prepare the data """ from read import * """ read has two methods: read and show """ """ Reads the training data """ training_iterator = read(dataset='training', path='../data') """ We use feature extraction first We will compute the following elements of an image y - the class avg_pixel - the mean of pixel, a measurement of brightness num_black - number of non-white pixels """ data = np.empty([0, 3]) for instance in training_iterator: y = instance[0] X = instance[1] X_pos = X > 0 avg_pixel = X.sum() / X.size num_black = (X > 0).sum() sym_pixel = (np.fliplr(X > 0) & X > 0) data = np.concatenate((data, np.matrix([y, avg_pixel, num_black])), axis = 0)
read_flag = 1 play("stop.mp3", 24000) if hand is 8: read_flag = 0 if hand is 2: translate('now.txt', 'en') txt2mp3('trans_en', 'en') play('trans_en.mp3', 24000) #read if read_flag is 0: read_flag = read(read_flag, orig) # update the FPS counter fps.update() # show the output frame cv2.imshow("Text Detection", orig) key = cv2.waitKey(1) & 0xFF # if the `q` key was pressed, break from the loop if key == ord("q"): break # stop the timer and display FPS information fps.stop() print("[INFO] elasped time: {:.2f}".format(fps.elapsed()))
## 引入讀資料檔 from read import * ### 需要改成讀參數 TEST_PATH = sys.argv[1] OUTPUT_PATH = sys.argv[2] WEIGHT_PATH = (sys.argv[3]==0) and './Weight/weight.npy' or './Weight/weight_best.npy' MEAN_PATH = (sys.argv[3]==0) and './Weight/mean_x.npy' or './Weight/mean_x_best.npy' STD_PATH = (sys.argv[3]==0) and './Weight/std_x.npy' or './Weight/std_x_best.npy' mean_x = np.load(MEAN_PATH) std_x = np.load(STD_PATH) ## Load data arrayTestX = read(TEST_PATH, False, mean_x, std_x) ## Load Weight w = np.load(WEIGHT_PATH) ans_y = np.dot(arrayTestX, w) ans_y = np.round(ans_y) ## Store result with open(OUTPUT_PATH, mode='w', newline='') as submit_file: csv_writer = csv.writer(submit_file) header = ['id', 'value'] print(header) csv_writer.writerow(header) for i in range(240): row = ['id_' + str(i), ans_y[i][0]] csv_writer.writerow(row)
from ped_update import * from Generator import * from write import * from math import * import scipy as SP import matplotlib matplotlib.use('TkAgg') import pylab as PL from path import * import pycxsimulator ############################################ state = read("map") static = [] for i in range(1, 9): name_open = "static" + str(i) stat = read(name_open) static.append(stat) ########################################## Map = build_map(state, static) """total = 45 while (total < 100): total = total + 1 global time, config, pedes,num_out,generatorSet,count, statictics global Length, Width, length, width, row_start, col_start data = read("map") config = data
def ReadNotePad(self): read(self.filename)
def assertExpressionRead(inputString, result): inputStream = Stream(inputString) expression = read(inputStream) assert(expressionToString(expression) == result)