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

error running aocr #48

Closed
yanpozka opened this issue Jan 9, 2018 · 13 comments
Closed

error running aocr #48

yanpozka opened this issue Jan 9, 2018 · 13 comments

Comments

@yanpozka
Copy link

yanpozka commented Jan 9, 2018

After installing aocr (pip install aocr) in both my OS and the official tensor docker container(gcr.io/tensorflow/tensorflow) I'm getting this error even when I run aocr --help:

Traceback (most recent call last):
  File "/usr/local/bin/aocr", line 7, in <module>
    from aocr.__main__ import main
  File "/usr/local/lib/python2.7/dist-packages/aocr/__main__.py", line 15, in <module>
    from .model.model import Model
  File "/usr/local/lib/python2.7/dist-packages/aocr/model/model.py", line 20, in <module>
    from .seq2seq_model import Seq2SeqModel
  File "/usr/local/lib/python2.7/dist-packages/aocr/model/seq2seq_model.py", line 27, in <module>
    from .seq2seq import model_with_buckets
  File "/usr/local/lib/python2.7/dist-packages/aocr/model/seq2seq.py", line 74, in <module>
    linear = rnn_cell._linear  # pylint: disable=protected-access
AttributeError: 'module' object has no attribute '_linear'
# uname -a
Linux 71e18aa0cfc4 4.10.0-42-generic #46~16.04.1-Ubuntu SMP Mon Dec 4 15:57:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
@AdamWP
Copy link
Contributor

AdamWP commented Jan 9, 2018

In some versions of TF _linear was moved from rnn_cell to rnn_cell_impl.

You need to modify /usr/local/lib/python2.7/dist-packages/aocr/model/seq2seq.py

Change line 71 from "from tensorflow.contrib.rnn.python.ops import rnn, rnn_cell"
to
"from tensorflow.contrib.rnn.python.ops import rnn
from tensorflow.python.ops import rnn_cell_impl"

Change line 74 "linear = rnn_cell._linear" to "rnn_cell_impl._linear"

@emedvedev
Copy link
Owner

Yup, looks like it's been moved in 1.4, so aocr is lagging a little behind.

@AdamWP would you mind submitting a PR? Ideally with a conditional import, to keep compatibility with the older TF versions.

@AdamWP
Copy link
Contributor

AdamWP commented Jan 10, 2018

@emedvedev Done!

@emedvedev
Copy link
Owner

Thanks! Closing the issue.

@avielas
Copy link

avielas commented Apr 23, 2018

@emedvedev but how did you solve that?

@emedvedev
Copy link
Owner

@avielas #51

@avielas
Copy link

avielas commented Apr 23, 2018

thanks so much!!

@avielas
Copy link

avielas commented Apr 25, 2018

@emedvedev #51 didn't work for me. I used tensorflow version 1.4.0 on ubuntu 16, python version 2.7. my seq2seq.py:

from tensorflow.python.ops import nn_ops
from tensorflow.contrib.rnn.python.ops import rnn
from tensorflow.python.ops import variable_scope

try:
from tensorflow.contrib.rnn.python.ops import rnn_cell_impl
except ImportError:
from tensorflow.python.ops import rnn_cell_impl

try:
linear = rnn_cell_impl._linear # pylint: disable=protected-access
except AttributeError:
from tensorflow.contrib.rnn.python.ops import core_rnn_cell
linear = core_rnn_cell._linear # pylint: disable=protected-access

Any ideas?

@emedvedev
Copy link
Owner

emedvedev commented Apr 25, 2018 via email

@avielas
Copy link

avielas commented Apr 25, 2018

sure:
(virtualenv_attention) @:~/DL/attention-ocr$ sudo aocr dataset ./datasets/annotations-training.txt ./datasets/training.tfrecords
Traceback (most recent call last):
File "/usr/local/bin/aocr", line 7, in
from aocr.main import main
File "/usr/local/lib/python2.7/dist-packages/aocr/main.py", line 15, in
from .model.model import Model
File "/usr/local/lib/python2.7/dist-packages/aocr/model/model.py", line 20, in
from .seq2seq_model import Seq2SeqModel
File "/usr/local/lib/python2.7/dist-packages/aocr/model/seq2seq_model.py", line 27, in
from .seq2seq import model_with_buckets
File "/usr/local/lib/python2.7/dist-packages/aocr/model/seq2seq.py", line 83, in
linear = core_rnn_cell._linear # pylint: disable=protected-access
AttributeError: 'module' object has no attribute '_linear'

@avielas
Copy link

avielas commented Apr 25, 2018

I tried tf 1.2 1.4 1.8. what exactly version should I use?

@avielas
Copy link

avielas commented Apr 25, 2018

update error(tf 1.2):
(virtualenv_aocr_0_7_3) @computer-name:~/DL/aocr-0.7.3$ sudo aocr dataset ./datasets/annotations-training.txt ./datasets/training.tfrecords
Traceback (most recent call last):
File "/usr/local/bin/aocr", line 9, in
load_entry_point('aocr==0.7.3', 'console_scripts', 'aocr')()
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 542, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2569, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2229, in load
return self.resolve()
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2235, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "build/bdist.linux-x86_64/egg/aocr/main.py", line 15, in
File "build/bdist.linux-x86_64/egg/aocr/model/model.py", line 20, in
File "build/bdist.linux-x86_64/egg/aocr/model/seq2seq_model.py", line 27, in
File "build/bdist.linux-x86_64/egg/aocr/model/seq2seq.py", line 83, in
AttributeError: 'module' object has no attribute '_linear'

@emedvedev
Copy link
Owner

emedvedev commented Apr 26, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants