This commit is contained in:
mszmyd 2024-05-04 23:42:37 +02:00
parent 9dafc8c895
commit 9ac4b3ec4e
2 changed files with 8 additions and 7 deletions

View File

@ -1,6 +1,5 @@
.PHONY: download-dataset sobel-dataset
download-dataset:
python3 ./file_manager/data_manager.py --download

View File

@ -33,16 +33,18 @@ class DataManager:
if not os.path.exists(main_path):
os.makedirs(main_path)
ZipFile(file_name).extractall(full_path_to_extract)
shutil.move("data/test/test",
full_path_to_extract, copy_function=shutil.copytree)
# shutil.move("data/test/test",
# full_path_to_extract, copy_function=shutil.copytree)
shutil.move(full_path_to_extract / old_path / "train",
full_path_to_extract / "train", copy_function=shutil.copytree)
shutil.move(full_path_to_extract / old_path / "valid",
full_path_to_extract / "valid", copy_function=shutil.copytree)
shutil.rmtree(
full_path_to_extract / "New Plant Diseases Dataset(Augmented)")
full_path_to_extract / "New Plant Diseases Dataset(Augmented)"
)
shutil.rmtree(
"data/Detection-of-plant-diseases/data/original dataset/test")
full_path_to_extract / "new plant diseases dataset(augmented)"
)
def write_image(self, image, path):
os.makedirs(path.rsplit('/', 1)[0], exist_ok=True)
@ -51,7 +53,7 @@ class DataManager:
def resize_dataset(self, source_dataset_name, width, height):
dataset_name = "resized_dataset"
if not os.path.exists(main_path / dataset_name):
for file in glob.glob(path_to_train_and_valid % source_dataset_name, recursive=True):
for file in glob.glob(str(path_to_train_and_valid) % source_dataset_name, recursive=True):
path_to_file = file.replace("\\", "/")
image = cv2.imread(path_to_file)
image = cv2.resize(image, (width, height))
@ -62,7 +64,7 @@ class DataManager:
def sobelx(self, source_dataset_name):
dataset_name = "sobel_dataset"
if not os.path.exists(main_path / dataset_name):
for file in glob.glob(path_to_train_and_valid % source_dataset_name, recursive=True):
for file in glob.glob(str(path_to_train_and_valid) % source_dataset_name, recursive=True):
path_to_file = file.replace("\\", "/")
image = cv2.imread(path_to_file)
sobel = cv2.Sobel(image, cv2.CV_64F, 1, 0, ksize=5)