2 Commits

Author SHA1 Message Date
√(noham)²
db075fb427 update instructions + slurm 2024-07-22 20:32:20 +02:00
√(noham)²
15b4fecdd0 v2 2024-07-22 18:38:42 +02:00
1089 changed files with 7025 additions and 0 deletions

3
.gitignore vendored
View File

@@ -155,3 +155,6 @@ node_modules/
/test/yolov7-tracker/runs
/test/yolov7-tracker/wandb
VoTT-v2-none.zip
VoTT-v2-done.zip
VoTT-v2/output/vott-json-export.zip
/OpenCV/opencv

View File

@@ -16,12 +16,28 @@ mv Yolov7-tracker yolov7-tracker
cd yolov7-tracker
git checkout v2 # change to v2 branch !!
```
Change np.int to np.int64 in :
utils/datasets.py
utils/general.py
Fix for GPU in [utils/loss.py](../yolov7-tracker-example/utils/loss.py.bak):
```python
from_which_layer.append((torch.ones(size=(len(b),)) * i).to('cuda')) ### SF #### (lines 686)
fg_mask_inboxes = fg_mask_inboxes.to(torch.device('cuda')) ### SF #### (lines 758 & 5164 & 1568)
```
Set up env :
```bash
conda create -n yolov7 python=3.9 pytorch=1.12
conda activate yolov7
pip3 install numpy scipy matplotlib cython pandas cuda-python
```
```
conda env : /home/noham.rivoirard/.conda/envs/yolov7
```
<!-- ## ERROR: Could not find a version that satisfies the requirement cuda-python (from versions: none) Requires-Python >=3.10 -->
```bash
pip3 install -r requirements.txt

43
yolov7-setup/sq.sh Normal file
View File

@@ -0,0 +1,43 @@
#!/bin/bash
## <------------------ pour le cluster de calcul
####SBATCH -N 1 ## 1 noeud
#SBATCH --nodelist=node20
### #SBATCH --exclusive ## le noeud sera entierement dedié à notre job.
######SBATCH -t 12:00:00 ## job tué au bout de 12h
#SBATCH --gres=gpu:1 ## 4 GPU par noeud
### #SBATCH --constraint=gpudp ## noeuds GPU double précision
#SBATCH --job-name=GPU_yolov7_noham
#SBATCH --chdir=/home/noham.rivoirard/yolov7-tracker
# -- Optionnel, pour être notifié par email :
#SBATCH --mail-type=FAIL
#SBATCH --mail-user=noham@noh.am
# -- Sortie standard et d'erreur dans le fichier .output :
#SBATCH --output=./%j.stdout
#SBATCH --error=./%j.stderr
# -- Contexte matériel
#SBATCH --nodes=1
#SBATCH --cpus-per-task=1
echo "SLURM_STEP_GPUS : "${SLURM_STEP_GPUS}
echo "SLURM_JOB_GPUS : "$SLURM_JOB_GPUS
echo "SLURM_STEP/JOB_GPUS "${SLURM_STEP_GPUS:-$SLURM_JOB_GPUS}
echo "CUDA_VISIBLE_DEVICES : "${CUDA_VISIBLE_DEVICES}
source /usr/local/anaconda3/etc/profile.d/conda.sh
conda activate yolov7
which python
#export OMP_NUM_THREADS=8
#echo $OMP_NUM_THREADS
#
## doc
# squeue permet de voir les jobs en attente ou en train de tourner. S'ils tournent, il y aura un R dans la colonne ST.
# sattach permet d'attacher sur le terminal les E/S d'un job en train de tourner. Ça permet de surveiller l'avancée d'un job, ou par exemple d'interagir avec un debugger. ctrl-c permet de détacher de nouveau le job et de le laisser de nouveau tourner en fond (de manière non bloquante).
# scancel permet permet de supprimer une soumission ou darrêter le job s'il est en cours dexécution.
# sstat donne des infos sur les ressources utilisées par un job
# python3 train.py --dataset datasetv2_20240722_ --epochs 600 --workers 1 --device 0 --batch-size 4 --data data/datasetv2/dataset.yaml --img 1280 720 --cfg cfg/training/yolov7x_datasetv2.yaml --weights '' --name yolov7x-datasetv2_20240722 --hyp data/hyp.scratch.custom.yamlclear
# srun python3 train.py --dataset dataset1_2024_06_19__ --workers 1 --device ${CUDA_VISIBLE_DEVICES} --batch-size 4 --epochs 600 --data data/dataset1_2024_06_19/dataset.yaml --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
srun python3 train.py --dataset datasetv2_20240722_ --epochs 600 --workers 1 --device ${CUDA_VISIBLE_DEVICES} --batch-size 4 --data data/datasetv2/dataset.yaml --img 1280 720 --cfg cfg/training/yolov7x_datasetv2.yaml --weights '' --name yolov7x-datasetv2_20240722 --hyp data/hyp.scratch.custom.yaml

