Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating and refactored project to TensorFlow 2.1.0 #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
__pycache__
.DS_Store
*.zip
env
model
.ipynb_checkpoints
23 changes: 11 additions & 12 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
absl-py==0.4.1
absl-py==0.7.0
astor==0.7.1
backcall==0.1.0
bleach==2.1.4
cloudpickle==0.5.5
cycler==0.10.0
dask==0.19.0
dask==1.0.0
decorator==4.3.0
entrypoints==0.2.3
gast==0.2.0
grpcio==1.14.2
gast==0.2.2
grpcio==1.24.3
h5py==2.8.0
html5lib==1.0.1
imageio==2.4.0
Expand All @@ -32,16 +32,15 @@ nbconvert==5.3.1
nbformat==4.4.0
networkx==2.1
notebook==5.7.8
numpy==1.14.5
numpy==1.16.0
pandocfilters==1.4.2
parso==0.3.1
pexpect==4.6.0
pickleshare==0.7.4
Pillow==5.2.0
pkg-resources==0.0.0
prometheus-client==0.3.1
prompt-toolkit==1.0.15
protobuf==3.6.1
protobuf==3.8.0
ptyprocess==0.6.0
Pygments==2.2.0
pyparsing==2.2.0
Expand All @@ -50,13 +49,13 @@ pytz==2018.5
PyWavelets==1.0.0
pyzmq==17.1.2
qtconsole==4.4.1
scikit-image==0.14.0
scipy==1.1.0
scikit-image==0.14.2
scipy==1.4.1
Send2Trash==1.5.0
simplegeneric==0.8.1
six==1.11.0
tensorboard==1.10.0
tensorflow==1.10.1
six==1.12.0
tensorboard==2.1.0
tensorflow==2.1.0
termcolor==1.1.0
terminado==0.8.1
testpath==0.3.1
Expand Down
2 changes: 1 addition & 1 deletion src/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"metadata": {},
"outputs": [],
"source": [
"sess = tf.InteractiveSession()\n",
"sess = tf.compat.v1.InteractiveSession()\n",
"cnn = LicensePlatesCNN(sess, checkpoint_dir, summary_dir)\n",
"cnn.load();"
]
Expand Down
2 changes: 1 addition & 1 deletion src/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def eval(test_data, store_results_path, input_channels=3, checkpoint_dir="checkpoint", summary_dir="summary"):
with tf.Session() as sess:
with tf.compat.v1.Session() as sess:
cnn = LicensePlatesCNN(sess=sess,
checkpoint_dir=checkpoint_dir,
summary_dir=summary_dir,
Expand Down
134 changes: 68 additions & 66 deletions src/model.py

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ def conv2d(x, W):
"""
Returns a 2D convolutional layer with full stride.
"""
return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding="SAME")
return tf.nn.conv2d(input=x, filters=W, strides=[1, 1, 1, 1], padding="SAME")


def max_pool_2x2(x):
"""
Max-pooling over 2x2 blocks
"""
return tf.nn.max_pool(x, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding="SAME")
return tf.nn.max_pool2d(input=x, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding="SAME")


def weights_variable_truncated_normal(shape, mean=0.0, stddev=0.1, name=None, trainable=True):
Expand All @@ -28,7 +28,7 @@ def weights_variable_truncated_normal(shape, mean=0.0, stddev=0.1, name=None, tr
the default list of variables to use by the `Optimizer` classes.
:return: Weight matrix
"""
initial = tf.truncated_normal(shape, mean=mean, stddev=stddev)
initial = tf.random.truncated_normal(shape, mean=mean, stddev=stddev)
return tf.Variable(initial, trainable=trainable, name=name)


Expand All @@ -43,7 +43,7 @@ def weights_variable_xavier(shape, name, trainable=True):
the default list of variables to use by the `Optimizer` classes.
:return: Weight matrix
"""
return tf.get_variable(name, shape=shape, initializer=tf.contrib.layers.xavier_initializer(), trainable=trainable)
return tf.compat.v1.get_variable(name, shape=shape, initializer=tf.compat.v1.keras.initializers.VarianceScaling(scale=1.0, mode="fan_avg", distribution="uniform"), trainable=trainable)


def bias_variable(shape, value=0, name=None, trainable=True):
Expand Down
2 changes: 1 addition & 1 deletion src/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
parser.add_argument("--summary_dir", type=str, help="Directory where to store summary", default="summary")
args = vars(parser.parse_args())

with tf.Session() as sess:
with tf.compat.v1.Session() as sess:
cnn = LicensePlatesCNN(sess,
args["checkpoint_dir"],
args["summary_dir"],
Expand Down