/Bytetrack-YoloX

I practive Bytetrack. And here is the tutorial.

Primary LanguageJupyter Notebook

Contents

🔱Download ByteTrack Github Resources

🔗 https://github.com/ifzhang/ByteTrack

Image from Gyazo

🔱Amend the code

Near 50 lines in set.py

Just add encoding='utf-8' behind "r" .

image

then enter the following in prompt

python setup.py develop

After finished, it would be like that.

image

🔱Install requirements

pip install cython
pip install -e git+https://github.com/samson-wang/cython_bbox.git#egg=cython-bbox
pip install pycocotools
pip install -r requirements.txt

⚠ If you would run Bytetrack in GPU, plz do more step as following. ⚠

Visit the Official Pytorch to get the cmd to install pytorch of CUDA.

🔗 https://pytorch.org/get-started/locally/

image

nvidia-smi

PS. If you're sure about CUDA version, you can check it in this cmd.

image

🔱Justify two codes

📍 yolox/data/data_auguments.py

find preproc function to replace as the following.

    def preproc(img, input_size, swap=(2, 0, 1)):
        if len(img.shape) == 3:
            padded_img = np.ones((input_size[0], input_size[1], 3), dtype=np.uint8) * 114
        else:
            padded_img = np.ones(input_size, dtype=np.uint8) * 114

        r = min(input_size[0] / img.shape[0], input_size[1] / img.shape[1])
        resized_img = cv2.resize(
            img,
            (int(img.shape[1] * r), int(img.shape[0] * r)),
            interpolation=cv2.INTER_LINEAR,
        ).astype(np.uint8)
        padded_img[: int(img.shape[0] * r), : int(img.shape[1] * r)] = resized_img

        padded_img = padded_img.transpose(swap)
        padded_img = np.ascontiguousarray(padded_img, dtype=np.float32)
        return padded_img, r

3

📍 tools/demo_track.py

Delete "self.rgb_means, self.std"

image

🔱Downloas pretrain file of YOLOX

🔗 https://github.com/Megvii-BaseDetection/YOLOX

You can choose any you prefer to download,then put it in root folder.

image

image

🔱Test

python tools/demo_track.py video -f exps/default/yolox_x.py -c yolox_x.pth --fp16 --fuse --save_result

If you successed, it would be like 👇👇

bandicam.2022-08-01.15-50-27-066.mp4

The output would be in "YOLOX_outputs/yolox_x/track_vis" image

Here is the ouput I tested.

palace_demo

Reference

https://github.com/ifzhang/ByteTrack https://colab.research.google.com/drive/1bDilg4cmXFa8HCKHbsZ_p16p0vrhLyu0?usp=sharing#scrollTo=kcuzq_MJ1EmK https://blog.csdn.net/kuweicai/article/details/120873335