Commit e959b342 authored by mihaivanea's avatar mihaivanea
Browse files

When demoing the dense cnn, it overfits tooo quicklly.

parent 135ec5d2
#!/vol/bitbucket/mv1315/urop/venv/bin/python3.5
import numpy as np
from keras.layers import Dense, Input, Flatten
from keras.models import Model
from generate_arrays_fddb import load_arrays_fddb
......@@ -6,7 +7,8 @@ from generate_arrays_fddb import load_arrays_fddb
inputs = Input(shape=(224, 224,3,))
x = Dense(100, activation="relu")(inputs)
x = Dense(100, activation="relu")(x)
x = Dense(32, activation="relu")(x)
x = Dense(10, activation="relu")(x)
x = Flatten()(x)
predictions = Dense(4, activation="relu")(x)
......@@ -19,6 +21,18 @@ model.compile(
fddb_path_train = "../fddb/FDDB-folds/FDDB-fold-01-ellipseList.txt"
x_train, y_train = load_arrays_fddb(fddb_path_train)
x_train = np.empty([224,224,3])
y_train = np.empty([4])
for i in range(1, 10):
x_t, y_t = load_arrays_fddb(fddb_path_train[:30] + str(i) + \
fddb_path_train[31:])
np.concatenate((x_train, x_t), axis=0)
np.concatenate((y_train, y_t), axis=0)
model.fit(
x_train, y_train,
batch_size=64,
epochs=10,
verbose=1)
model.fit(x_train, y_train)
......@@ -26,12 +26,9 @@ def convert_to_cartesian(ellip_array):
y1 = round(c_y - major_r, 4)
x2 = round(c_x + minor_r, 4)
y2 = round(c_y + major_r, 4)
#box = [round(p, 4) for p in (x1, y1, x2, y2)]
#cartesian_output.append(box)
#break
#cartesian_output = np.array(cartesian_output)
#return cartesian_output
return x1, y1, x2, y2
cartesian_output.append([x1, y1, x2, y2])
break
return cartesian_output
def generate_arrays_fddb(path):
no_labels, labels = (l for l in benchmark.tokenise(path))
......@@ -59,7 +56,8 @@ def load_arrays_fddb(path):
if len(data.shape) == 3:
x.append(data)
result = convert_to_cartesian(lb[2])
y.append(result)
for r in result:
y.append(r)
x = np.array(x)
y = np.array(y)
return x, y
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment