Skip to content

Commit

Permalink
fix name bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wz authored and wz committed Nov 26, 2020
1 parent b36ad21 commit 540cb78
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
22 changes: 11 additions & 11 deletions pytorch_object_detection/yolov3_spp/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,19 @@ def train(hyp):

# dataset
# 训练集的图像尺寸指定为multi_scale_range中最大的尺寸
train_dataset = LoadImageAndLabels(train_path, imgsz_train, batch_size,
augment=True,
hyp=hyp, # augmentation hyperparameters
rect=opt.rect, # rectangular training
cache_images=opt.cache_images,
single_cls=opt.single_cls)
train_dataset = LoadImagesAndLabels(train_path, imgsz_train, batch_size,
augment=True,
hyp=hyp, # augmentation hyperparameters
rect=opt.rect, # rectangular training
cache_images=opt.cache_images,
single_cls=opt.single_cls)

# 验证集的图像尺寸指定为img_size(512)
val_dataset = LoadImageAndLabels(test_path, imgsz_test, batch_size,
hyp=hyp,
rect=True, # 将每个batch的图像调整到合适大小,可减少运算量(并不是512x512标准尺寸)
cache_images=opt.cache_images,
single_cls=opt.single_cls)
val_dataset = LoadImagesAndLabels(test_path, imgsz_test, batch_size,
hyp=hyp,
rect=True, # 将每个batch的图像调整到合适大小,可减少运算量(并不是512x512标准尺寸)
cache_images=opt.cache_images,
single_cls=opt.single_cls)

# dataloader
nw = min([os.cpu_count(), batch_size if batch_size > 1 else 0, 8]) # number of workers
Expand Down
24 changes: 12 additions & 12 deletions pytorch_object_detection/yolov3_spp/train_multi_GPU.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,19 @@ def main(opt, hyp):
# 训练集的图像尺寸指定为multi_scale_range中最大的尺寸
# Make sure only the first process in DDP process the dataset first, and the following others can use the cache.
with torch_distributed_zero_first(opt.rank):
train_dataset = LoadImageAndLabels(train_path, imgsz_train, batch_size,
augment=True,
hyp=hyp, # augmentation hyperparameters
rect=opt.rect, # rectangular training
cache_images=opt.cache_images,
single_cls=opt.single_cls,
rank=opt.rank)
train_dataset = LoadImagesAndLabels(train_path, imgsz_train, batch_size,
augment=True,
hyp=hyp, # augmentation hyperparameters
rect=opt.rect, # rectangular training
cache_images=opt.cache_images,
single_cls=opt.single_cls,
rank=opt.rank)
# 验证集的图像尺寸指定为img_size(512)
val_dataset = LoadImageAndLabels(test_path, imgsz_test, batch_size,
hyp=hyp,
cache_images=opt.cache_images,
single_cls=opt.single_cls,
rank=opt.rank)
val_dataset = LoadImagesAndLabels(test_path, imgsz_test, batch_size,
hyp=hyp,
cache_images=opt.cache_images,
single_cls=opt.single_cls,
rank=opt.rank)

# 给每个rank对应的进程分配训练的样本索引
train_sampler = torch.utils.data.distributed.DistributedSampler(train_dataset)
Expand Down
2 changes: 1 addition & 1 deletion pytorch_object_detection/yolov3_spp/utils/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def exif_size(img):
return s


class LoadImageAndLabels(Dataset): # for training/testing
class LoadImagesAndLabels(Dataset): # for training/testing
def __init__(self,
path, # 指向data/my_train_data.txt路径或data/my_val_data.txt路径
# 这里设置的是预处理后输出的图片尺寸
Expand Down

0 comments on commit 540cb78

Please sign in to comment.