Closed mistaleee closed 5 years ago
I use this data augmentation class to dump augmented images:
class DumpSamples(DetectionAugmentation):
def __init__(self, debug_dir):
super().__init__()
self.debug_dir = debug_dir
def apply(self, input_record):
image = input_record["image"]
gt_bbox = input_record["gt_bbox"]
img = image.astype(np.uint8).transpose((1, 2, 0)).copy()
for box in gt_bbox:
cv2.rectangle(img, tuple(box[:2]), tuple(box[2:4]), color=(255, 0, 0),thickness=3)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
print("DEBUG: writing file {}".format(os.path.join(self.debug_dir,"{}.jpg".format(input_record['im_id']))))
if not os.path.exists(self.debug_dir):
os.makedirs(self.debug_dir)
cv2.imwrite(os.path.join(self.debug_dir,"{}.jpg".format(input_record['im_id'])),img)
Make sure you have debug/data_aug
directory. And then just append DumpSamples("debug/")
in configuration file to the end of transform
list. Also make sure you stop execution when you get enough examples.
Awesome, thanks for your code!
I put the class in the config file tridentnet_r101v2c4_c5_2x.py
and append the DumpSamples("debug/")
at the end of
metric_list = [rpn_acc_metric, rpn_l1_metric, box_acc_metric, box_l1_metric] return General, KvstoreParam, RpnParam, RoiParam, BboxParam, DatasetParam, \ ModelParam, OptimizeParam, TestParam, \ transform, data_name, label_name, metric_list, DumpSamples("debug/")
But I tells me that 'NameError: name 'DetectionAugmentation' is not defined'.
Is there anything I missed?
yeah, the class definition goes to core.detection_input
file OR should import DetectionAugmentation
from that file. If you put into core.detection_input
don't forget to import it later in configuration file (as others data augmentations classes:
from core.detection_input import DumpSamples
Thanks, I'll try it and come back to you.
yes, it worked. Thanks!
Hi there,
is there a possibility to visualize the batches from the input layer to check if the batches are korrekt?
Thanks for any hints.