Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
71349a10
Unverified
Commit
71349a10
authored
Nov 11, 2017
by
Martin Wicke
Committed by
GitHub
Nov 11, 2017
Browse files
Merge pull request #2565 from alexgorban/master
#attention_ocr: fix deprecation warnings and update usage examples
parents
3653ef1b
d906b135
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
7 additions
and
7 deletions
+7
-7
research/attention_ocr/README.md
research/attention_ocr/README.md
+2
-2
research/attention_ocr/python/demo_inference.py
research/attention_ocr/python/demo_inference.py
+1
-0
research/attention_ocr/python/model.py
research/attention_ocr/python/model.py
+1
-1
research/attention_ocr/python/model_test.py
research/attention_ocr/python/model_test.py
+2
-3
research/attention_ocr/python/sequence_layers.py
research/attention_ocr/python/sequence_layers.py
+1
-1
No files found.
research/attention_ocr/README.md
View file @
71349a10
...
...
@@ -34,7 +34,7 @@ pip install --upgrade tensorflow-gpu
2.
At least 158GB of free disk space to download the FSNS dataset:
```
cd
models
/attention_ocr/python/datasets
cd
research
/attention_ocr/python/datasets
aria2c -c -j 20 -i ../../../street/python/fsns_urls.txt
cd ..
```
...
...
@@ -50,7 +50,7 @@ cd ..
To run all unit tests:
```
cd
models
/attention_ocr/python
cd
research
/attention_ocr/python
python -m unittest discover -p '*_test.py'
```
...
...
research/attention_ocr/python/demo_inference.py
View file @
71349a10
...
...
@@ -12,6 +12,7 @@ https://www.tensorflow.org/serving/serving_basic
Usage:
python demo_inference.py --batch_size=32
\
--checkpoint=model.ckpt-399731
\
--image_path_pattern=./datasets/data/fsns/temp/fsns_train_%02d.png
"""
import
numpy
as
np
...
...
research/attention_ocr/python/model.py
View file @
71349a10
...
...
@@ -299,7 +299,7 @@ class Model(object):
with shape [batch_size x seq_length].
"""
log_prob
=
utils
.
logits_to_log_prob
(
chars_logit
)
ids
=
tf
.
to_int32
(
tf
.
argmax
(
log_prob
,
dimension
=
2
),
name
=
'predicted_chars'
)
ids
=
tf
.
to_int32
(
tf
.
argmax
(
log_prob
,
axis
=
2
),
name
=
'predicted_chars'
)
mask
=
tf
.
cast
(
slim
.
one_hot_encoding
(
ids
,
self
.
_params
.
num_char_classes
),
tf
.
bool
)
all_scores
=
tf
.
nn
.
softmax
(
chars_logit
)
...
...
research/attention_ocr/python/model_test.py
View file @
71349a10
...
...
@@ -19,7 +19,6 @@ import numpy as np
import
string
import
tensorflow
as
tf
from
tensorflow.contrib
import
slim
from
tensorflow.contrib.tfprof
import
model_analyzer
import
model
import
data_provider
...
...
@@ -127,9 +126,9 @@ class ModelTest(tf.test.TestCase):
ocr_model
=
self
.
create_model
()
ocr_model
.
create_base
(
images
=
self
.
fake_images
,
labels_one_hot
=
None
)
with
self
.
test_session
()
as
sess
:
tfprof_root
=
model_analyzer
.
print_model_analysis
(
tfprof_root
=
tf
.
profiler
.
profile
(
sess
.
graph
,
tfprof
_options
=
model_analyzer
.
TRAINABLE_VARS_PARAMS_STAT_OPTIONS
)
options
=
tf
.
prof
iler
.
ProfileOptionBuilder
.
trainable_variables_parameter
()
)
model_size_bytes
=
4
*
tfprof_root
.
total_parameters
self
.
assertLess
(
model_size_bytes
,
1
*
2
**
30
)
...
...
research/attention_ocr/python/sequence_layers.py
View file @
71349a10
...
...
@@ -216,7 +216,7 @@ class SequenceLayerBase(object):
Returns:
A tensor with shape [batch_size, num_char_classes]
"""
prediction
=
tf
.
argmax
(
logit
,
dimension
=
1
)
prediction
=
tf
.
argmax
(
logit
,
axis
=
1
)
return
slim
.
one_hot_encoding
(
prediction
,
self
.
_params
.
num_char_classes
)
def
get_input
(
self
,
prev
,
i
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment