Stage-2024/yolov7-setup/instructions.md
√(noham)² f6099d91f1 changes
2024-07-22 14:10:11 +02:00

5.1 KiB

References

Yolov7-tracker

VoTT LabelIMG CVAT

https://theses.hal.science/tel-01784521/file/TH2017ChapelMarieNeige.pdf

OpenCV exemples

calcul de distance camera - objet

Yolov7-tracker

git clone https://github.com/JackWoo0831/Yolov7-tracker.git
mv Yolov7-tracker yolov7-tracker
cd yolov7-tracker
git checkout v2  # change to v2 branch !!
conda create -n yolov7 python=3.9 pytorch=1.12
conda activate yolov7
pip3 install numpy scipy matplotlib cython pandas cuda-python
pip3 install -r requirements.txt
pip3 install ultralytics==8.0.94

Setup cluster

ssh sas ssh cinaps ssh node20

nvidia-smi => cuda 11.4 sur node20

cf notes d'installation de pytorch pour trouver les bonnes versions : https://pytorch.org/get-started/previous-versions/

pip3 install torch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2 --index-url https://download.pytorch.org/whl/cu118
pip3 install filterpy
>>> import torch
>>> torch.cuda.is_available()
True

Setup macos

conda install pytorch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 -c pytorch

Config train

DATASET_ROOT: '/data/DATASETNAME'
SPLIT: train
CATEGORY_NAMES: 
  - 'runner'

CATEGORY_DICT:
  0: 'runner'

CERTAIN_SEQS:
  - 

IGNORE_SEQS:  # Seqs you want to ignore
  - 
train: data/DATASETNAME/liste_images.txt
val: data/DATASETNAME/liste_images.txt
nc: 1
names: ['runner']
Your custom anchor boxes are [[ 13.  34.]
 [ 17.  46.]
 [ 18.  59.]
 [ 21.  79.]
 [ 26. 102.]
 [ 33. 111.]
 [ 34. 135.]
 [ 40. 155.]
 [ 76. 161.]]
Anchors box for yaml file:
anchors:
  - [13,34, 17,46, 18,59]  # P3/8
  - [21,79, 26,102, 33,111]  # P4/16
  - [34,135, 40,155, 76,161]  # P5/32

Launch train

GPU:

python3 train.py --dataset dataset1_2024_06_19__ --workers 1  --device 0 --batch-size 4 --data data/dataset1_2024_06_19/datasetyaml  --img 1280 720 --cfg cfg/training/yolov7x_dataset1_2024_06_19.yaml  --weights ''  --name yolov7x-dataset1_2024_06_19  --hyp data/hyp.scratch.custom.yaml

CPU:

python3 train.py --dataset dataset2fps_20240718_ --epochs 20 --workers 1 --device cpu --batch-size 4 --data data/dataset2fps/dataset.yaml  --img 1280 720 --cfg cfg/training/yolov7x_dataset2fps.yaml --weights '' --name yolov7x-dataset2fps_20240718 --hyp data/hyp.scratch.custom.yaml

Note:

Si erreur : _pickle.UnpicklingError: STACK_GLOBAL requires str
Effacer les fichiers .cache : liste_images.cache par exemple...

Si erreur np.int => remplacer par des np.int64

Si erreur cuda/cpu dans loss.py :
you have to replace the line in the file yolo7/utils/loss.py
"from_which_layer.append((torch.ones(size=(len(b),)) * i)"
to "from_which_layer.append((torch.ones(size=(len(b),)) * i).to('cuda'))",
and add new line "fg_mask_inboxes = fg_mask_inboxes.to(torch.device('cuda'))"
after "fg_mask_inboxes = matching_matrix.sum(0) > 0.0"
so you need to do it 3 times in the file

Result :

10 iterations on MBP M2 : logs

On wandb : https://wandb.ai/noham-/YOLOR/runs/

PDF : pdf

Weights : best.pt