Jules Musquin commited on
Commit
f0064c6
·
1 Parent(s): 0f6542f

[ADD] Adding a inference script to validate performance of models compared to each other.

Browse files
.gitignore CHANGED
@@ -30,4 +30,5 @@ lib64/
30
  #website
31
  generated_html/
32
  annotations/
33
- dataset/
 
 
30
  #website
31
  generated_html/
32
  annotations/
33
+ dataset/
34
+ test/
inference.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import glob
3
+ import os
4
+ import matplotlib.pyplot as plt
5
+
6
+ from ultralytics import YOLO
7
+
8
+ # uv run predict.py path_to_model.pt path_to_images ./test
9
+ def parse_args() -> argparse.Namespace:
10
+ parser = argparse.ArgumentParser(
11
+ description="Prédiction YOLO sur un dossier d'images avec sauvegarde des résultats annotés."
12
+ )
13
+
14
+ parser.add_argument(
15
+ "model_path",
16
+ type=str,
17
+ help="Chemin vers le modèle YOLO (.pt)",
18
+ )
19
+ parser.add_argument(
20
+ "images_path",
21
+ type=str,
22
+ help="Dossier contenant les images à traiter",
23
+ )
24
+ parser.add_argument(
25
+ "output_path",
26
+ type=str,
27
+ help="Dossier de sortie pour les images annotées",
28
+ )
29
+
30
+ return parser.parse_args()
31
+
32
+
33
+ def predict(model_path:str, images_path:str, output_path:str):
34
+ model = YOLO(model_path)
35
+ images = glob.glob(os.path.join(images_path, "*.jpg"))
36
+ selection = images[:25]
37
+ print(selection)
38
+ results = model(selection)
39
+ name_model = model_path.split('/')
40
+
41
+ output_dir = output_path
42
+ model_dir = name_model[0]
43
+
44
+ if not os.path.isdir(output_dir):
45
+ os.mkdir(output_dir)
46
+
47
+ for i, result in enumerate(results):
48
+ boxes = result.boxes
49
+ im_array = result.plot() # retourne un array numpy BGR avec les boxes dessinées
50
+
51
+ plt.figure(figsize=(10, 10))
52
+ plt.imshow(im_array[..., ::-1]) # conversion BGR -> RGB pour matplotlib
53
+ plt.axis("off")
54
+ plt.show()
55
+
56
+ result.save(filename=os.path.join(output_dir, model_dir, f"result_{i}.jpg")) # sauvegarde avec nom unique
57
+
58
+ def main() -> None:
59
+ args = parse_args()
60
+ predict(args.model_path, args.images_path, args.output_path)
61
+
62
+ if __name__ == "__main__":
63
+ main()
64
+
predict.ipynb DELETED
File without changes
requirement.txt CHANGED
@@ -1,76 +1,128 @@
1
  anyio==4.14.2
2
- apturl==0.5.2
3
- blinker==1.4
4
- Brlapi==0.8.3
5
- certifi==2020.6.20
6
- chardet==4.0.0
7
- click==8.4.2
8
- colorama==0.4.4
9
- command-not-found==0.3
10
- cryptography==3.4.8
11
- cupshelpers==1.0
12
- dbus-python==1.2.18
13
- defer==1.0.6
14
- distro==1.7.0
15
- distro-info==1.1+ubuntu0.2
 
 
 
 
 
16
  exceptiongroup==1.3.1
17
- filelock==3.31.1
 
 
 
18
  fsspec==2026.6.0
19
  h11==0.16.0
20
- hf==1.24.0
21
- hf-xet==1.5.2
22
  httpcore==1.0.9
23
- httplib2==0.20.2
24
  httpx==0.28.1
25
- huggingface_hub==1.24.0
26
- idna==3.3
27
- importlib-metadata==4.6.4
28
- jeepney==0.7.1
29
- keyring==23.5.0
30
- language-selector==0.1
31
- launchpadlib==1.10.16
32
- lazr.restfulclient==0.14.4
33
- lazr.uri==1.0.6
34
- louis==3.20.0
35
- macaroonbakery==1.3.1
36
- more-itertools==8.10.0
37
- netifaces==0.11.0
38
- oauthlib==3.2.0
39
- olefile==0.46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  packaging==26.2
41
- pexpect==4.8.0
42
- Pillow==9.0.1
43
- protobuf==3.12.4
 
 
 
 
 
44
  ptyprocess==0.7.0
45
- pycairo==1.20.1
46
- pycups==2.0.1
47
- PyGObject==3.42.1
48
- PyJWT==2.3.0
49
- pymacaroons==0.13.0
50
- PyNaCl==1.5.0
51
- pyparsing==2.4.7
52
- pyRFC3339==1.1
53
- python-apt==2.4.0+ubuntu4.1
54
- python-dateutil==2.8.1
55
- python-debian==0.1.43+ubuntu1.1
56
- pytz==2022.1
57
- pyxdg==0.27
58
- PyYAML==5.4.1
59
- reportlab==3.6.8
60
- requests==2.25.1
61
- screen-resolution-extra==0.0.0
62
- SecretStorage==3.3.1
63
- six==1.16.0
64
- ssh-import-id==5.11
65
- systemd-python==234
66
- tqdm==4.69.0
67
- typing_extensions==4.16.0
68
- ubuntu-drivers-common==0.0.0
69
- ubuntu-pro-client==8001
70
- ufw==0.36.1
71
- unattended-upgrades==0.1
72
- urllib3==1.26.5
73
- wadllib==1.3.6
74
- xdg==5
75
- xkit==0.0.0
76
- zipp==1.0.0
 
 
 
 
 
1
  anyio==4.14.2
