Эх сурвалжийг харах

set num_workers to 0 if negtive smaples are added

will-jl944 4 жил өмнө
parent
commit
0bf3ffe452

+ 2 - 1
paddlex/cv/datasets/coco.py

@@ -196,8 +196,9 @@ class CocoDetection(VOCDetection):
             logging.error(
                 "No coco record found in %s' % (ann_file)", exit=True)
         self.pos_num = len(self.file_list)
-        if self.allow_empty:
+        if self.allow_empty and neg_file_list:
             self.file_list += self._sample_empty(neg_file_list)
+            self.num_workers = 0
         logging.info(
             "{} samples in file {}, including {} positive samples and {} negative samples.".
             format(

+ 6 - 2
paddlex/cv/datasets/voc.py

@@ -290,8 +290,9 @@ class VOCDetection(Dataset):
             logging.error(
                 "No voc record found in %s' % (file_list)", exit=True)
         self.pos_num = len(self.file_list)
-        if self.allow_empty:
+        if self.allow_empty and neg_file_list:
             self.file_list += self._sample_empty(neg_file_list)
+            self.num_workers = 0
         logging.info(
             "{} samples in file {}, including {} positive samples and {} negative samples.".
             format(
@@ -423,7 +424,10 @@ class VOCDetection(Dataset):
                 **
                 label_info
             })
-        self.file_list += self._sample_empty(neg_file_list)
+        if neg_file_list:
+            self.allow_empty = True
+            self.file_list += self._sample_empty(neg_file_list)
+            self.num_workers = 0
         logging.info(
             "{} negative samples added. Dataset contains {} positive samples and {} negative samples.".
             format(