print("trainlist: ", len(train_img_list)) print("vallist: ", len(val_img_list)) # make Dataset voc_classes = [ 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor' ] input_size = 300 * scale # 画像のinputサイズを300×300にする ## DatasetTransformを適応 transform = DatasetTransform(input_size) transform_anno = Anno_xml2list(voc_classes) # Dataloaderに入れるデータセットファイル。 # ゲットで叩くと画像とGTを前処理して出力してくれる。 train_dataset = VOCDataset(train_img_list, train_anno_list, phase="train", transform=transform, transform_anno=transform_anno) val_dataset = VOCDataset(val_img_list, val_anno_list, phase="val", transform=DatasetTransform(input_size, color_mean), transform_anno=Anno_xml2list(voc_classes)) batch_size = 32
vocpath = "../VOCdevkit/VOC2012" train_img_list2, train_anno_list2, _, _ = make_datapath_list(vocpath, cls="person", VOC2012=True) train_img_list.extend(train_img_list2) train_anno_list.extend(train_anno_list2) # make Dataset voc_classes = ['person'] color_mean = (104, 117, 123) # (BGR)の色の平均値 print("trainlist: ", len(train_img_list)) print("vallist: ", len(val_img_list)) ## DatasetTransformを適応 transform = DatasetTransform(input_size, color_mean) transform_anno = Anno_xml2list(voc_classes) train_dataset = VOCDataset(train_img_list, train_anno_list, phase = "train", transform=transform, transform_anno = transform_anno) val_dataset = VOCDataset(val_img_list, val_anno_list, phase="val", transform=DatasetTransform( input_size, color_mean), transform_anno=Anno_xml2list(voc_classes)) train_dataloader = data.DataLoader( train_dataset, batch_size=batch_size, shuffle=True, collate_fn=od_collate_fn, num_workers=8) val_dataloader = data.DataLoader( val_dataset, batch_size=batch_size, shuffle=False, collate_fn=od_collate_fn, num_workers=8) dataloaders_dict = {"train": train_dataloader, "val": val_dataloader} # In[4]:
val_img_list[0] # In[6]: class_names = [ 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor' ] color_mean = (104, 117, 123) # (BGR)???F???????l input_size = 300 # ??????input?T?C?Y??300?~300?????? ## DatasetTransform???K?? transform = DatasetTransform(input_size, color_mean) transform_anno = Anno_xml2list(class_names) # In[7]: val_dataset = VOCDataset(val_img_list, val_anno_list, phase="val", transform=DatasetTransform(input_size, color_mean), transform_anno=Anno_xml2list(class_names)) # In[8]: val_dataloader = data.DataLoader(val_dataset, batch_size=1, shuffle=False, collate_fn=od_collate_fn,