It wasn't clear to me what to do to deblur an image using the provided pre-trained model. I'm still fairly new to coding and computer vision. Here's what I had to do to make it work.
Update the Tensorflow code for version one compatibility. That meant changing the code in all of the python files in the DeblurGAN-tf folder.
I updated whichever tf modules were stated as missing in the error messages.
From:
tf.placeholder
To:
tf.compat.v1.placeholder
I also added the following code in whichever file used tf.placeholder. I placed it at the top after the imports section. Apparently, the placeholder doesn't work with eager execution.
tf.compat.v1.disable_eager_execution()
I added an empty result and model folder in the DeblurGAN-tf directory. The default settings are stated in the "main.py" file from line 20 to 28.
You can add folders named after the ones stated in the default settings.
You can change the default folder names in the "main.py" file.
You can include the path arguments in your command-line interface command.
--train_Sharp_path, --train_Blur_path, --test_Sharp_path, --test_Blur_path, --vgg_path, --patch_size, --result_path, --model_path
I extracted the pre-trained model files into the model folder. The command in the docs to extract the tar file didn't work. It ended up creating a new tar file. Instead, I double-clicked on the tar file to manually extract it. The And, I referenced the model file path in the command-line interface as ./model/DeblurrGAN_last without the extension.
Mac OS: Stop the .DS_Store file from being loaded in the image folder. Add the following code to the image_loader function in theutil.py file in the DeblurGAN-tf folder.
FROM:
def image_loader(image_path, load_x, load_y, is_train = True):
imgs = sorted(os.listdir(image_path))
img_list = []
for ele in imgs:
img = Image.open(os.path.join(image_path, ele))
if is_train:
img = img.resize((load_x, load_y), Image.BICUBIC)
img_list.append(np.array(img))
return img_list
ADD:
for name in imgs:
if name.endswith("DS_Store"):
imgs.remove(name)
TO:
def image_loader(image_path, load_x, load_y, is_train = True):
imgs = sorted(os.listdir(image_path))
for name in imgs:
print(name)
if name.endswith("DS_Store"):
imgs.remove(name)
img_list = []
for ele in imgs:
img = Image.open(os.path.join(image_path, ele))
if is_train:
img = img.resize((load_x, load_y), Image.BICUBIC)
img_list.append(np.array(img))
return img_list
It wasn't clear to me what to do to deblur an image using the provided pre-trained model. I'm still fairly new to coding and computer vision. Here's what I had to do to make it work.
DeblurGAN-tf
folder.I updated whichever
tf
modules were stated as missing in the error messages.From:
To:
I also added the following code in whichever file used
tf.placeholder
. I placed it at the top after the imports section. Apparently, the placeholder doesn't work with eager execution.I added an empty
result
andmodel
folder in theDeblurGAN-tf
directory. The default settings are stated in the "main.py" file from line 20 to 28.--train_Sharp_path
,--train_Blur_path
,--test_Sharp_path
,--test_Blur_path
,--vgg_path
,--patch_size
,--result_path
,--model_path
I extracted the pre-trained model files into the
model
folder. The command in the docs to extract the tar file didn't work. It ended up creating a new tar file. Instead, I double-clicked on the tar file to manually extract it. The And, I referenced the model file path in the command-line interface as./model/DeblurrGAN_last
without the extension.Mac OS: Stop the
.DS_Store
file from being loaded in the image folder. Add the following code to theimage_loader
function in theutil.py
file in theDeblurGAN-tf
folder.FROM:
ADD:
TO: