def main(): model = KMeansThresholding() train_files_x = find_files("data/train") train_files_y = find_files("data/train_cleaned") y_pred = map(lambda x: extract_x([x],0), train_files_x) y_pred = list(map(predict, y_pred)) y_pred = np.concatenate(y_pred) y_true = np.concatenate(list(map(lambda x: extract_y([x],0) ,train_files_y))) print("Calculating MSE") mse = metrics.mean_squared_error(y_true, y_pred) print("MSE: %0.2f (+/- %0.2f)" % (mse.mean()*100, mse.std() * 200))
def main(): r = int(getarg(1, 0)) k = int(getarg(2, 0)) print("Extracting with radius=%d" % (r)) prefix = "data/train" if(k > 0): prefix += "_k"+str(k) train_files_x = find_files(prefix) X = extract_x(train_files_x,r) train_files_y = find_files("data/train_cleaned") y = extract_y(train_files_y,r) outname = prefix+"_r"+str(r)+".npz" np.savez(outname,X=X,y=y)
def main(): r = int(getarg(1, 0)) k = int(getarg(2, 3)) print("Extracting with radius=%d" % (r)) prefix = "data/train" outname = prefix+"_c_k"+str(k)+"_r"+str(r)+".npz" print("Saving to: "+ outname) train_files_x = find_files(prefix) X = extract_x(train_files_x,r) Xk = extract_x(find_files(prefix+"_k"+str(k)),r,True) X = np.concatenate([X,Xk], axis=1) train_files_y = find_files("data/train_cleaned") y = extract_y(train_files_y,r) np.savez(outname,X=X,y=y)
def main(): test_files = find_files("data/test") model = pickle.load(open("data/raw_lin.p", "rb")) for f in test_files: w,h = Image.open(f).size X = extract_x([f]) y = np.reshape(model.predict(X), (h,w)) y = np.vectorize(filter_point_value)(y) img = Image.fromarray(y.astype(np.uint8)) outf = str.replace(f,"data/test","out/raw_lin") img.save(outf)