37
37
import os
38
38
import os .path as osp
39
39
from .utils import *
40
+ import argparse
40
41
41
42
42
43
class SplitRSData :
@@ -333,9 +334,49 @@ def run(self):
333
334
else :
334
335
feedback .pushInfo ("Option instance segmentation is not selected" )
335
336
336
- # if self.dlg.checkBoxPaddle.isChecked():
337
- # generate_list()
338
- # else :
339
- # feedback.pushInfo("Option instance segmentation is not selected")
340
-
341
- iface .messageBar ().pushMessage ("You will find the dataset in " + image_folder_path , level = Qgis .Success , duration = 5 )
337
+ if self .dlg .checkBoxPaddle .isChecked ():
338
+ dataset_path = "/" .join (image_folder_path .split ("/" )[:- 1 ])
339
+ Training_Set = self .dlg .mOpacityWidget_Training .opacity ()
340
+ Val_Set = self .dlg .mOpacityWidget_Validating .opacity ()
341
+ Testing_Set = self .dlg .mOpacityWidget_Testing .opacity ()
342
+ def parse_args (dataset_path ,image_folder_path , label_folder_path , Training_Set , Val_Set , Testing_Set ):
343
+ parser = argparse .ArgumentParser (
344
+ description =
345
+ 'A tool for proportionally randomizing dataset to produce file lists.' )
346
+ parser .add_argument ('dataset_root' , help = 'the dataset root path' , type = str , default = dataset_path )
347
+ parser .add_argument (
348
+ 'images_dir_name' , help = 'the directory name of images' , type = str , default = image_folder_path )
349
+ parser .add_argument (
350
+ 'labels_dir_name' , help = 'the directory name of labels' , type = str , default = label_folder_path )
351
+ parser .add_argument (
352
+ '--split' , help = '' , nargs = 3 , type = float , default = [Training_Set , Val_Set , Testing_Set ])
353
+ parser .add_argument (
354
+ '--label_class' ,
355
+ help = 'label class names' ,
356
+ type = str ,
357
+ nargs = '*' ,
358
+ default = ['__background__' , '__foreground__' ])
359
+ parser .add_argument (
360
+ '--separator' ,
361
+ dest = 'separator' ,
362
+ help = 'file list separator' ,
363
+ default = " " ,
364
+ type = str )
365
+ parser .add_argument (
366
+ '--format' ,
367
+ help = 'data format of images and labels, e.g. jpg, tif or png.' ,
368
+ type = str ,
369
+ nargs = 2 ,
370
+ default = ['jpg' , 'png' ])
371
+ parser .add_argument (
372
+ '--postfix' ,
373
+ help = 'postfix of images or labels' ,
374
+ type = str ,
375
+ nargs = 2 ,
376
+ default = ['' , '' ])
377
+
378
+ return parser .parse_args ()
379
+ args = parse_args (dataset_path ,image_folder_path , label_folder_path , Training_Set , Val_Set , Testing_Set )
380
+ generate_list (args )
381
+
382
+ iface .messageBar ().pushMessage ("You will find the dataset in " + dataset_path , level = Qgis .Success , duration = 5 )
0 commit comments