[go: nahoru, domu]

Skip to content

Commit

Permalink
Remove unused 'detector' model, which was intended to be used as the …
Browse files Browse the repository at this point in the history
…first phase in a cascade to increase detection speed. This may be revived in the future.
  • Loading branch information
matthewearl committed Apr 13, 2016
1 parent 0de6632 commit 10debba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 43 deletions.
20 changes: 6 additions & 14 deletions gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,18 +304,10 @@ def members():


if __name__ == "__main__":
if sys.argv[1] == "detect":
im_gen = generate_ims(int(sys.argv[2]), bg_prob=0.5)
for img_idx, (im, _, p) in enumerate(im_gen):
fname = "detect_test/{:08d}_{}.png".format(img_idx,
"1" if p else "0")
print fname
cv2.imwrite(fname, im * 255.)
elif sys.argv[1] == "read":
im_gen = generate_ims(int(sys.argv[2]))
for img_idx, (im, c, p) in enumerate(im_gen):
fname = "test/{:08d}_{}_{}.png".format(img_idx, c,
"1" if p else "0")
print fname
cv2.imwrite(fname, im * 255.)
im_gen = generate_ims(int(sys.argv[1]))
for img_idx, (im, c, p) in enumerate(im_gen):
fname = "test/{:08d}_{}_{}.png".format(img_idx, c,
"1" if p else "0")
print fname
cv2.imwrite(fname, im * 255.)

33 changes: 4 additions & 29 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,6 @@
import model


def detector_model():
x = tf.placeholder(tf.float32, [None, 128 * 64])

W_conv1 = weight_variable([11, 11, 1, 32])
b_conv1 = bias_variable([32])
x_image = tf.reshape(x, [-1,64,128,1])
h_conv1 = tf.nn.sigmoid(conv2d(x_image, W_conv1) + b_conv1)

W_conv2 = weight_variable([1, 1, 32, 1])
b_conv2 = bias_variable([1])
h_conv2 = tf.nn.sigmoid(conv2d(h_conv1, W_conv2) + b_conv2)

b_final = bias_variable([1])
y = tf.reduce_sum(tf.reshape(h_conv2, [-1, 128 * 64]), 1) + b_final

return x, y, [W_conv1, b_conv1, W_conv2, b_conv2, b_final]


def im_to_vec(im):
return im.flatten()

Expand Down Expand Up @@ -289,15 +271,8 @@ def do_batch():
else:
initial_weights = None

if sys.argv[1] == "detect":
train_detector(learn_rate=0.1,
report_steps=10,
batch_size=10,
bg_prob=0.5,
initial_weights=initial_weights)
elif sys.argv[1] == "read":
train_reader(learn_rate=0.001,
report_steps=20,
batch_size=50,
initial_weights=initial_weights)
train_reader(learn_rate=0.001,
report_steps=20,
batch_size=50,
initial_weights=initial_weights)

0 comments on commit 10debba

Please sign in to comment.