I'm trying to change background of image using pixellib library but am encountering problem. I'm getting this error:
Traceback (most recent call last): File "C:/Users/FEd/PycharmProjects/pythonProject/PIXEL.py", line 16, in change_bg.load_pascalvoc_model("deeplabv3_xception_tf_dim_ordering_tf_kernels.h5") File "C:\Users\FEd\PycharmProjects\pythonProject\venv\lib\site-packages\pixellib\tune_bg.py", line 43, in load_pascalvoc_model self.model.load_weights(model_path) File "C:\Users\FEd\PycharmProjects\pythonProject\venv\lib\site-packages\tensorflow\python\keras\engine\training.py", line 2319, in load_weights with h5py.File(filepath, 'r') as f: File "C:\Users\FEd\PycharmProjects\pythonProject\venv\lib\site-packages\h5py_hl\files.py", line 427, in init swmr=swmr) File "C:\Users\FEd\PycharmProjects\pythonProject\venv\lib\site-packages\h5py_hl\files.py", line 190, in make_fid fid = h5f.open(name, flags, fapl=fapl) File "h5py_objects.pyx", line 54, in h5py._objects.with_phil.wrapper File "h5py_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py\h5f.pyx", line 96, in h5py.h5f.open OSError: Unable to open file (unable to open file: name = 'deeplabv3_xception_tf_dim_ordering_tf_kernels.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
Have used os.getcwd
to get the current working directory but still am getting same error. Have found this link states i should use os.getcwd
to get current working directory
Code
import pixellib
from pixellib.tune_bg import alter_bg
import os
my_dir = os.getcwd()
print(my_dir)
m1 = my_dir+"\sample.jpg"
m2 = my_dir+"\change_background.jpg"
print(m1)
print(m2)
change_bg = alter_bg()
change_bg.load_pascalvoc_model("deeplabv3_xception_tf_dim_ordering_tf_kernels.h5")
change_bg.change_bg_img(f_image_path =m1, b_image_path = m2, output_image_name="new_img.jpg")
print("done")