This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pip install opencv-python |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import cv2 | |
| from matplotlib import pyplot as plt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define the minimum matching keypoints to consider an object as a match | |
| MIN_MATCH_COUNT = 10 | |
| #read the letter we are looking for | |
| img1 = cv2.imread('a4.png',0) | |
| #read the captcha | |
| img2 = cv2.imread('aydpat.jpg',0) # trainImage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import keras | |
| from keras.layers import Dense, Input, Dropout | |
| from keras.models import Model |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def configs_builder(input_dim, output_dim, layers_configs, training_algorithms, | |
| losses, dropouts, regularizers, | |
| hidden_activations, output_activations, | |
| callbacks, metrics, initializers): | |
| configs = [] | |
| for layers_config in layers_configs: | |
| for training_algorithm in training_algorithms: | |
| for loss in losses: | |
| for dropout in dropouts: | |
| for regularizer in regularizers_v: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def feed_forward_builder(config): | |
| input_layer = Input(shape=(config['layers']['input dim'],1), dtype = config['layers']['dtype'], name = 'InputLayer') | |
| if config['layers']['number'] == 0: | |
| print('No Hidden Layers') | |
| else: | |
| layer = Dense(config['layers']['dims'][0], | |
| dtype = config['layers']['dtype'], | |
| name = config['layers']['names'][0], | |
| activation = config['layers']['activations'][0], | |
| kernel_initializer = config['layers']['initializers'][0], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| input_dim = 5 #input dimension for the network, adapte this to your use case | |
| output_dim = 1 #ouput dimension | |
| layers_configs = [[2]] #you can have multiple layers configs, if you want multiple neural networks, | |
| #for now this example will create a neural network with one hidden layer of two nodes. | |
| #[[10, 5]] this will create a neural network with two hidden layers of 10 and 5 nodes respectively | |
| #[[9],[3,2]] using this will create two configurations for two different networks | |
| #ignore the rest of parameters, they are generic, we need them so the builder works fine | |
| training_algorithms = ['rmsprop'] #you can specify multiple training algorithms each config will have one | |
| losses = ['binary_crossentropy'] #you can also define one or more loss functions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| configs = configs_builder(input_dim, output_dim, layers_configs, training_algorithms, | |
| losses, dropouts, regularizers, | |
| hidden_activations, output_activations, | |
| callbacks, metrics, initializers) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for config in configs: | |
| model = feed_forward_builder(config) | |
| ### | |
| #here you can train and evaluate you model and choose best configuraiton | |
| ### | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from os import listdir | |
| from PIL import Image | |
| import os.path | |
| import numpy as np | |
| path = 'path/to/folder/containing/exe/files' | |
| h = 256 #height of image | |
| w = 256 #width of image |