def main(): X,Y = get_image_data() X = X.transpose((0,2,3,1)) model = CNN( convpool_layer_sizes=[(20,5,5),(20,5,5)], hidden_layer_sizes=[500,300] ) model.fit(X,Y)
def create_blur_image(image, radius, weight): img, width, height = open_image(image) image_data = get_image_data(img) new_image_data = get_image_data(img) new_color = [] for x in range(width): for y in range(height): image_data_submatrix, height_sub, width_sub = extract_submatrix(x, y, height, width, image_data.copy(), radius, weight) new_color = calculate_new_color(image_data_submatrix, weight, height_sub, width_sub) new_image_data[y][x] = new_color save_new_image(new_image_data, f'test-image-blur-radius-{radius}-weight-{weight}.png') print('Image successfully changed.')
def main(): X, Y = get_image_data() # reshape X for tf: N * W * H *C # i in the j-th place in the tuple means a‘s i-th axis becomes a.transpose()‘s j-th axis. X = X.transpose((0, 2, 3, 1)) print('X.shape: ', X.shape) model = Cnn( convpool_layer_sizes=[(20, 5, 5), (20, 5, 5)], hidden_layer_sizes=[500, 300] ) model.fit(X, Y)
def change_image_color(image): img, width, height = open_image(image) image_data = get_image_data(img) new_color = [] for color in ['red', 'green', 'blue']: for x in range(width): for y in range(height): r, g, b, alpha = img.getpixel((x, y)) if color == 'red': new_color = [r,0,0, alpha] elif color== 'green': new_color = [0,g,0, alpha] elif color == 'blue': new_color = [0,0,b, alpha] image_data[y][x] = new_color save_new_image(image_data, f"test-image-split-{color}.png") print('Images successfully saved.')
import h5py from util import get_image_data folder = './../data/with_brace/ipad_zach/ring_cont2' images, data = get_image_data(folder) out_data = [images, data] with h5py.File(folder + '/image_data.h5', 'w') as hf: hf.create_dataset("images", data=images) hf.create_dataset("data", data=data)
def main(): X_train, labels_train, X_val, labels_val = get_image_data() model = CNN(convpool_layer_sizes=[(20, 5, 5), (20, 5, 5)], hidden_layer_sizes=[300, 100]) model.fit(X_train, labels_train, X_val, labels_val, show_fig=True)
def main(): X, Y = get_image_data() model = CNN(conv_pool_size=[(20, 5, 5), (20, 5, 5)], hidden_layer_size=[500, 300]) model.fit(X, Y)