Integer printout (#2450)
Browse files* Integer printout
* test.py 'Labels'
* Update train.py
- test.py +2 -2
- train.py +1 -1
- utils/torch_utils.py +1 -1
test.py
CHANGED
@@ -93,7 +93,7 @@ def test(data,
|
|
93 |
confusion_matrix = ConfusionMatrix(nc=nc)
|
94 |
names = {k: v for k, v in enumerate(model.names if hasattr(model, 'names') else model.module.names)}
|
95 |
coco91class = coco80_to_coco91_class()
|
96 |
-
s = ('%20s' + '%12s' * 6) % ('Class', 'Images', '
|
97 |
p, r, f1, mp, mr, map50, map, t0, t1 = 0., 0., 0., 0., 0., 0., 0., 0., 0.
|
98 |
loss = torch.zeros(3, device=device)
|
99 |
jdict, stats, ap, ap_class, wandb_images = [], [], [], [], []
|
@@ -223,7 +223,7 @@ def test(data,
|
|
223 |
nt = torch.zeros(1)
|
224 |
|
225 |
# Print results
|
226 |
-
pf = '%20s' + '%12.3g' *
|
227 |
print(pf % ('all', seen, nt.sum(), mp, mr, map50, map))
|
228 |
|
229 |
# Print results per class
|
|
|
93 |
confusion_matrix = ConfusionMatrix(nc=nc)
|
94 |
names = {k: v for k, v in enumerate(model.names if hasattr(model, 'names') else model.module.names)}
|
95 |
coco91class = coco80_to_coco91_class()
|
96 |
+
s = ('%20s' + '%12s' * 6) % ('Class', 'Images', 'Labels', 'P', 'R', '[email protected]', '[email protected]:.95')
|
97 |
p, r, f1, mp, mr, map50, map, t0, t1 = 0., 0., 0., 0., 0., 0., 0., 0., 0.
|
98 |
loss = torch.zeros(3, device=device)
|
99 |
jdict, stats, ap, ap_class, wandb_images = [], [], [], [], []
|
|
|
223 |
nt = torch.zeros(1)
|
224 |
|
225 |
# Print results
|
226 |
+
pf = '%20s' + '%12i' * 2 + '%12.3g' * 4 # print format
|
227 |
print(pf % ('all', seen, nt.sum(), mp, mr, map50, map))
|
228 |
|
229 |
# Print results per class
|
train.py
CHANGED
@@ -264,7 +264,7 @@ def train(hyp, opt, device, tb_writer=None, wandb=None):
|
|
264 |
if rank != -1:
|
265 |
dataloader.sampler.set_epoch(epoch)
|
266 |
pbar = enumerate(dataloader)
|
267 |
-
logger.info(('\n' + '%10s' * 8) % ('Epoch', 'gpu_mem', 'box', 'obj', 'cls', 'total', '
|
268 |
if rank in [-1, 0]:
|
269 |
pbar = tqdm(pbar, total=nb) # progress bar
|
270 |
optimizer.zero_grad()
|
|
|
264 |
if rank != -1:
|
265 |
dataloader.sampler.set_epoch(epoch)
|
266 |
pbar = enumerate(dataloader)
|
267 |
+
logger.info(('\n' + '%10s' * 8) % ('Epoch', 'gpu_mem', 'box', 'obj', 'cls', 'total', 'labels', 'img_size'))
|
268 |
if rank in [-1, 0]:
|
269 |
pbar = tqdm(pbar, total=nb) # progress bar
|
270 |
optimizer.zero_grad()
|
utils/torch_utils.py
CHANGED
@@ -120,7 +120,7 @@ def profile(x, ops, n=100, device=None):
|
|
120 |
s_in = tuple(x.shape) if isinstance(x, torch.Tensor) else 'list'
|
121 |
s_out = tuple(y.shape) if isinstance(y, torch.Tensor) else 'list'
|
122 |
p = sum(list(x.numel() for x in m.parameters())) if isinstance(m, nn.Module) else 0 # parameters
|
123 |
-
print(f'{p:12
|
124 |
|
125 |
|
126 |
def is_parallel(model):
|
|
|
120 |
s_in = tuple(x.shape) if isinstance(x, torch.Tensor) else 'list'
|
121 |
s_out = tuple(y.shape) if isinstance(y, torch.Tensor) else 'list'
|
122 |
p = sum(list(x.numel() for x in m.parameters())) if isinstance(m, nn.Module) else 0 # parameters
|
123 |
+
print(f'{p:12}{flops:12.4g}{dtf:16.4g}{dtb:16.4g}{str(s_in):>24s}{str(s_out):>24s}')
|
124 |
|
125 |
|
126 |
def is_parallel(model):
|