View File

@@ -0,0 +1,41 @@
#!/bin/bash
## <------------------ pour le cluster de calcul
####SBATCH -N 1 ## 1 noeud
#SBATCH --nodelist=node15
### #SBATCH --exclusive ## le noeud sera entierement dedié à notre job.
######SBATCH -t 12:00:00 ## job tué au bout de 12h
#SBATCH --gres=gpu:1 ## 4 GPU par noeud
### #SBATCH --constraint=gpudp ## noeuds GPU double précision
#SBATCH --job-name=GPU_yolov7
#SBATCH --chdir=/home/sylvain.faure/RN/athle/yolov7-tracker/
# -- Optionnel, pour être notifié par email :
#SBATCH --mail-type=FAIL
#SBATCH --mail-user=sylvain.faure@universite-paris-saclay.fr
# -- Sortie standard et d'erreur dans le fichier .output :
#SBATCH --output=./%j.stdout
#SBATCH --error=./%j.stderr
# -- Contexte matériel
#SBATCH --nodes=1
#SBATCH --cpus-per-task=1
echo "SLURM_STEP_GPUS : "${SLURM_STEP_GPUS}
echo "SLURM_JOB_GPUS : "$SLURM_JOB_GPUS
echo "SLURM_STEP/JOB_GPUS "${SLURM_STEP_GPUS:-$SLURM_JOB_GPUS}
echo "CUDA_VISIBLE_DEVICES : "${CUDA_VISIBLE_DEVICES}
source /usr/local/anaconda3/etc/profile.d/conda.sh
conda activate yolov7
which python
#export OMP_NUM_THREADS=8
#echo $OMP_NUM_THREADS
#
## doc
# squeue permet de voir les jobs en attente ou en train de tourner. S'ils tournent, il y aura un R dans la colonne ST.
# sattach permet d'attacher sur le terminal les E/S d'un job en train de tourner. Ça permet de surveiller l'avancée d'un job, ou par exemple d'interagir avec un debugger. ctrl-c permet de détacher de nouveau le job et de le laisser de nouveau tourner en fond (de manière non bloquante).
# scancel permet permet de supprimer une soumission ou darrêter le job s'il est en cours dexécution.
# sstat donne des infos sur les ressources utilisées par un job
srun python3 train.py --dataset dataset1_2024_06_19__ --workers 1 --device ${CUDA_VISIBLE_DEVICES} --batch-size 4 --epochs 600 --data data/dataset1_2024_06_19/dataset.yaml --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

View File

