yolov8_tracking

SSW·2023년 4월 24일
0

Deep Learning

목록 보기
8/8

가상환경 setting

$ conda create -n yolov8_tracking python=3.8 -y
$ conda activate yolov8_tracking
$ pip install numpy
$ pip install -r requirements.txt
$ pip install onnxruntime

Tracking

yolov8_deepocsort_tracking.sh script

YOLO_WIEGHTS=yolov8n.pt
TRACKING_METHOD=deepocsort
SOURCE=10
YOLO_WEIGHTS=yolov8n.pt
IMG=640
CLASSES=0  # Detect only person among all classes
#REID_WEIGHTS=resnet50_msmt17.onnx

python track.py \
 --yolo-weights ${YOLO_WIEGHTS} \
 --tracking-method ${TRACKING_METHOD} \
 --source ${SOURCE} \
 --yolo-weights ${YOLO_WEIGHTS} \
 --img ${IMG} \
 --classes ${CLASSES} \
# --reid-weights ${REID_WEIGHTS} \
# --save-trajectories \
# --save-vid \
# --save-txt

Execution command

$ sh yolov8_deepocsort_tracking.sh

Results

Trouble Shooting

Error Message

pip install -r requirements.txt로 package들을 설치하고 build할 때 error 발생

Building wheels for collected packages: lap
  Building wheel for lap (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [13 lines of output]
      Partial import of lap during the build process.
      Traceback (most recent call last):
        File "/tmp/pip-install-q88vs9i0/lap_02a67bf6f6894c1282f3a2b139e13c52/setup.py", line 127, in get_numpy_status
          import numpy
      ModuleNotFoundError: No module named 'numpy'
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-q88vs9i0/lap_02a67bf6f6894c1282f3a2b139e13c52/setup.py", line 236, in <module>
          setup_package()
        File "/tmp/pip-install-q88vs9i0/lap_02a67bf6f6894c1282f3a2b139e13c52/setup.py", line 220, in setup_package
          raise ImportError('lap requires numpy, '
      ImportError: lap requires numpy, please "pip install numpy".
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for lap
  Running setup.py clean for lap
Failed to build lap
ERROR: Could not build wheels for lap, which is required to install pyproject.toml-based projects

Solution

# pip install -r requirements.txt 명령어 입력 전에 numpy 먼저 설치
$ pip install numpy

Error message

track.py를 실행할 때 발생

Traceback (most recent call last):
  File "/home/xxxx/yolov8_tracking/track.py", line 32, in <module>
    from yolov8.ultralytics.nn.autobackend import AutoBackend
  File "/home/xxxx/yolov8_tracking/yolov8/ultralytics/nn/autobackend.py", line 17, in <module>
    from ultralytics.yolo.utils import LINUX, LOGGER, ROOT, yaml_load
ImportError: cannot import name 'LINUX' from 'ultralytics.yolo.utils' (/home/xxxx/.conda/envs/yolov8_tracking/lib/python3.9/site-packages/ultralytics/yolo/utils/__init__.py)
Sentry is attempting to send 2 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit

Solution

# version 8.0.20 -> 8.0.87(최신 version)
$ pip install --upgrade ultralytics

Error message

D455 webcam 연결 후 track.py를 실행할 때 webcam을 열 수 없다는 error 발생

Traceback (most recent call last):
  File "/home/xxxx/yolov8_tracking/track.py", line 365, in <module>
    main(opt)
  File "/home/xxxx/yolov8_tracking/track.py", line 360, in main
    run(**vars(opt))
  File "/home/xxxx/.conda/envs/yolov8_tracking/lib/python3.9/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "/home/xxxx/yolov8_tracking/track.py", line 112, in run
    dataset = LoadStreams(
  File "/home/xxxx/yolov8_tracking/yolov8/ultralytics/yolo/data/dataloaders/stream_loaders.py", line 59, in __init__
    raise ConnectionError(f'{st}Failed to open {s}')
ConnectionError: 1/1: 0... Failed to open 0

Solution

IntelRealSense/librealsense Github Link

$ sudo apt install v4l-utils
$ ls /dev/video*
$ v4l2-ctl -d /dev/video0 --list-ctrls

# 만약 vidio0이 잡히지 않는다면 RealSense SDK 설치를 위해 아래 명령어 실행

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE
$ sudo add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo $(lsb_release -cs) main" -u
$ sudo apt-get install librealsense2-dkms
$ sudo apt-get install librealsense2-utils
$ sudo apt-get install librealsense2-dev
$ sudo apt-get install librealsense2-dbg

$ pip install pyrealsense2

$ sudo apt-get update
$ sudo apt-get upgrade

Webcam 인식은 되는데 여전히 ConnectionError: 1/1: 0... Failed to open 0 error 발생

D435i webcam을 연결했을 때 terminal에 v4l2-ctl --list-devices 명령어를 입력하면 /dev/video6, /dev/video7, /dev/video8, /dev/video9, /dev/video10, /dev/video11, /dev/media2, /dev/media3가 출력되는데 SOURCE0이 아닌 10으로 설정하면 해결됨

References

mikel-brostrom/yolov8_tracking github

profile
ssw

0개의 댓글