From 160dd8830ea3e896da5f62bce6e68c19c6ecbe71 Mon Sep 17 00:00:00 2001 From: Colin Wong Date: Sun, 6 Nov 2022 18:00:38 -0600 Subject: [PATCH 01/12] Update streams.txt default Signed-off-by: Colin Wong --- utils/dataloaders.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/dataloaders.py b/utils/dataloaders.py index b33a24a46f9c..ce8235e230b3 100644 --- a/utils/dataloaders.py +++ b/utils/dataloaders.py @@ -339,7 +339,7 @@ def __len__(self): class LoadStreams: # YOLOv5 streamloader, i.e. `python detect.py --source 'rtsp://example.com/media.mp4' # RTSP, RTMP, HTTP streams` - def __init__(self, sources='streams.txt', img_size=640, stride=32, auto=True, transforms=None, vid_stride=1): + def __init__(self, sources='rtsp.streams', img_size=640, stride=32, auto=True, transforms=None, vid_stride=1): torch.backends.cudnn.benchmark = True # faster for fixed-size inference self.mode = 'stream' self.img_size = img_size From f5e95c71592f7130cd300d0fbf2d756ee0a66cf7 Mon Sep 17 00:00:00 2001 From: Colin Wong Date: Sun, 6 Nov 2022 18:04:02 -0600 Subject: [PATCH 02/12] Change streams list extension to .streams --- detect.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/detect.py b/detect.py index 8e42fbe159d0..04e9f6528593 100644 --- a/detect.py +++ b/detect.py @@ -7,6 +7,7 @@ img.jpg # image vid.mp4 # video path/ # directory + files.txt # list of media 'path/*.jpg' # glob 'https://youtu.be/Zgi9g1ksQHc' # YouTube 'rtsp://example.com/media.mp4' # RTSP, RTMP, HTTP stream @@ -81,7 +82,7 @@ def run( save_img = not nosave and not source.endswith('.txt') # save inference images is_file = Path(source).suffix[1:] in (IMG_FORMATS + VID_FORMATS) is_url = source.lower().startswith(('rtsp://', 'rtmp://', 'http://', 'https://')) - webcam = source.isnumeric() or source.endswith('.txt') or (is_url and not is_file) + webcam = source.isnumeric() or source.endswith('.streams') or (is_url and not is_file) screenshot = source.lower().startswith('screen') if is_url and is_file: source = check_file(source) # download From a5d0c18ce6999670bdc5af2a2447c738fd0d8751 Mon Sep 17 00:00:00 2001 From: Colin Wong Date: Sun, 6 Nov 2022 18:22:28 -0600 Subject: [PATCH 03/12] Read txt as media per line --- utils/dataloaders.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/dataloaders.py b/utils/dataloaders.py index ce8235e230b3..d0d92ef411fc 100644 --- a/utils/dataloaders.py +++ b/utils/dataloaders.py @@ -240,6 +240,8 @@ class LoadImages: # YOLOv5 image/video dataloader, i.e. `python detect.py --source image.jpg/vid.mp4` def __init__(self, path, img_size=640, stride=32, auto=True, transforms=None, vid_stride=1): files = [] + if isinstance(path, str) and path.split('.')[-1].lower() == "txt": + path = Path(path).read_text().rsplit() # txt with media on each line for p in sorted(path) if isinstance(path, (list, tuple)) else [path]: p = str(Path(p).resolve()) if '*' in p: From 659be1de952f05f413b775f2f967ee2dc0e8cdd9 Mon Sep 17 00:00:00 2001 From: Colin Wong Date: Sun, 6 Nov 2022 18:30:04 -0600 Subject: [PATCH 04/12] Missed one --- classify/predict.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classify/predict.py b/classify/predict.py index 96508d633da8..026def835948 100644 --- a/classify/predict.py +++ b/classify/predict.py @@ -73,7 +73,7 @@ def run( save_img = not nosave and not source.endswith('.txt') # save inference images is_file = Path(source).suffix[1:] in (IMG_FORMATS + VID_FORMATS) is_url = source.lower().startswith(('rtsp://', 'rtmp://', 'http://', 'https://')) - webcam = source.isnumeric() or source.endswith('.txt') or (is_url and not is_file) + webcam = source.isnumeric() or source.endswith('.streams') or (is_url and not is_file) screenshot = source.lower().startswith('screen') if is_url and is_file: source = check_file(source) # download From f9597ef8384ec9e1a05b9edbf729a065561302a5 Mon Sep 17 00:00:00 2001 From: Colin Wong Date: Sun, 6 Nov 2022 18:32:01 -0600 Subject: [PATCH 05/12] Missed another one --- segment/predict.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/segment/predict.py b/segment/predict.py index 3ae68240726a..05288b6627a2 100644 --- a/segment/predict.py +++ b/segment/predict.py @@ -84,7 +84,7 @@ def run( save_img = not nosave and not source.endswith('.txt') # save inference images is_file = Path(source).suffix[1:] in (IMG_FORMATS + VID_FORMATS) is_url = source.lower().startswith(('rtsp://', 'rtmp://', 'http://', 'https://')) - webcam = source.isnumeric() or source.endswith('.txt') or (is_url and not is_file) + webcam = source.isnumeric() or source.endswith('.streams') or (is_url and not is_file) screenshot = source.lower().startswith('screen') if is_url and is_file: source = check_file(source) # download From 4b921983b051b9fe0905af271ef7675dc5ad413f Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 3 Dec 2022 14:30:51 -0800 Subject: [PATCH 06/12] Update dataloaders.py --- utils/dataloaders.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/dataloaders.py b/utils/dataloaders.py index 417a4c25fd30..5aeb38617578 100644 --- a/utils/dataloaders.py +++ b/utils/dataloaders.py @@ -340,7 +340,7 @@ def __len__(self): class LoadStreams: # YOLOv5 streamloader, i.e. `python detect.py --source 'rtsp://example.com/media.mp4' # RTSP, RTMP, HTTP streams` - def __init__(self, sources='rtsp.streams', img_size=640, stride=32, auto=True, transforms=None, vid_stride=1): + def __init__(self, sources='file.streams', img_size=640, stride=32, auto=True, transforms=None, vid_stride=1): torch.backends.cudnn.benchmark = True # faster for fixed-size inference self.mode = 'stream' self.img_size = img_size From e124f1d2a42afe171de85e66a8e7d4c13d9b2fd1 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 3 Dec 2022 14:41:45 -0800 Subject: [PATCH 07/12] Update detect.py --- detect.py | 1 - 1 file changed, 1 deletion(-) diff --git a/detect.py b/detect.py index 6c32cb7b1e7c..9c257e140055 100644 --- a/detect.py +++ b/detect.py @@ -8,7 +8,6 @@ vid.mp4 # video screen # screenshot path/ # directory - files.txt # list of media 'path/*.jpg' # glob 'https://youtu.be/Zgi9g1ksQHc' # YouTube 'rtsp://example.com/media.mp4' # RTSP, RTMP, HTTP stream From 75b94cb7abe0a1f0f7a21b8096c583d7a3948247 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 3 Dec 2022 14:44:58 -0800 Subject: [PATCH 08/12] Update dataloaders.py --- utils/dataloaders.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/dataloaders.py b/utils/dataloaders.py index 5aeb38617578..6d2b27ea5e60 100644 --- a/utils/dataloaders.py +++ b/utils/dataloaders.py @@ -238,9 +238,9 @@ def __next__(self): class LoadImages: # YOLOv5 image/video dataloader, i.e. `python detect.py --source image.jpg/vid.mp4` def __init__(self, path, img_size=640, stride=32, auto=True, transforms=None, vid_stride=1): + if isinstance(path, str) and Path(path).suffix == ".txt": # *.txt file with img/vid/dir on each line + path = Path(path).read_text().rsplit() files = [] - if isinstance(path, str) and path.split('.')[-1].lower() == "txt": - path = Path(path).read_text().rsplit() # txt with media on each line for p in sorted(path) if isinstance(path, (list, tuple)) else [path]: p = str(Path(p).resolve()) if '*' in p: From ebadad39ba90a928b861f1dfb4b7424001190a63 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 3 Dec 2022 14:55:16 -0800 Subject: [PATCH 09/12] Update detect.py --- detect.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/detect.py b/detect.py index 9c257e140055..2d13401f78bd 100644 --- a/detect.py +++ b/detect.py @@ -8,6 +8,8 @@ vid.mp4 # video screen # screenshot path/ # directory + list.txt # list of images + list.streams # list of streams 'path/*.jpg' # glob 'https://youtu.be/Zgi9g1ksQHc' # YouTube 'rtsp://example.com/media.mp4' # RTSP, RTMP, HTTP stream From 6951e8e0aa1d747128b74fccced50258902cafbd Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 3 Dec 2022 14:55:39 -0800 Subject: [PATCH 10/12] Update predict.py --- classify/predict.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/classify/predict.py b/classify/predict.py index 35dc92f867ad..5a5edabda42c 100644 --- a/classify/predict.py +++ b/classify/predict.py @@ -8,6 +8,8 @@ vid.mp4 # video screen # screenshot path/ # directory + list.txt # list of images + list.streams # list of streams 'path/*.jpg' # glob 'https://youtu.be/Zgi9g1ksQHc' # YouTube 'rtsp://example.com/media.mp4' # RTSP, RTMP, HTTP stream From d96408bec1ce3b3ba34509b6f06e7184467bcaa0 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 3 Dec 2022 14:56:02 -0800 Subject: [PATCH 11/12] Update predict.py --- segment/predict.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/segment/predict.py b/segment/predict.py index 54801759f679..e9093baa1cc7 100644 --- a/segment/predict.py +++ b/segment/predict.py @@ -8,6 +8,8 @@ vid.mp4 # video screen # screenshot path/ # directory + list.txt # list of images + list.streams # list of streams 'path/*.jpg' # glob 'https://youtu.be/Zgi9g1ksQHc' # YouTube 'rtsp://example.com/media.mp4' # RTSP, RTMP, HTTP stream From 9b62ae4a5425272b69778cab16c66cb3efce7c5c Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 3 Dec 2022 14:57:59 -0800 Subject: [PATCH 12/12] Update README.md --- README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index dd24a938a060..3c163b3e1742 100644 --- a/README.md +++ b/README.md @@ -182,14 +182,16 @@ results.print() # or .show(), .save(), .crop(), .pandas(), etc. the latest YOLOv5 [release](https://github.com/ultralytics/yolov5/releases) and saving results to `runs/detect`. ```bash -python detect.py --source 0 # webcam - img.jpg # image - vid.mp4 # video - screen # screenshot - path/ # directory - 'path/*.jpg' # glob - 'https://youtu.be/Zgi9g1ksQHc' # YouTube - 'rtsp://example.com/media.mp4' # RTSP, RTMP, HTTP stream +python detect.py --weights yolov5s.pt --source 0 # webcam + img.jpg # image + vid.mp4 # video + screen # screenshot + path/ # directory + list.txt # list of images + list.streams # list of streams + 'path/*.jpg' # glob + 'https://youtu.be/Zgi9g1ksQHc' # YouTube + 'rtsp://example.com/media.mp4' # RTSP, RTMP, HTTP stream ```