updates
This commit is contained in:
parent
62f1e21b14
commit
e82f201578
|
@ -108,7 +108,7 @@ V100 x2 | 64 (64x1) | 0.30 s | 18 min | $0.46
|
||||||
|
|
||||||
## Webcam
|
## Webcam
|
||||||
|
|
||||||
`detect.py` with `webcam=True` shows a live webcam feed.
|
`python3 detect.py --webcam` shows a live webcam feed.
|
||||||
|
|
||||||
# Pretrained Weights
|
# Pretrained Weights
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,7 @@ def detect(cfg,
|
||||||
conf_thres=0.5,
|
conf_thres=0.5,
|
||||||
nms_thres=0.5,
|
nms_thres=0.5,
|
||||||
save_txt=False,
|
save_txt=False,
|
||||||
save_images=True,
|
save_images=True):
|
||||||
webcam=False):
|
|
||||||
# Initialize
|
# Initialize
|
||||||
device = torch_utils.select_device()
|
device = torch_utils.select_device()
|
||||||
torch.backends.cudnn.benchmark = False # set False for reproducible results
|
torch.backends.cudnn.benchmark = False # set False for reproducible results
|
||||||
|
@ -58,7 +57,7 @@ def detect(cfg,
|
||||||
|
|
||||||
# Set Dataloader
|
# Set Dataloader
|
||||||
vid_path, vid_writer = None, None
|
vid_path, vid_writer = None, None
|
||||||
if webcam:
|
if opt.webcam:
|
||||||
save_images = False
|
save_images = False
|
||||||
dataloader = LoadWebcam(img_size=img_size, half=opt.half)
|
dataloader = LoadWebcam(img_size=img_size, half=opt.half)
|
||||||
else:
|
else:
|
||||||
|
@ -101,7 +100,7 @@ def detect(cfg,
|
||||||
|
|
||||||
print('Done. (%.3fs)' % (time.time() - t))
|
print('Done. (%.3fs)' % (time.time() - t))
|
||||||
|
|
||||||
if webcam: # Show live webcam
|
if opt.webcam: # Show live webcam
|
||||||
cv2.imshow(weights, im0)
|
cv2.imshow(weights, im0)
|
||||||
|
|
||||||
if save_images: # Save image with detections
|
if save_images: # Save image with detections
|
||||||
|
@ -139,6 +138,7 @@ if __name__ == '__main__':
|
||||||
parser.add_argument('--fourcc', type=str, default='mp4v', help='fourcc output video codec (verify ffmpeg support)')
|
parser.add_argument('--fourcc', type=str, default='mp4v', help='fourcc output video codec (verify ffmpeg support)')
|
||||||
parser.add_argument('--output', type=str, default='output', help='specifies the output path for images and videos')
|
parser.add_argument('--output', type=str, default='output', help='specifies the output path for images and videos')
|
||||||
parser.add_argument('--half', action='store_true', help='half precision FP16 inference')
|
parser.add_argument('--half', action='store_true', help='half precision FP16 inference')
|
||||||
|
parser.add_argument('--webcam', action='store_true', help='use webcam')
|
||||||
opt = parser.parse_args()
|
opt = parser.parse_args()
|
||||||
print(opt)
|
print(opt)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue