From 0a52ae16dc820c2fc7c62112cf27b8ff209fc1a5 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 25 Oct 2020 14:05:28 +0100 Subject: [PATCH] README Update (#1207) * README Update * Update README.md * README Update * Update README.md --- README.md | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5275e9d..eec9bcb 100755 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ YOLOv5 may be run in any of the following up-to-date verified environments (with ## Inference -Inference can be run on most common media formats. Model [checkpoints](https://drive.google.com/open?id=1Drs_Aiu7xx6S-ix95f9kNsA6ueKRpN2J) are downloaded automatically if available. Results are saved to `./inference/output`. +detect.py runs inference on a variety of sources, downloading models automatically from the [latest YOLOv5 release](https://github.com/ultralytics/yolov5/releases) and saving results to `inference/output`. ```bash $ python detect.py --source 0 # webcam file.jpg # image @@ -81,22 +81,43 @@ $ python detect.py --source 0 # webcam http://112.50.243.8/PLTV/88888888/224/3221225900/1.m3u8 # http stream ``` -To run inference on examples in the `./inference/images` folder: - +To run inference on example images in `inference/images`: ```bash -$ python detect.py --source ./inference/images/ --weights yolov5s.pt --conf 0.4 +$ python detect.py --source inference/images --weights yolov5s.pt --conf 0.25 -Namespace(agnostic_nms=False, augment=False, classes=None, conf_thres=0.4, device='', fourcc='mp4v', half=False, img_size=640, iou_thres=0.5, output='inference/output', save_txt=False, source='./inference/images/', view_img=False, weights='yolov5s.pt') -Using CUDA device0 _CudaDeviceProperties(name='Tesla P100-PCIE-16GB', total_memory=16280MB) +Namespace(agnostic_nms=False, augment=False, classes=None, conf_thres=0.25, device='', img_size=640, iou_thres=0.45, output='inference/output', save_conf=False, save_txt=False, source='inference/images', update=False, view_img=False, weights='yolov5s.pt') +Using CUDA device0 _CudaDeviceProperties(name='Tesla V100-SXM2-16GB', total_memory=16160MB) -Downloading https://drive.google.com/uc?export=download&id=1R5T6rIyy3lLwgFXNms8whc-387H0tMQO as yolov5s.pt... Done (2.6s) +Downloading https://github.com/ultralytics/yolov5/releases/download/v3.0/yolov5s.pt to yolov5s.pt... 100%|██████████████| 14.5M/14.5M [00:00<00:00, 21.3MB/s] -image 1/2 inference/images/bus.jpg: 640x512 3 persons, 1 buss, Done. (0.009s) -image 2/2 inference/images/zidane.jpg: 384x640 2 persons, 2 ties, Done. (0.009s) -Results saved to /content/yolov5/inference/output +Fusing layers... +Model Summary: 140 layers, 7.45958e+06 parameters, 0 gradients +image 1/2 yolov5/inference/images/bus.jpg: 640x480 4 persons, 1 buss, 1 skateboards, Done. (0.013s) +image 2/2 yolov5/inference/images/zidane.jpg: 384x640 2 persons, 2 ties, Done. (0.013s) +Results saved to yolov5/inference/output +Done. (0.124s) ``` + - +### PyTorch Hub + +To run **batched inference** with YOLOv5 and [PyTorch Hub](https://github.com/ultralytics/yolov5/issues/36): +```python +import torch +from PIL import Image + +# Model +model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True).fuse().eval() # yolov5s.pt +model = model.autoshape() # for autoshaping of PIL/cv2/np inputs and NMS + +# Images +img1 = Image.open('zidane.jpg') +img2 = Image.open('bus.jpg') +imgs = [img1, img2] # batched list of images + +# Inference +prediction = model(imgs, size=640) # includes NMS +``` ## Training