image-background-removal icon indicating copy to clipboard operation
image-background-removal copied to clipboard

When running your code I got a error

Open usalexsantos opened this issue 5 years ago • 6 comments

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?

usalexsantos avatar Apr 15 '19 18:04 usalexsantos

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

susheelsk avatar Apr 26 '19 12:04 susheelsk

pip3 install tensorflow==1.14 fixes this.

dirkk0 avatar Mar 11 '20 18:03 dirkk0

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

NMNaufaldo avatar May 22 '20 09:05 NMNaufaldo

For those that might have the same issue and dont want to downgrade anything I found this solution: https://github.com/tensorflow/models/issues/7703#issuecomment-545669265

dome272 avatar Jun 07 '20 17:06 dome272

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

SaeedArisha avatar Jun 01 '21 08:06 SaeedArisha

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

adills avatar Mar 31 '24 18:03 adills