pics = np.genfromtxt(imgs_loc, delimiter=',') boxs = np.genfromtxt(boxs_loc, delimiter=',') # Resize the box lists boxs = boxs.reshape(boxs.shape[0], -1, 4) # dimensions of the whole pictures, constant for now picshape = 240, 240 # height and width # Create the NN model localizer = Localizer(picshape=(240, 240), hidden_layers=(42, 30, 10)) epochs = 20 batch_size = 20 localizer.train(pics, boxs, epochs, batch_size) i = random.randint(0, pics.shape[0] - 1) pic = pics[i, :].reshape(240, 240) utils.test_localizer(localizer, pic, show_probs=True) #print(localizer.predict(pic)) # a hard test, just for fun resistors = Image.open('resistors.png', mode='r') resistors = resistors.convert(mode='F') utils.test_localizer(localizer, np.asarray(resistors), show_probs=True) localizer.save('datasets/dataset{0}/best_model'.format(dataset))