TransVTSpotter icon indicating copy to clipboard operation
TransVTSpotter copied to clipboard

RuntimeError: median cannot be called with empty tensor

Open imMid-Star opened this issue 3 years ago • 2 comments

Traceback (most recent call last): File "main_track.py", line 363, in main(args) File "main_track.py", line 326, in main model, criterion, data_loader_train, optimizer, device, epoch, args.clip_max_norm) File "TransVTSpotter/engine_track.py", line 41, in train_one_epoch for _ in metric_logger.log_every(range(len(data_loader)), print_freq, header): File "TransVTSpotter/util/misc.py", line 260, in log_every meters=str(self), File "TransVTSpotter/util/misc.py", line 210, in str "{}: {}".format(name, str(meter)) File "TransVTSpotter/util/misc.py", line 109, in str median=self.median, File "TransVTSpotter/util/misc.py", line 88, in median return d.median().item() RuntimeError: median cannot be called with empty tensor

l think there might be something wrong with the datasets. My path of the datasets is as below: image

Is that right? Can u give me some examples of the structure of the datasets or the solution to this error? Thanks!

imMid-Star avatar Jan 26 '22 14:01 imMid-Star

The error is under these two Class: `class MetricLogger(object):

def __init__(self, delimiter="\t"):
    self.meters = defaultdict(SmoothedValue)
    self.delimiter = delimiter

def __str__(self):
    loss_str = []
    for name, meter in self.meters.items():
        loss_str.append(
            "{}: {}".format(name, str(meter)) 
        )
    return self.delimiter.join(loss_str)

class SmoothedValue(object):

@property
def median(self):
    d = torch.tensor(list(self.deque))
    return d.median().item()

def __str__(self):
    return self.fmt.format(
        median=self.median,
        avg=self.avg,
        global_avg=self.global_avg,
        max=self.max,
        value=self.value)`

imMid-Star avatar Jan 26 '22 15:01 imMid-Star

DUX(XW666V5DN)OH)_ KHOS Another problem is when l comment out the above error, the training just stay still. It seems that it fails to train. l'm a rookie and just start to learn the code. Please help me with these two problems, thanks!

imMid-Star avatar Jan 26 '22 18:01 imMid-Star