Skip to content

Commit 6de13e5

Browse files
committed
trying with paddlepaddle dataset splitting text
1 parent 975eaa8 commit 6de13e5

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

deep-learning-datasets-maker/split_rs_data.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,18 +318,17 @@ def run(self):
318318
# label_folder_path = str(self.dlg.lineEditLabels.text())
319319
image_folder_path = str(self.dlg.mQfwImages.filePath())
320320
label_folder_path = str(self.dlg.mQfwLabels.filePath())
321-
gggg = fn_ras.dataProvider().dataSourceUri()
322-
splitting(gggg, image_folder_path, "jpg", "JPEG", "", SplittingSize, SplittingSize, currentrasterlay)
321+
fn_ras_path = fn_ras.dataProvider().dataSourceUri()
322+
splitting(fn_ras_path, image_folder_path, "jpg", "JPEG", "", SplittingSize, SplittingSize, currentrasterlay)
323323
splitting(output, label_folder_path, "png", "PNG", "", SplittingSize, SplittingSize, currentrasterlay) #should be the same name of image. vector name if needed-> currentvectorlay
324324

325-
label_path = label_folder_path
326-
save_path = str(self.dlg.mQfwLabels_InSeg.filePath())
327-
# names = os.listdir(label_path)
328-
names = [f for f in os.listdir(label_path) if f.endswith('.png')]
325+
save_path_InSeg = str(self.dlg.mQfwLabels_InSeg.filePath())
326+
# names = os.listdir(label_folder_path)
327+
names = [f for f in os.listdir(label_folder_path) if f.endswith('.png')]
329328
if self.dlg.checkBoxInSeg.isChecked():
330329
for name in names:
331-
label = osp.join(label_path, name)
332-
saver = osp.join(save_path, name)
330+
label = osp.join(label_folder_path, name)
331+
saver = osp.join(save_path_InSeg, name)
333332
segMaskB2I(label, saver)
334333
else :
335334
feedback.pushInfo("Option instance segmentation is not selected")

deep-learning-datasets-maker/utils/paddlepaddle_split_dataset_list.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# import glob
1+
import glob
22
import os.path
33
# import argparse
44
import warnings
@@ -44,26 +44,28 @@
4444
# return parser.parse_args()
4545

4646

47-
# def get_files(path, format, postfix):
48-
# pattern = '*%s.%s' % (postfix, format)
47+
def get_files(dataset_root, format, postfix, image_folder_path):
48+
dataset_root = "/".join(image_folder_path.split("/")[:-2])
49+
pattern = '*%s.%s' % (postfix, format)
4950

50-
# search_files = os.path.join(path, pattern)
51-
# search_files2 = os.path.join(path, "*", pattern) # Include subdirectories
52-
# search_files3 = os.path.join(path, "*", "*", pattern) # Contains three levels of directories
51+
search_files = os.path.join(dataset_root, pattern)
52+
search_files2 = os.path.join(dataset_root, "*", pattern) # Include subdirectories
53+
search_files3 = os.path.join(dataset_root, "*", "*", pattern) # Contains three levels of directories
5354

54-
# filenames = glob.glob(search_files)
55-
# filenames2 = glob.glob(search_files2)
56-
# filenames3 = glob.glob(search_files3)
55+
filenames = glob.glob(search_files)
56+
filenames2 = glob.glob(search_files2)
57+
filenames3 = glob.glob(search_files3)
5758

58-
# filenames = filenames + filenames2 + filenames3
59+
filenames = filenames + filenames2 + filenames3
5960

60-
# return sorted(filenames)
61+
return sorted(filenames)
6162

6263

63-
def pp_generate_list(args):
64+
def pp_generate_list(args, image_folder_path, label_folder_path, Training_Set, Val_Set, Testing_Set):
6465
separator = "args.separator"
65-
dataset_root = "/".join(rasdir.split("/")[:-2])
66-
if sum(args.split) != 1.0:
66+
dataset_root = "/".join(image_folder_path.split("/")[:-2])
67+
all_sum_sets = Training_Set+Val_Set+Testing_Set
68+
if all_sum_sets != 1.0:
6769
raise ValueError("The sum of the division ratios must be 1")
6870

6971
file_list = os.path.join(dataset_root, 'labels.txt')

0 commit comments

Comments
 (0)