@@ -0,0 +1,96 @@
import json
import os, sys
import math
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns; sns.set() # for plot styling
from PIL import Image
imgsize = int(input("Image size for train and run? "))
print("=> imgsize =",imgsize)
# imgsize = 256
BBDlabeldict = {"runner":0}
datasetpath = '/Users/noham/Documents/GitHub/Stage-2024/yolov7-setup/v2/datasetv2/'
images_path = datasetpath+"images"
labels_path = datasetpath+"labels"
filenames = sorted(os.listdir(images_path))
print("Nb d'images =",len(filenames))
w,h = [] , []
for i,file in enumerate(filenames):
#print(file)
try:
# if True:
im = Image.open(images_path+"/"+file)
img_width = im.width
img_height = im.height
#print(img_width,img_height)
fo = open(images_path.replace("images","labels")+"/"+file.replace("jpg","txt"), "r+")
lines = fo.readlines()
for line in lines:
a = np.array(line.split(" ")).astype(float)
w.append(a[3]*img_width)
h.append(a[4]*img_height)
if (a[3]*img_height<0.001) or (a[4]*img_height<0.001):
print("!! ATTENTION : boite trop petite dans le fichier ",file, "=> il faut vérifier et supprimer la ligne dans le fichier label au format txt !!")
except:
pass
w=np.asarray(w)#+0.001*(np.random.random((len(w),)) - 0.5)
h=np.asarray(h)#+0.001*(np.random.random((len(w),)) - 0.5)
print("h => min =",h.min()," max =",h.max())
print("w => min =",w.min()," max =",h.max())
print("Nb objets entourés =",len(h))
x=[w,h]
x=np.asarray(x)
x=x.transpose()
########################################## K- Means
##########################################
from sklearn.cluster import KMeans
kmeans3 = KMeans(n_clusters=9)
kmeans3.fit(x)
y_kmeans3 = kmeans3.predict(x)
##########################################
centers3 = kmeans3.cluster_centers_
yolo_anchor_average=[]
for ind in range (9):
yolo_anchor_average.append(np.mean(x[y_kmeans3==ind],axis=0))
yolo_anchor_average=np.array(yolo_anchor_average)
plt.scatter(x[:, 0], x[:, 1], c=y_kmeans3, s=2, cmap='viridis')
plt.scatter(yolo_anchor_average[:, 0], yolo_anchor_average[:, 1], c='red', s=50)
yoloV3anchors = yolo_anchor_average
yoloV3anchors[:, 0] =yolo_anchor_average[:, 0] /1920 *imgsize
yoloV3anchors[:, 1] =yolo_anchor_average[:, 1] /1056 *imgsize
yoloV3anchors = np.rint(yoloV3anchors)
fig, ax = plt.subplots()
for ind in range(9):
rectangle= plt.Rectangle((0.5*imgsize-yoloV3anchors[ind,0]/2,0.5*imgsize-yoloV3anchors[ind,1]/2), yoloV3anchors[ind,0],yoloV3anchors[ind,1] , fc='b',edgecolor='b',fill = None)
ax.add_patch(rectangle)
ax.set_aspect(1.0)
plt.axis([0,imgsize,0,imgsize])
plt.savefig(datasetpath+"boites.png",dpi=150)
plt.show()
yoloV3anchors.sort(axis=0)
print("Your custom anchor boxes are {}".format(yoloV3anchors))
F = open(datasetpath+"YOLOV_BDD_Anchors_"+str(imgsize)+".txt", "w")
F.write("{}".format(yoloV3anchors))
F.close()
print("Anchors box for yaml file :")
s_anchors = yoloV3anchors[yoloV3anchors[:, 0].argsort()]
anchor_lists = [s_anchors[i:i+3].tolist() for i in range(0, len(s_anchors), 3)]
# anchor_lists = [[[14.0, 37.0], [15.0, 48.0], [19.0, 53.0]], [[21.0, 70.0], [24.0, 88.0], [31.0, 112.0]], [[34.0, 136.0], [35.0, 155.0], [76.0, 161.0]]]
p = ['] # P3/8', '] # P4/16', '] # P5/32']
out = "anchors:"
for l in anchor_lists:
out += '\n' + " - [" + ", ".join([f"{int(i[0])},{int(i[1])}" for i in l]) + p[anchor_lists.index(l)]
print(out)

View File

@@ -0,0 +1,9 @@
[[ 23. 58.]
[ 27. 104.]
[ 38. 106.]
[ 46. 146.]
[ 47. 156.]
[ 68. 192.]
[ 68. 232.]
[134. 273.]
[204. 498.]]

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -0,0 +1,4 @@
train: data/datasetv2/liste_images.txt
val: data/datasetv2/liste_images.txt
nc: 1
names: ['runner']

Binary file not shown.

After

Width:  |  Height:  |  Size: 812 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 820 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 816 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 814 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 840 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 844 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 838 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 877 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 833 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 853 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 878 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 890 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 919 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 937 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 941 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 964 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 980 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1014 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 849 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 887 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 965 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1008 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 818 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 895 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 930 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 977 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1006 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 852 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 779 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 748 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 787 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 759 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 742 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 736 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 716 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 723 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 755 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 779 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 791 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 792 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 804 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 814 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 816 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 773 KiB

Some files were not shown because too many files have changed in this diff Show More