DEV Community

Discussion on: How to Change Background of an image using PixelLib

Collapse
 
theviren profile image
Virendra Chaudhary

Thank you so much for the post. I tried this. But I am not sure why I am getting following error. Any help to fix this issue is really appreciated.

File "change_background.py", line 3, in <module>
from pixellib.tune_bg import alter_bg
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pixellib/tune_bg/__init__.py", line 4, in <module>
from pixellib.semantic.deeplab import Deeplab_xcep_pascal
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pixellib/semantic/__init__.py", line 4, in <module>
from .deeplab import Deeplab_xcep_pascal
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pixellib/semantic/deeplab.py", line 15, in <module>
from tensorflow.python.keras.layers import BatchNormalization
ImportError: cannot import name 'BatchNormalization' from 'tensorflow.python.keras.layers' (/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/python/keras/layers/__init__.py)

Collapse
 
sakshat682 profile image
Sakshat Jain

I was facing the same problem so I reduce the tensorflow version to 2.4.1 and also reduce the python version to 3.7 (pip install tensorflow==2.4.1)

Collapse
 
sunilaleti profile image
Sunil Aleti

Itseems you have some dependencies issue, try running in google colab

Collapse
 
divyagattani profile image
divyagattani

I am trying it in google colab even though i am getting the same error
can you help how to solve this issue ?