Install
git clone https://github.com/MoodangE/MoodangE_tracking # clone
cd MoodangE_tracking
pip install -r requirements.txt # install
Inference with tracking.py
tracking.py
runs inference on a variety of sources,
downloading models automatically from the latest
YOLOv5 release and saving results to runs/detect
.
-
Save Results as Image Using webcam
python "file_name".py --source 0 # webcam
-
Save Results as Image Using Video file
python "file_name".py --source "path/vid.mp4" --view-img # video
-
Command Format about save results as image using 'custom weights'
python "file_name".py --weights "path/custom_weight.pt" --data "path/custom_yaml.yaml" --source "path\vide.mp4" --view-img
- When collecting information to track your location, it is recommended that you collect it for about 5 seconds.
Ex) FPS = 30,
-
Default values
- Weight : best_1107.pt
- Data : gachon_road.yaml
- Start point : AI
- All files are associated with the realtime database in the firebase to store this information.
-
Save Results (Prediction of Gachon University's Location) as Image or Video
python tracking_location_cam.py --source 0 --view-img
-
Save Result (Prediction of Gachon University's Location) as Text
python tracking_location_text.py --source 0
-
Not Save Result (Prediction of Gachon University's Location)
python tracking_location_db.py --source 0
-
Default values
- Weight : yolov5s.pt
- Data : coco128.yaml
- Filming location : MainGate
- All files are associated with the realtime database in the firebase to store this information.
-
Save Result (Calculate of person confusion) as Image or Video
python tracking_person_cam.py --source 0
-
Not Save Result (Calculate of person confusion)
python tracking_person_db.py --source 0
Train
-
Change wandb run name in
yolov5/train.py
-
Use this command to run training
cd yolov5 python train.py --img 1920 --batch 4 --epochs 100 --data customDataset/gachon_road.yaml --cfg models/yolov5s.yaml --weights weights/yolov5s.pt
Implements Reference
- tensorturtle/classy-sort-yolov5 : See How to Configure Two Repositories
- ultralytics/YOLOv5 : With No Modifications
- abewley/SORT : With minor Modifications
Error & Solution
-
PyCharm으로 구동해볼 때 classy-sort-yolov5의 classy_track의 58번째 줄의 **from sort import ***에서 오류가 발생
해결책 > PyCharm 프로젝트 안에서 두개의 프로젝트를 일반 폴더가 아닌 소스 형태로 바꾸면 정상으로 import 됨
↓ 정상 import 된 화면
-
classy-sort-yolov5/yolov5/weights/download_weights.sh의 파일이 정상 작동하지 않아 yolov5s.pt 파일을 정상적으로 다운로드 하지 못함.
** 해결책 >** https://github.com/ultralytics/yolov5/releases/download/v3.1/yolov5s.pt 를 통해 yolov5s.pt 파일을 다운로드 한뒤에 classy-sort-yolov5/yolov5/weights에 붙여넣음
-
(python classy_track.py --source 동영상 경로 --view-img) or (python classy_track.py —source 0)를 실행시 발생하는 오류 ( —view—img: 영상, 0: 웹캠)
AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor’라는 오류가 발생함.
해결책 > 출처 : ultralytics/yolov5#6948 ~\site-packages\torch\nn\modules\upsampling.py에서 154줄의
recompute_scale_factor=self.recompute_scale_factor
를 주석처리하면 정상 작동↓ 정상 작동하며 Multiple Object Tracking (MOT)가 되는것을 볼 수 있음