Skip to content

Instantly share code, notes, and snippets.

View weklund's full-sized avatar
😄
Learning

Wes weklund

😄
Learning
View GitHub Profile
LMPD
UNMANNED VEHICLE,GROUND 1 Each $298,861.00 Q 3 Oct 4, 2018 12:00:00 AM
HELMET,FLYER'S 10 Each $886.57 Q 3 Dec 8, 2016 12:00:00 AM
SPECTACLES SET,BALLISTIC AND LASER PROTECTIVE 35 Each $28.27 D 1 May 2, 2010 12:00:00 AM
SPECTACLES,BALLISTIC AND LASER PROTECTIVE 50 Each $20.16 D 1 Jul 30, 2010 12:00:00 AM
SPECTACLES KIT,BALLISTIC AND LASER PROTECTIVE 45 Kit $15.16 D 1 Oct 28, 2009 12:00:00 AM
HELMET,FLYER'S 1 Each $449.88 C Mar 2, 2010 12:00:00 AM
HELMET,ADVANCED COMBAT 18 Each $276.71 D 1 Nov 23, 2009 12:00:00 AM
HELMET,ADVANCED COMBAT 9 Each $223.69 D 1 Sep 30, 2009 12:00:00 AM
def path_to_tensor(path):
img = image.load_img(path, target_size = (224,224))
x= image.img_to_array(img)
return np.expand_dims(x, axis=0)
def paths_to_tensor(paths):
list_of_tensors = [path_to_tensor(path) for path in tqdm(paths)]
return np.vstack(list_of_tensors)
def load_dataset(path):
data = load_files(path, shuffle=True)
img_files = np.array(data['filenames'])
img_targets = np_utils.to_categorical(np.array(data['target']), 3)
return img_files, img_targets
train_files, train_labels = load_dataset('data/train')
valid_files, valid_labels = load_dataset('data/valid')
def load_dataset_no_shuffle(path):
from keras.callbacks import ModelCheckpoint
checkpoint_inception = ModelCheckpoint(
save_best_only = True,
verbose = 1,
filepath = 'saved_models/weights.best.from_inception_resnet_v2.hdf5'
)
model.fit(
train_features_inception,
submission_inception_resnet = pd.DataFrame({'Id':test_files, 'task_1':test_predictions_task1,'task_2':test_predictions_task2})
pd.DataFrame.to_csv(submission_inception_resnet, 'submission.csv', index=False)
preds_path = sys.argv[1]
thresh = 0.5
# get ground truth labels for test dataset
truth = pd.read_csv('ground_truth.csv')
y_true = truth.as_matrix(columns=["task_1", "task_2"])
model = InceptionResNetV2(weights = 'imagenet', include_top = False)
model = Sequential()
model.add(GlobalAveragePooling2D(input_shape = train_features_inception.shape[1:]))
model.add(Dropout(0.2))
model.add(Dense(1024, activation = 'relu'))
model.add(Dropout(0.2))
model.add(Dense(512, activation = 'relu'))
model.add(Dropout(0.2))
model.add(Dense(128, activation = 'relu'))

Keybase proof

I hereby claim:

  • I am weklund on github.
  • I am weseklund (https://keybase.io/weseklund) on keybase.
  • I have a public key ASAMJSGZP-tbTZy8_qO7Vbe5UN8iJk8Tm5VG9YwLTEXGDgo

To claim this, I am signing this object:

@weklund
weklund / 0_reuse_code.js
Created March 6, 2014 17:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console