From 77566756034a398315686920b74f35a58d9bb8f7 Mon Sep 17 00:00:00 2001 From: Ju Hoon Park Date: Wed, 24 Apr 2024 12:48:47 +0900 Subject: [PATCH 1/4] a little modify for requirements.txt link rename 'master' to 'main' due to [github renaming](https://github.com/github/renaming) in requirements.txt hyper link. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 643e39ef..04f4389b 100755 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ This repository contains a highly configurable two-stage-tracker that adjusts to If you already cloned and forgot to use `--recurse-submodules` you can run `git submodule update --init` -2. Make sure that you fulfill all the requirements: Python 3.8 or later with all [requirements.txt](https://github.com/mikel-brostrom/Yolov7_DeepSort_Pytorch/blob/master/requirements.txt) dependencies installed, including torch>=1.7. To install, run: +2. Make sure that you fulfill all the requirements: Python 3.8 or later with all [requirements.txt](https://github.com/mikel-brostrom/Yolov7_DeepSort_Pytorch/blob/main/requirements.txt) dependencies installed, including torch>=1.7. To install, run: `pip install -r requirements.txt` From 36266e1c470440031026b0ec94523b5757854afc Mon Sep 17 00:00:00 2001 From: Ju Hoon Park Date: Wed, 24 Apr 2024 12:56:08 +0900 Subject: [PATCH 2/4] my mistake modify address of "requirements.txt" --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 04f4389b..78559b97 100755 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ This repository contains a highly configurable two-stage-tracker that adjusts to If you already cloned and forgot to use `--recurse-submodules` you can run `git submodule update --init` -2. Make sure that you fulfill all the requirements: Python 3.8 or later with all [requirements.txt](https://github.com/mikel-brostrom/Yolov7_DeepSort_Pytorch/blob/main/requirements.txt) dependencies installed, including torch>=1.7. To install, run: +2. Make sure that you fulfill all the requirements: Python 3.8 or later with all [requirements.txt](https://github.com/mikel-brostrom/Yolov7_StrongSORT_OSNet/blob/main/requirements.txt) dependencies installed, including torch>=1.7. To install, run: `pip install -r requirements.txt` From 7a1968f2c3ab04096cc76254b209561e99d43ce5 Mon Sep 17 00:00:00 2001 From: Ju Hoon Park Date: Fri, 26 Apr 2024 16:39:25 +0900 Subject: [PATCH 3/4] add 'save_one_box' method for '--save-crop' argument method from [https://github.com/WongKinYiu/yolov7/blob/u5/utils/plots.py#L474] --- track.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/track.py b/track.py index 281377a7..075f17d4 100644 --- a/track.py +++ b/track.py @@ -32,13 +32,31 @@ from yolov7.models.experimental import attempt_load from yolov7.utils.datasets import LoadImages, LoadStreams from yolov7.utils.general import (check_img_size, non_max_suppression, scale_coords, check_requirements, cv2, - check_imshow, xyxy2xywh, increment_path, strip_optimizer, colorstr, check_file) + check_imshow, xyxy2xywh, xywh2xyxy, clip_coords, increment_path, strip_optimizer, colorstr, check_file) from yolov7.utils.torch_utils import select_device, time_synchronized from yolov7.utils.plots import plot_one_box from strong_sort.utils.parser import get_config from strong_sort.strong_sort import StrongSORT +# method from [https://github.com/WongKinYiu/yolov7/blob/u5/utils/plots.py#L474] for availabling '--save-crop' argument +def save_one_box(xyxy, im, file=Path('im.jpg'), gain=1.02, pad=10, square=False, BGR=False, save=True): + # Save image crop as {file} with crop size multiple {gain} and {pad} pixels. Save and/or return crop + xyxy = torch.tensor(xyxy).view(-1, 4) + b = xyxy2xywh(xyxy) # boxes + if square: + b[:, 2:] = b[:, 2:].max(1)[0].unsqueeze(1) # attempt rectangle to square + b[:, 2:] = b[:, 2:] * gain + pad # box wh * gain + pad + xyxy = xywh2xyxy(b).long() + clip_coords(xyxy, im.shape) + crop = im[int(xyxy[0, 1]):int(xyxy[0, 3]), int(xyxy[0, 0]):int(xyxy[0, 2]), ::(1 if BGR else -1)] + if save: + file.parent.mkdir(parents=True, exist_ok=True) # make directory + f = str(Path(increment_path(file)).with_suffix('.jpg')) + # cv2.imwrite(f, crop) # https://github.com/ultralytics/yolov5/issues/7007 chroma subsampling issue + Image.fromarray(cv2.cvtColor(crop, cv2.COLOR_BGR2RGB)).save(f, quality=95, subsampling=0) + return crop + VID_FORMATS = 'asf', 'avi', 'gif', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'ts', 'wmv' # include video suffixes From ea4363a9e72ccc00a94357dd3a7690e2cb35acad Mon Sep 17 00:00:00 2001 From: Ju Hoon Park Date: Fri, 26 Apr 2024 16:41:21 +0900 Subject: [PATCH 4/4] Update track.py --- track.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/track.py b/track.py index 075f17d4..0b2d5151 100644 --- a/track.py +++ b/track.py @@ -14,7 +14,7 @@ import torch import torch.backends.cudnn as cudnn from numpy import random - +from PIL import Image FILE = Path(__file__).resolve() ROOT = FILE.parents[0] # yolov5 strongsort root directory