updates
This commit is contained in:
parent
809667404f
commit
db515a4535
|
@ -172,7 +172,7 @@ class YOLOLayer(nn.Module):
|
||||||
lh = k * MSELoss(h[mask], th[mask])
|
lh = k * MSELoss(h[mask], th[mask])
|
||||||
|
|
||||||
# lconf = k * BCEWithLogitsLoss(pred_conf[mask], mask[mask].float())
|
# lconf = k * BCEWithLogitsLoss(pred_conf[mask], mask[mask].float())
|
||||||
lconf = (k * 1) * BCEWithLogitsLoss(pred_conf, mask.float())
|
lconf = (k * 5) * BCEWithLogitsLoss(pred_conf, mask.float())
|
||||||
|
|
||||||
lcls = (k / 10) * CrossEntropyLoss(pred_cls[mask], torch.argmax(tcls, 1))
|
lcls = (k / 10) * CrossEntropyLoss(pred_cls[mask], torch.argmax(tcls, 1))
|
||||||
# lcls = (k * 10) * BCEWithLogitsLoss(pred_cls[mask], tcls.float())
|
# lcls = (k * 10) * BCEWithLogitsLoss(pred_cls[mask], tcls.float())
|
||||||
|
|
11
train.py
11
train.py
|
@ -125,7 +125,8 @@ def main(opt):
|
||||||
g['lr'] = lr
|
g['lr'] = lr
|
||||||
|
|
||||||
# Compute loss, compute gradient, update parameters
|
# Compute loss, compute gradient, update parameters
|
||||||
loss = model(imgs.to(device), targets, requestPrecision=False)
|
precision_per_batch = False
|
||||||
|
loss = model(imgs.to(device), targets, requestPrecision=precision_per_batch)
|
||||||
loss.backward()
|
loss.backward()
|
||||||
|
|
||||||
# accumulated_batches = 1 # accumulate gradient for 4 batches before stepping optimizer
|
# accumulated_batches = 1 # accumulate gradient for 4 batches before stepping optimizer
|
||||||
|
@ -133,13 +134,15 @@ def main(opt):
|
||||||
optimizer.step()
|
optimizer.step()
|
||||||
optimizer.zero_grad()
|
optimizer.zero_grad()
|
||||||
|
|
||||||
# Compute running epoch-means of tracked metrics
|
# Running epoch-means of tracked metrics
|
||||||
ui += 1
|
ui += 1
|
||||||
metrics += model.losses['metrics']
|
|
||||||
TP, FP, FN = metrics
|
|
||||||
for key, val in model.losses.items():
|
for key, val in model.losses.items():
|
||||||
rloss[key] = (rloss[key] * ui + val) / (ui + 1)
|
rloss[key] = (rloss[key] * ui + val) / (ui + 1)
|
||||||
|
|
||||||
|
if precision_per_batch:
|
||||||
|
TP, FP, FN = metrics
|
||||||
|
metrics += model.losses['metrics']
|
||||||
|
|
||||||
# Precision
|
# Precision
|
||||||
precision = TP / (TP + FP)
|
precision = TP / (TP + FP)
|
||||||
k = (TP + FP) > 0
|
k = (TP + FP) > 0
|
||||||
|
|
|
@ -438,7 +438,7 @@ def plot_results():
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
plt.figure(figsize=(16, 8))
|
plt.figure(figsize=(16, 8))
|
||||||
s = ['X', 'Y', 'Width', 'Height', 'Objectness', 'Classification', 'Total Loss', 'Precision', 'Recall', 'mAP']
|
s = ['X', 'Y', 'Width', 'Height', 'Objectness', 'Classification', 'Total Loss', 'Precision', 'Recall', 'mAP']
|
||||||
for f in ('results5.txt', 'results_new.txt', 'results3.txt',
|
for f in ('results_d5.txt', 'results_d10.txt', 'results_new.txt',
|
||||||
):
|
):
|
||||||
results = np.loadtxt(f, usecols=[2, 3, 4, 5, 6, 7, 8, 9, 10]).T # column 16 is mAP
|
results = np.loadtxt(f, usecols=[2, 3, 4, 5, 6, 7, 8, 9, 10]).T # column 16 is mAP
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
|
|
Loading…
Reference in New Issue