Преглед на файлове

Update run-once lines (#2058)

5.0
Glenn Jocher GitHub преди 3 години
родител
ревизия
2a835c79a9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
променени са 2 файла, в които са добавени 4 реда и са изтрити 4 реда
  1. +2
    -2
      detect.py
  2. +2
    -2
      test.py

+ 2
- 2
detect.py Целия файл

colors = [[random.randint(0, 255) for _ in range(3)] for _ in names] colors = [[random.randint(0, 255) for _ in range(3)] for _ in names]


# Run inference # Run inference
if device.type != 'cpu':
model(torch.zeros(1, 3, imgsz, imgsz).to(device).type_as(next(model.parameters()))) # run once
t0 = time.time() t0 = time.time()
img = torch.zeros((1, 3, imgsz, imgsz), device=device) # init img
_ = model(img.half() if half else img) if device.type != 'cpu' else None # run once
for path, img, im0s, vid_cap in dataset: for path, img, im0s, vid_cap in dataset:
img = torch.from_numpy(img).to(device) img = torch.from_numpy(img).to(device)
img = img.half() if half else img.float() # uint8 to fp16/32 img = img.half() if half else img.float() # uint8 to fp16/32

+ 2
- 2
test.py Целия файл



# Dataloader # Dataloader
if not training: if not training:
img = torch.zeros((1, 3, imgsz, imgsz), device=device) # init img
_ = model(img.half() if half else img) if device.type != 'cpu' else None # run once
if device.type != 'cpu':
model(torch.zeros(1, 3, imgsz, imgsz).to(device).type_as(next(model.parameters()))) # run once
path = data['test'] if opt.task == 'test' else data['val'] # path to val/test images path = data['test'] if opt.task == 'test' else data['val'] # path to val/test images
dataloader = create_dataloader(path, imgsz, batch_size, model.stride.max(), opt, pad=0.5, rect=True, dataloader = create_dataloader(path, imgsz, batch_size, model.stride.max(), opt, pad=0.5, rect=True,
prefix=colorstr('test: ' if opt.task == 'test' else 'val: '))[0] prefix=colorstr('test: ' if opt.task == 'test' else 'val: '))[0]

Loading…
Отказ
Запис