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

When running your code I got a error #2

Open
usalexsantos opened this issue Apr 15, 2019 · 6 comments
Open

When running your code I got a error #2

usalexsantos opened this issue Apr 15, 2019 · 6 comments

Comments

@usalexsantos
Copy link

Hi @susheelsk, I got an error running your code.

C:\image-background>python seg.py /input/0001.jpg /output/0001.png 1
Traceback (most recent call last):
File "seg.py", line 89, in
MODEL = DeepLabModel(modelType)
File "seg.py", line 25, in init
graph_def = tf.GraphDef.FromString(open(tarball_path + "/frozen_inference_graph.pb", "rb").read())
AttributeError: module 'tensorflow' has no attribute 'GraphDef'

Can you help?

@susheelsk
Copy link
Owner

Looks like a virtualenv issue. Can you try reinstalling tf?

@dirkk0
Copy link

dirkk0 commented Mar 11, 2020

pip3 install tensorflow==1.14 fixes this.

@NMNaufaldo
Copy link

@dirkk0 In my case, I've to downgrade Python 3.8 to 3.7 to be able to install tensorflow==1.14

@dome272
Copy link

dome272 commented Jun 7, 2020

For those that might have the same issue and dont want to downgrade anything I found this solution:
tensorflow/models#7703 (comment)

@SaeedArisha
Copy link

instead of downgrading the Tf version trace the error, go to the line causing it, and then write tf.compat.v1.GraphDef

@adills
Copy link

adills commented Mar 31, 2024

Needed to make the following 3 changes in the seg.py file to be compatible with Py 3.11.6, tf 2.16.1, and pillow 10.2.0:

  1. line 25, tf.GraphDef.FromString tf.compat.v1.GraphDef.FromString
  2. line 33, tf.Session to tf.compat.v1.Session
  3. line 50, Image.ANTIALIAS to Image.LANCZOS

See updated file attached. Change the .txt back to .py after downloading.
seg.txt

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

7 participants