From 50a888b06498c9c41ed9989169eff911f069dd6a Mon Sep 17 00:00:00 2001 From: elsayeaa <64815927+elsayeaa@users.noreply.github.com> Date: Sat, 19 Dec 2020 11:58:46 +0200 Subject: [PATCH 1/5] Fixing the FileNotFound error --- src/image_alignment.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/image_alignment.py b/src/image_alignment.py index 6bab7f9..bd3aa71 100644 --- a/src/image_alignment.py +++ b/src/image_alignment.py @@ -1,5 +1,5 @@ import sys - +import os.path import cv2 import numpy as np import image_shapes as shapes @@ -90,6 +90,8 @@ def align_images(petal_img, vein_img, raw_vein=True): def main(): if (len(sys.argv) < 3): raise ValueError("Usage: image_alignment.py ") + if not (os.path.exists(sys.argv[1]) and os.path.exists(sys.argv[2])): + raise ValueError("One of the image files doesn't Exists. Please review your file paths \n Usage: image.alignment.py ") petal_image = cv2.imread(sys.argv[1]) vein_image = cv2.imread(sys.argv[2], cv2.IMREAD_GRAYSCALE) (petal_shape, vein_aligned) = align_images(petal_image, vein_image) From e1c9fbd72334ca17eeb150fc9ba66f9540b471da Mon Sep 17 00:00:00 2001 From: elsayeaa <64815927+elsayeaa@users.noreply.github.com> Date: Sat, 19 Dec 2020 12:01:40 +0200 Subject: [PATCH 2/5] Handling FileNotFound in PCA file --- src/principal_component.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/principal_component.py b/src/principal_component.py index 8834bf3..7eff42c 100644 --- a/src/principal_component.py +++ b/src/principal_component.py @@ -1,5 +1,6 @@ import sys import cv2 +import os.path import matplotlib.pyplot as plt import numpy as np import image_shapes as shapes @@ -59,6 +60,8 @@ def create_point_cloud(image): if len(sys.argv) < 2: print("Standalone usage: python principal_component.py input_filename.jpg [output_filename.jpg]") sys.exit(1) + if not os.path.exists(sys.argv[1]): + raise ValueError("One of the image files doesn't Exists. Please review your file paths") petal_image = cv2.imread(sys.argv[1]) petal_shape = shapes.get_petal_shape(petal_image) result = pca_to_grey(petal_image, petal_shape, True) @@ -66,4 +69,4 @@ def create_point_cloud(image): cv2.imwrite(sys.argv[2], result) else: io.imshow(result) - io.show() \ No newline at end of file + io.show() From d5d951d77553e5bd0b2a45698ebd8ed35c869dbf Mon Sep 17 00:00:00 2001 From: elsayeaa <64815927+elsayeaa@users.noreply.github.com> Date: Sat, 19 Dec 2020 12:03:43 +0200 Subject: [PATCH 3/5] Handling FileNotFound error in spot_detection.py --- src/spot_detection.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/spot_detection.py b/src/spot_detection.py index 1df4367..ffc3712 100644 --- a/src/spot_detection.py +++ b/src/spot_detection.py @@ -1,5 +1,5 @@ import sys - +import os.path import matplotlib.pyplot as plt import numpy as np from sklearn.mixture import BayesianGaussianMixture @@ -56,6 +56,8 @@ def overlay_spotting_events_on_image(image, model): plt.show() def main(): + if not os.path.exists(sys.argv[1]): + raise ValueError("The image files doesn't Exists. Please review your file path") image = imread(sys.argv[1]) image = iu.resize_image(image, 400) From 13738e75beee5a4c20f0453c092214378116d345 Mon Sep 17 00:00:00 2001 From: elsayeaa <64815927+elsayeaa@users.noreply.github.com> Date: Sat, 19 Dec 2020 12:05:06 +0200 Subject: [PATCH 4/5] Fixing FileNotFound error in imgrab.py --- src/imgrab.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/imgrab.py b/src/imgrab.py index 7c9b5bf..4067ac2 100644 --- a/src/imgrab.py +++ b/src/imgrab.py @@ -1,10 +1,13 @@ import principal_component as p import sys +import os.path import cv2 from skimage import io def main(): + if not os.path.exists(sys.argv[1]): + raise ValueError("The image files doesn't Exists. Please review your file path") image = cv2.imread(sys.argv[1]) im = vein_image = cv2.imread(sys.argv[1], cv2.IMREAD_GRAYSCALE) i = p.pca_to_grey(image) From dcb887bd8fb14c15f217e2680d9b4b8308e98458 Mon Sep 17 00:00:00 2001 From: elsayeaa <64815927+elsayeaa@users.noreply.github.com> Date: Sat, 19 Dec 2020 12:06:48 +0200 Subject: [PATCH 5/5] Fix FileNotFound error in data_processing.py --- src/data_processing.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/data_processing.py b/src/data_processing.py index daa4a7a..3cd9e2d 100644 --- a/src/data_processing.py +++ b/src/data_processing.py @@ -37,6 +37,8 @@ def store_data(filenames, input_path, output_path): print(error_message) def main(): + if not os.path.exists(sys.argv[1]): + raise ValueError("The image files doesn't Exists. Please review your file path") dir = sys.argv[1] input_filepaths = get_file_names(dir) output_filepath = sys.argv[2]