comment updates
This commit is contained in:
1 parent
ea34f848a6
commit
140d84cca1
2 files changed
+4
-7
No files matched your search
@@ -152,13 +152,13 @@ def train(hyp):
|
|||||||
model, optimizer = amp.initialize(model, optimizer, opt_level='O1', verbosity=0)
|
model, optimizer = amp.initialize(model, optimizer, opt_level='O1', verbosity=0)
|
||||||
|
|
||||||
# Distributed training
|
# Distributed training
|
||||||
if device.type != 'cpu' and torch.cuda.device_count() > 1 and torch.distributed.is_available():
|
if device.type != 'cpu' and torch.cuda.device_count() > 1 and dist.is_available():
|
||||||
dist.init_process_group(backend='nccl', # distributed backend
|
dist.init_process_group(backend='nccl', # distributed backend
|
||||||
init_method='tcp://127.0.0.1:9999', # init method
|
init_method='tcp://127.0.0.1:9999', # init method
|
||||||
world_size=1, # number of nodes
|
world_size=1, # number of nodes
|
||||||
rank=0) # node rank
|
rank=0) # node rank
|
||||||
|
# model = torch.nn.SyncBatchNorm.convert_sync_batchnorm(model).to(device) # requires world_size > 1
|
||||||
model = torch.nn.parallel.DistributedDataParallel(model)
|
model = torch.nn.parallel.DistributedDataParallel(model)
|
||||||
# pip install torch==1.4.0+cu100 torchvision==0.5.0+cu100 -f https://download.pytorch.org/whl/torch_stable.html
|
|
||||||
|
|
||||||
# Trainloader
|
# Trainloader
|
||||||
dataloader, dataset = create_dataloader(train_path, imgsz, batch_size, gs, opt,
|
dataloader, dataset = create_dataloader(train_path, imgsz, batch_size, gs, opt,
|
||||||
|
|||||||
+2
-5
@@ -503,6 +503,7 @@ def build_targets(p, targets, model):
|
|||||||
off = torch.tensor([[1, 0], [0, 1], [-1, 0], [0, -1]], device=targets.device).float() # overlap offsets
|
off = torch.tensor([[1, 0], [0, 1], [-1, 0], [0, -1]], device=targets.device).float() # overlap offsets
|
||||||
at = torch.arange(na).view(na, 1).repeat(1, nt) # anchor tensor, same as .repeat_interleave(nt)
|
at = torch.arange(na).view(na, 1).repeat(1, nt) # anchor tensor, same as .repeat_interleave(nt)
|
||||||
|
|
||||||
|
g = 0.5 # offset
|
||||||
style = 'rect4'
|
style = 'rect4'
|
||||||
for i in range(det.nl):
|
for i in range(det.nl):
|
||||||
anchors = det.anchors[i]
|
anchors = det.anchors[i]
|
||||||
@@ -517,7 +518,6 @@ def build_targets(p, targets, model):
|
|||||||
a, t = at[j], t.repeat(na, 1, 1)[j] # filter
|
a, t = at[j], t.repeat(na, 1, 1)[j] # filter
|
||||||
|
|
||||||
# overlaps
|
# overlaps
|
||||||
g = 0.5 # offset
|
|
||||||
gxy = t[:, 2:4] # grid xy
|
gxy = t[:, 2:4] # grid xy
|
||||||
z = torch.zeros_like(gxy)
|
z = torch.zeros_like(gxy)
|
||||||
if style == 'rect2':
|
if style == 'rect2':
|
||||||
@@ -878,10 +878,7 @@ def fitness(x):
|
|||||||
|
|
||||||
|
|
||||||
def output_to_target(output, width, height):
|
def output_to_target(output, width, height):
|
||||||
"""
|
# Convert model output to target format [batch_id, class_id, x, y, w, h, conf]
|
||||||
Convert a YOLO model output to target format
|
|
||||||
[batch_id, class_id, x, y, w, h, conf]
|
|
||||||
"""
|
|
||||||
if isinstance(output, torch.Tensor):
|
if isinstance(output, torch.Tensor):
|
||||||
output = output.cpu().numpy()
|
output = output.cpu().numpy()
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user