-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Angelica/Steph] Refactored code for SVR/TDNN system.
- Loading branch information
1 parent
1e255a8
commit 130eddb
Showing
12 changed files
with
81 additions
and
86 deletions.
There are no files selected for viewing
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
File renamed without changes.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from skimage import color, io | ||
from skimage.feature import hog | ||
|
||
|
||
class Feature: | ||
|
||
def extract_hog_feature_vector(self, imageFile, image_resize_length=64): | ||
image = io.imread(imageFile) | ||
image.resize((image_resize_length,image_resize_length)) | ||
image = color.rgb2gray(image) | ||
featureVector, hog_image = hog(image, orientations=8, pixels_per_cell=(16, 16), cells_per_block=(1, 1), visualise=True) | ||
return featureVector, hog_image |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from keras.layers import Dense | ||
from keras.models import Sequential | ||
import math | ||
|
||
class RegressionModel: | ||
def __init__(self, features, labels, num_output_values=4, test_data_percentage=0.25): | ||
self.test_data_percentage = test_data_percentage | ||
self.features = features | ||
self.labels = labels | ||
self.test_features = features[int(math.ceil(len(features) * (1 - test_data_percentage))):len(features)] | ||
self.test_labels = labels[int(math.ceil(len(labels) * (1 - test_data_percentage))):len(labels)] | ||
self.feature_vector_length = len(features[0]) | ||
|
||
self.model = Sequential() | ||
self.model.add(Dense(num_output_values, input_shape=(self.feature_vector_length,), activation='sigmoid')) | ||
|
||
def fit(self): | ||
self.model.compile(loss='mean_squared_error', optimizer='rmsprop', metrics=['accuracy']) | ||
|
||
self.model.fit(self.features, self.labels, | ||
batch_size=1, epochs=2, | ||
validation_split=self.test_data_percentage) | ||
|
||
def predict(self): | ||
return self.model.predict(self.test_features, batch_size=1) |
This file contains 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
File renamed without changes.