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 generateImagesOfVariousSizes(numberOfPoints): | |
| directory = 'data/countingVariousSizes/' + str(numberOfPoints) + '/' | |
| os.makedirs(directory, exist_ok=True) | |
| #Create 5,000 images of this class | |
| for j in tnrange(5000): | |
| path = directory + str(j) + '.png' | |
| #Get points | |
| x, y = createNonOverlappingPoints(numberOfPoints) | |
| #Create plot |
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
| learner = create_cnn(data, models.resnet34, metrics=error_rate) | |
| learner.fit_one_cycle(15, max_lr=slice(1e-4, 1e-2)) |
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
| learner = create_cnn(data, models.resnet34, metrics=error_rate) | |
| learner.fit_one_cycle(3) |
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
| path = 'data/counting' | |
| np.random.seed(42) | |
| data = ImageDataBunch.from_folder(path, train=".", valid_pct=0.2, | |
| ds_tfms=get_transforms(), size=224, num_workers=4).normalize(imagenet_stats) | |
| data.show_batch(rows=3, figsize=(7,8)) |
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
| learner = create_cnn(data, models.resnet34, metrics=error_rate) | |
| learner.fit_one_cycle(3) |
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
| path = 'data/counting' | |
| data = ImageDataBunch.from_folder(path, train=".", valid_pct=0.2, | |
| ds_tfms=get_transforms(), size=224, num_workers=4).normalize(imagenet_stats) | |
| data.show_batch(rows=3, figsize=(7,8)) |
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 random | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| def createNonOverlappingPoints(numElements): | |
| x = np.zeros((numElements)) + 2 #Place the cirlces offscreen | |
| y = np.zeros((numElements)) + 2 #Place the circles offscreen | |
| for i in range(0, numElements): | |
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
| learner.fit_one_cycle(15, max_lr=slice(1e-4)) |
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
| learner.save('stage-1') | |
| learner.unfreeze() | |
| learner.lr_find() | |
| learner.recorder.plot() |
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
| learner = create_cnn(data, models.resnet34, metrics=error_rate) | |
| learner.fit_one_cycle(5) |