2
+ argon2-cffi==25.1.0
3
+ argon2-cffi-bindings==25.1.0
4
+ arrow==1.4.0
5
+ asttokens==3.0.2
6
+ async-lru==2.3.0
7
+ attrs==26.1.0
8
+ babel==2.18.0
9
+ beautifulsoup4==4.15.0
10
+ bleach==6.4.0
11
+ certifi==2026.7.22
12
+ cffi==2.1.0
13
+ charset-normalizer==3.4.9
14
+ comm==0.2.3
15
+ cuda-bindings==13.3.1
16
+ cuda-pathfinder==1.6.0
17
+ cuda-toolkit==13.0.3.0
18
+ debugpy==1.8.21
19
+ decorator==5.3.1
20
+ defusedxml==0.7.1
21
  exceptiongroup==1.3.1
22
+ executing==2.2.1
23
+ fastjsonschema==2.21.2
24
+ filelock==3.32.0
25
+ fqdn==1.5.1
26
  fsspec==2026.6.0
27
  h11==0.16.0
 
 
28
  httpcore==1.0.9
 
29
  httpx==0.28.1
30
+ idna==3.18
31
+ ipykernel==7.3.0
32
+ ipython==8.39.0
33
+ ipywidgets==8.1.8
34
+ isoduration==20.11.0
35
+ jedi==0.20.0
36
+ jinja2==3.1.6
37
+ json5==0.15.0
38
+ jsonpointer==3.1.1
39
+ jsonschema==4.26.0
40
+ jsonschema-specifications==2025.9.1
41
+ jupyter==1.1.1
42
+ jupyter-builder==1.1.1
43
+ jupyter-client==8.9.1
44
+ jupyter-console==6.6.3
45
+ jupyter-core==5.9.1
46
+ jupyter-events==0.12.1
47
+ jupyter-lsp==2.3.1
48
+ jupyter-server==2.20.0
49
+ jupyter-server-terminals==0.5.4
50
+ jupyterlab==4.6.2
51
+ jupyterlab-pygments==0.3.0
52
+ jupyterlab-server==2.28.0
53
+ jupyterlab-widgets==3.0.16
54
+ lark==1.3.1
55
+ markupsafe==3.0.3
56
+ matplotlib-inline==0.2.2
57
+ mistune==3.3.4
58
+ mpmath==1.3.0
59
+ nbclient==0.11.0
60
+ nbconvert==7.17.1
61
+ nbformat==5.10.4
62
+ nest-asyncio2==1.7.2
63
+ networkx==3.4.2
64
+ notebook==7.6.1
65
+ notebook-shim==0.2.4
66
+ numpy==2.2.6
67
+ nvidia-cublas==13.1.1.3
68
+ nvidia-cuda-cupti==13.0.85
69
+ nvidia-cuda-nvrtc==13.0.88
70
+ nvidia-cuda-runtime==13.0.96
71
+ nvidia-cudnn-cu13==9.20.0.48
72
+ nvidia-cufft==12.0.0.61
73
+ nvidia-cufile==1.15.1.6
74
+ nvidia-curand==10.4.0.35
75
+ nvidia-cusolver==12.0.4.66
76
+ nvidia-cusparse==12.6.3.3
77
+ nvidia-cusparselt-cu13==0.8.1
78
+ nvidia-nccl-cu13==2.29.7
79
+ nvidia-nvjitlink==13.3.33
80
+ nvidia-nvshmem-cu13==3.4.5
81
+ nvidia-nvtx==13.0.85
82
+ overrides==7.7.0
83
  packaging==26.2
84
+ pandocfilters==1.5.1
85
+ parso==0.8.7
86
+ pexpect==4.9.0
87
+ pillow==12.3.0
88
+ platformdirs==4.11.0
89
+ prometheus-client==0.25.0
90
+ prompt-toolkit==3.0.52
91
+ psutil==7.2.2
92
  ptyprocess==0.7.0
93
+ pure-eval==0.2.3
94
+ pycparser==3.0
95
+ pygments==2.20.0
96
+ python-dateutil==2.9.0.post0
97
+ python-json-logger==4.1.0
98
+ pyyaml==6.0.3
99
+ pyzmq==27.1.0
100
+ referencing==0.37.0
101
+ requests==2.34.2
102
+ rfc3339-validator==0.1.4
103
+ rfc3986-validator==0.1.1
104
+ rfc3987-syntax==1.1.0
105
+ rpds-py==0.30.0
106
+ send2trash==2.1.0
107
+ setuptools==83.0.0
108
+ six==1.17.0
109
+ soupsieve==2.9.1
110
+ stack-data==0.6.3
111
+ sympy==1.14.0
112
+ terminado==0.18.1
113
+ tinycss2==1.5.1
114
+ tomli==2.4.1
115
+ torch==2.13.0
116
+ torchvision==0.28.0
117
+ tornado==6.5.7
118
+ traitlets==5.15.1
119
+ triton==3.7.1
120
+ typing-extensions==4.16.0
121
+ tzdata==2026.3
122
+ uri-template==1.3.0
123
+ urllib3==2.7.0
124
+ wcwidth==0.8.2
125
+ webcolors==25.10.0
126
+ webencodings==0.5.1
127
+ websocket-client==1.9.0
128
+ widgetsnbextension==4.0.15
{test → test_images}/wit396_pdf545/images/1.jpg RENAMED
File without changes
{test → test_images}/wit396_pdf545/images/2.jpg RENAMED
File without changes
{test → test_images}/wit396_pdf545/labels/1.txt RENAMED
File without changes
{test → test_images}/wit396_pdf545/labels/2.txt RENAMED
File without changes