Isaacgv commited on
Commit
5b24840
·
1 Parent(s): 5aecbb0
app.py CHANGED
@@ -9,14 +9,13 @@ Date : 2023-03-16
9
  Title : Inference With Gradio running an onnxruntime backend
10
  """
11
 
 
12
  import os
 
 
13
 
14
  import gradio as gr
15
-
16
  import requests
17
- from pathlib import Path
18
- import inspect
19
- import shutil
20
 
21
  import sys
22
  sys.path.append(".")
@@ -24,6 +23,8 @@ sys.path.append(".")
24
  from config_parser import *
25
  from inferencer import *
26
 
 
 
27
  gr.close_all()
28
 
29
 
@@ -32,9 +33,13 @@ def format_examples(task_number, product, product_example):
32
  examples_folder = Path(f"examples/{product}")
33
  os.makedirs(examples_folder, exist_ok=True)
34
  filepath = Path(examples_folder / f'{product_example.split("/")[-1]}')
35
- with open(filepath, "wb") as f:
36
- f.write(response.content)
37
- return [f"task{task_number+1}", product, filepath]
 
 
 
 
38
 
39
 
40
  def generate_parralel_interface(task_number, product):
@@ -113,21 +118,21 @@ def create_interface(task_number, product, model_number):
113
  allow_flagging="never",
114
  css="footer {visibility: hidden} body}, .gradio-container {background-color: white}",
115
  inputs=[
116
- gr.Textbox(
117
- value=f"task{task_number+1}",
118
- label="Tasks",
119
- visible=False,
120
- interactive=False,
121
- ),
122
- gr.Dropdown(
123
- tasks_products[task_number],
124
- type="value",
125
- value=product,
126
- label="Choix",
127
- # visible=True if len(tasks_products[task_number]) > 1 else False,
128
- visible=False,
129
- info="Sur quel type de produit, voulez vous lancer l'analyse ?",
130
- ),
131
  gr.Image(
132
  label="Image à analyser",
133
  shape=None,
 
9
  Title : Inference With Gradio running an onnxruntime backend
10
  """
11
 
12
+ import inspect
13
  import os
14
+ import shutil
15
+ from pathlib import Path
16
 
17
  import gradio as gr
 
18
  import requests
 
 
 
19
 
20
  import sys
21
  sys.path.append(".")
 
23
  from config_parser import *
24
  from inferencer import *
25
 
26
+
27
+
28
  gr.close_all()
29
 
30
 
 
33
  examples_folder = Path(f"examples/{product}")
34
  os.makedirs(examples_folder, exist_ok=True)
35
  filepath = Path(examples_folder / f'{product_example.split("/")[-1]}')
36
+ if filepath.exists():
37
+ pass
38
+ else:
39
+ with open(filepath, "wb") as f:
40
+ f.write(response.content)
41
+ # return [f"task{task_number+1}", product, filepath]
42
+ return [filepath]
43
 
44
 
45
  def generate_parralel_interface(task_number, product):
 
118
  allow_flagging="never",
119
  css="footer {visibility: hidden} body}, .gradio-container {background-color: white}",
120
  inputs=[
121
+ # gr.Textbox(
122
+ # value=f"task{task_number+1}",
123
+ # label="Tasks",
124
+ # visible=False,
125
+ # interactive=False,
126
+ # ),
127
+ # gr.Dropdown(
128
+ # tasks_products[task_number],
129
+ # type="value",
130
+ # value=product,
131
+ # label="Choix",
132
+ # # visible=True if len(tasks_products[task_number]) > 1 else False,
133
+ # visible=False,
134
+ # info="Sur quel type de produit, voulez vous lancer l'analyse ?",
135
+ # ),
136
  gr.Image(
137
  label="Image à analyser",
138
  shape=None,
build_image.sh DELETED
@@ -1,8 +0,0 @@
1
- #!/bin/bash -e
2
- image_name=gcr.io/tough-variety-310920/openvino_inference
3
- image_tag=1.0.1
4
- full_image_name=${image_name}:${image_tag}
5
-
6
- cd "$(dirname "$0")"
7
- docker build -t "${full_image_name}" .
8
- docker push "$full_image_name"
 
 
 
 
 
 
 
 
 
config_file/.DS_Store ADDED
Binary file (6.15 kB). View file
 
config_file/configtest.json DELETED
@@ -1,100 +0,0 @@
1
- {
2
- "title": "YVES ROCHER",
3
- "description": "Démonstration des algos de reconnaissance d'étiquetage/bouchage correct",
4
- "tasks": {
5
- "task1": {
6
- "shortname": "Étiquetage",
7
- "name": {
8
- "en": "Quality Control of Labels",
9
- "fr": "Contrôle de l'Étiquetage"
10
- },
11
- "description": {
12
- "en": "",
13
- "fr": "Est-ce que l'étiquette est bien positionnée"
14
- },
15
- "products":[
16
- "497 Pure Algue 200ml",
17
- "505 Pure Calmille 200ml",
18
- "614 Eco Douche 100ml",
19
- "648 Hair Care 300ml"
20
- ],
21
- "models": {
22
- "497 Pure Algue 200ml": {
23
- "type": "classification",
24
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/po2xfZzK0KtWZUpXrFjZ/model.onnx",
25
- "input_shape": 224,
26
- "mean": [0.485, 0.456, 0.406],
27
- "std": [0.229, 0.224, 0.225],
28
- "class_names": ["Étiquetage incorrect", "Étiquetage correct"]
29
- },
30
- "505 Pure Calmille 200ml": {
31
- "type": "classification",
32
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/po2xfZzK0KtWZUpXrFjZ/model.onnx",
33
- "input_shape": 224,
34
- "mean": [0.485, 0.456, 0.406],
35
- "std": [0.229, 0.224, 0.225],
36
- "class_names": ["Étiquetage incorrect", "Étiquetage correct"]
37
- },
38
- "614 Eco Douche 100ml": {
39
- "type": "classification",
40
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/po2xfZzK0KtWZUpXrFjZ/model.onnx",
41
- "input_shape": 224,
42
- "mean": [0.485, 0.456, 0.406],
43
- "std": [0.229, 0.224, 0.225],
44
- "class_names": ["Étiquetage incorrect", "Étiquetage correct"]
45
- },
46
- "648 Hair Care 300ml": {
47
- "type": "classification",
48
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/po2xfZzK0KtWZUpXrFjZ/model.onnx",
49
- "input_shape": 224,
50
- "mean": [0.485, 0.456, 0.406],
51
- "std": [0.229, 0.224, 0.225],
52
- "class_names": ["Étiquetage incorrect", "Étiquetage correct"]
53
- }
54
- }
55
- },
56
- "task2": {
57
- "shortname": "Bouchage",
58
- "name": {
59
- "en": "Quality Control of Corck Screwing",
60
- "fr": "Contrôle du Bouchage"
61
- },
62
- "description": {
63
- "en": "",
64
- "fr": "Est-ce que le bouchon est bien positionné et entièrement vissé"
65
- },
66
- "products":[
67
- "187 Hamamelis 300ml",
68
- "550 SVC 300ml",
69
- "600 PN 500 ml"
70
- ],
71
- "models": {
72
- "187 Hamamelis 300ml":{
73
- "type": "classification",
74
- "path": "/Users/bastien/Downloads/model_corck_screwing.onnx",
75
- "input_shape": 256,
76
- "mean": [0.485, 0.456, 0.406],
77
- "std": [0.229, 0.224, 0.225],
78
- "class_names": ["Bouchage incorrect", "Bouchage correct"]
79
- },
80
- "550 SVC 300ml": {
81
- "type": "classification",
82
- "path": "/Users/bastien/Downloads/model_corck_screwing.onnx",
83
- "input_shape": 256,
84
- "mean": [0.485, 0.456, 0.406],
85
- "std": [0.229, 0.224, 0.225],
86
- "class_names": ["Bouchage incorrect", "Bouchage correct"]
87
- },
88
- "600 PN 500 ml": {
89
- "type": "classification",
90
- "path": "/Users/bastien/Downloads/model_corck_screwing.onnx",
91
- "input_shape": 256,
92
- "mean": [0.485, 0.456, 0.406],
93
- "std": [0.229, 0.224, 0.225],
94
- "class_names": ["Bouchage incorrect", "Bouchage correct"]
95
- }
96
- }
97
- }
98
- }
99
- }
100
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
config_file/demo_full_yvesrocher.json DELETED
@@ -1,209 +0,0 @@
1
- {
2
- "title": "YVES ROCHER",
3
- "description": "Démonstration des algos de reconnaissance d'étiquetage/bouchage correct",
4
- "tasks": {
5
- "task1": {
6
- "shortname": "Étiquetage",
7
- "name": {
8
- "en": "Quality Control of Labels",
9
- "fr": "Contrôle de l'Étiquetage"
10
- },
11
- "description": {
12
- "en": "Is the label in the right position ?",
13
- "fr": "Est-ce que l'étiquette est bien positionnée ?"
14
- },
15
- "products": [
16
- "497 Pure Algue 200ml",
17
- "505 Pure Calmille 200ml",
18
- "614 Eco Douche 100ml",
19
- "648 Hair Care 300ml"
20
- ],
21
- "models": {
22
- "497 Pure Algue 200ml": [
23
- {
24
- "type": "classification",
25
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/po2xfZzK0KtWZUpXrFjZ/model.onnx",
26
- "input_shape": 224,
27
- "mean": [
28
- 0.485,
29
- 0.456,
30
- 0.406
31
- ],
32
- "std": [
33
- 0.229,
34
- 0.224,
35
- 0.225
36
- ],
37
- "class_names": [
38
- "Étiquetage correct",
39
- "Étiquetage incorrect"
40
- ]
41
- },
42
- {
43
- "type": "classification",
44
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/po2xfZzK0KtWZUpXrFjZ/model.onnx",
45
- "input_shape": 224,
46
- "mean": [
47
- 0.485,
48
- 0.456,
49
- 0.406
50
- ],
51
- "std": [
52
- 0.229,
53
- 0.224,
54
- 0.225
55
- ],
56
- "class_names": [
57
- "Étiquetage correct",
58
- "Étiquetage incorrect"
59
- ]
60
- }
61
- ],
62
- "505 Pure Calmille 200ml": [
63
- {
64
- "type": "classification",
65
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/po2xfZzK0KtWZUpXrFjZ/model.onnx",
66
- "input_shape": 224,
67
- "mean": [
68
- 0.485,
69
- 0.456,
70
- 0.406
71
- ],
72
- "std": [
73
- 0.229,
74
- 0.224,
75
- 0.225
76
- ],
77
- "class_names": [
78
- "Étiquetage correct",
79
- "Étiquetage incorrect"
80
- ]
81
- }
82
- ],
83
- "614 Eco Douche 100ml": [
84
- {
85
- "type": "classification",
86
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/po2xfZzK0KtWZUpXrFjZ/model.onnx",
87
- "input_shape": 224,
88
- "mean": [
89
- 0.485,
90
- 0.456,
91
- 0.406
92
- ],
93
- "std": [
94
- 0.229,
95
- 0.224,
96
- 0.225
97
- ],
98
- "class_names": [
99
- "Étiquetage correct",
100
- "Étiquetage incorrect"
101
- ]
102
- }
103
- ],
104
- "648 Hair Care 300ml": [
105
- {
106
- "type": "classification",
107
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/J5dAmDWboJNDouVkMVIL/model.onnx",
108
- "input_shape": 224,
109
- "mean": [
110
- 0.485,
111
- 0.456,
112
- 0.406
113
- ],
114
- "std": [
115
- 0.229,
116
- 0.224,
117
- 0.225
118
- ],
119
- "class_names": [
120
- "Étiquetage correct",
121
- "Étiquetage incorrect"
122
- ]
123
- }
124
- ]
125
- }
126
- },
127
- "task2": {
128
- "shortname": "Bouchage",
129
- "name": {
130
- "en": "Quality Control of Corck Screwing",
131
- "fr": "Contrôle du Bouchage"
132
- },
133
- "description": {
134
- "en": "Is the corck in the right position ?",
135
- "fr": "Est-ce que le bouchon est bien positionné et entièrement vissé ?"
136
- },
137
- "products": [
138
- "187 Hamamelis 300ml",
139
- "550 SVC 300ml",
140
- "600 PN 500 ml"
141
- ],
142
- "models": {
143
- "187 Hamamelis 300ml": [
144
- {
145
- "type": "classification",
146
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/Qp6BRHBcLq7KKxqCWqmV/model.onnx",
147
- "input_shape": 224,
148
- "mean": [
149
- 0.485,
150
- 0.456,
151
- 0.406
152
- ],
153
- "std": [
154
- 0.229,
155
- 0.224,
156
- 0.225
157
- ],
158
- "class_names": [
159
- "Bouchage correct",
160
- "Bouchage incorrect"
161
- ]
162
- }
163
- ],
164
- "550 SVC 300ml": [
165
- {
166
- "type": "anomaly_detection-classification",
167
- "path": "/Users/bastien/Downloads/model_corck_screwing.onnx",
168
- "input_shape": 256,
169
- "mean": [
170
- 0.485,
171
- 0.456,
172
- 0.406
173
- ],
174
- "std": [
175
- 0.229,
176
- 0.224,
177
- 0.225
178
- ],
179
- "class_names": [
180
- "Bouchage correct",
181
- "Bouchage incorrect"
182
- ]
183
- }
184
- ],
185
- "600 PN 500 ml": [
186
- {
187
- "type": "anomaly_detection-classification",
188
- "path": "/Users/bastien/Downloads/model_corck_screwing.onnx",
189
- "input_shape": 256,
190
- "mean": [
191
- 0.485,
192
- 0.456,
193
- 0.406
194
- ],
195
- "std": [
196
- 0.229,
197
- 0.224,
198
- 0.225
199
- ],
200
- "class_names": [
201
- "Bouchage correct",
202
- "Bouchage incorrect"
203
- ]
204
- }
205
- ]
206
- }
207
- }
208
- }
209
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
config_file/demo_testing_model_variant_yvesrocher.json DELETED
@@ -1,372 +0,0 @@
1
- {
2
- "title": "YVES ROCHER",
3
- "description": "Démonstration des algos de reconnaissance d'étiquetage/bouchage correct",
4
- "tasks": {
5
- "task1": {
6
- "shortname": "Étiquetage",
7
- "name": {
8
- "en": "Quality Control of Labels",
9
- "fr": "Contrôle de l'Étiquetage"
10
- },
11
- "description": {
12
- "en": "Is the label in the right position ?",
13
- "fr": "Est-ce que l'étiquette est bien positionnée ?"
14
- },
15
- "products": [
16
- "505 Pure Calmille 200ml"
17
- ],
18
- "models": {
19
- "505 Pure Calmille 200ml": [
20
- {
21
- "type": "classification",
22
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/dmeQ6Mae0HKDwkHBTdh2/model.onnx",
23
- "name": "Original Dataset",
24
- "input_shape": 224,
25
- "mean": [
26
- 0.485,
27
- 0.456,
28
- 0.406
29
- ],
30
- "std": [
31
- 0.229,
32
- 0.224,
33
- 0.225
34
- ],
35
- "class_names": [
36
- "Étiquetage correct",
37
- "Étiquetage incorrect"
38
- ],
39
- "examples": []
40
- }
41
- ],
42
- "648 Haire Care 300 ml": [
43
- {
44
- "type": "classification",
45
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/uDFdeazjnSzTnIE0JVSf/model.onnx",
46
- "name": "Original Dataset",
47
- "input_shape": 224,
48
- "mean": [
49
- 0.485,
50
- 0.456,
51
- 0.406
52
- ],
53
- "std": [
54
- 0.229,
55
- 0.224,
56
- 0.225
57
- ],
58
- "class_names": [
59
- "Étiquetage correct",
60
- "Étiquetage incorrect"
61
- ]
62
- },
63
- {
64
- "type": "classification",
65
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/J5dAmDWboJNDouVkMVIL/model.onnx",
66
- "name": "Original + Augmented AutoAlbumentations",
67
- "input_shape": 224,
68
- "mean": [
69
- 0.485,
70
- 0.456,
71
- 0.406
72
- ],
73
- "std": [
74
- 0.229,
75
- 0.224,
76
- 0.225
77
- ],
78
- "class_names": [
79
- "Étiquetage correct",
80
- "Étiquetage incorrect"
81
- ]
82
- }
83
- ]
84
- }
85
- },
86
- "task2": {
87
- "shortname": "Bouchage",
88
- "name": {
89
- "en": "Quality Control of Corck Screwing",
90
- "fr": "Contrôle du Bouchage"
91
- },
92
- "description": {
93
- "en": "Is the corck in the right position ?",
94
- "fr": "Est-ce que le bouchon est bien positionné et entièrement vissé ?"
95
- },
96
- "products": [
97
- "187 Hamamelis 300ml"
98
- ],
99
- "models": {
100
- "187 Hamamelis 300ml": [
101
- {
102
- "type": "classification",
103
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/3nkoTiBxDNBzqyGtE5w8/model.onnx",
104
- "name": "Original Dataset",
105
- "input_shape": 224,
106
- "mean": [
107
- 0.485,
108
- 0.456,
109
- 0.406
110
- ],
111
- "std": [
112
- 0.229,
113
- 0.224,
114
- 0.225
115
- ],
116
- "class_names": [
117
- "Bouchage correct",
118
- "Bouchage incorrect"
119
- ],
120
- "examples": [
121
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000000_NOK.bmp",
122
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000001_NOK.bmp",
123
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000003_NOK.bmp",
124
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000004_NOK.bmp",
125
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000006_NOK.bmp",
126
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000007_NOK.bmp",
127
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000008_NOK.bmp",
128
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000009_NOK.bmp",
129
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000010_NOK.bmp",
130
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000011_NOK.bmp",
131
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000012_NOK.bmp",
132
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000013_NOK.bmp",
133
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000014_NOK.bmp",
134
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000015_NOK.bmp",
135
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000000_OK.bmp",
136
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000001_OK.bmp",
137
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000002_OK.bmp",
138
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000003_OK.bmp",
139
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000004_OK.bmp",
140
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000005_OK.bmp",
141
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000006_OK.bmp",
142
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000007_OK.bmp",
143
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000008_OK.bmp",
144
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000009_OK.bmp",
145
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000010_OK.bmp",
146
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000011_OK.bmp",
147
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000012_OK.bmp",
148
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000013_OK.bmp",
149
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000014_OK.bmp",
150
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000015_OK.bmp",
151
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000016_OK.bmp",
152
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000017_OK.bmp",
153
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000018_OK.bmp",
154
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000019_OK.bmp",
155
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000020_OK.bmp",
156
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000021_OK.bmp",
157
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000022_OK.bmp",
158
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000023_OK.bmp",
159
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000024_OK.bmp",
160
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000025_OK.bmp",
161
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000026_OK.bmp",
162
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000027_OK.bmp",
163
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000028_OK.bmp",
164
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000029_OK.bmp",
165
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000030_OK.bmp",
166
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000031_OK.bmp",
167
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000032_OK.bmp",
168
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000033_OK.bmp",
169
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000034_OK.bmp",
170
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000035_OK.bmp",
171
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000036_OK.bmp",
172
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000037_OK.bmp",
173
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000038_OK.bmp",
174
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000039_OK.bmp",
175
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000040_OK.bmp",
176
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000041_OK.bmp",
177
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000042_OK.bmp",
178
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000043_OK.bmp",
179
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000044_OK.bmp",
180
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000045_OK.bmp",
181
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000046_OK.bmp",
182
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000047_OK.bmp",
183
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000048_OK.bmp",
184
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000049_OK.bmp",
185
- "https://automi-test-models.s3.eu-west-3.amazonaws.com/YVES/Hamamelis300/188_Bouchage_L01_00000050_OK.bmp"
186
- ]
187
- },
188
- {
189
- "type": "classification",
190
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/Qp6BRHBcLq7KKxqCWqmV/model.onnx",
191
- "name": "Original + Stable Diffusion 1 - Experiment 1",
192
- "input_shape": 224,
193
- "mean": [
194
- 0.485,
195
- 0.456,
196
- 0.406
197
- ],
198
- "std": [
199
- 0.229,
200
- 0.224,
201
- 0.225
202
- ],
203
- "class_names": [
204
- "Bouchage correct",
205
- "Bouchage incorrect"
206
- ]
207
- },
208
- {
209
- "type": "classification",
210
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/1vQ282qVBOG1lomT15pl/model.onnx",
211
- "name": "Original + Stable Diffusion 2 - Experiment 1",
212
- "input_shape": 224,
213
- "mean": [
214
- 0.485,
215
- 0.456,
216
- 0.406
217
- ],
218
- "std": [
219
- 0.229,
220
- 0.224,
221
- 0.225
222
- ],
223
- "class_names": [
224
- "Bouchage correct",
225
- "Bouchage incorrect"
226
- ]
227
- },
228
- {
229
- "type": "classification",
230
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/8h2CS7Mr3Sw7XYMklbbN/model.onnx",
231
- "name": "Original + Stable Diffusion 2 - Experiment 2",
232
- "input_shape": 224,
233
- "mean": [
234
- 0.485,
235
- 0.456,
236
- 0.406
237
- ],
238
- "std": [
239
- 0.229,
240
- 0.224,
241
- 0.225
242
- ],
243
- "class_names": [
244
- "Bouchage correct",
245
- "Bouchage incorrect"
246
- ]
247
- },
248
- {
249
- "type": "classification",
250
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/qFnoMAChnLZxxOsjJeok/model.onnx",
251
- "name": "Original + Augmented NOK - Experiment 1",
252
- "input_shape": 224,
253
- "mean": [
254
- 0.485,
255
- 0.456,
256
- 0.406
257
- ],
258
- "std": [
259
- 0.229,
260
- 0.224,
261
- 0.225
262
- ],
263
- "class_names": [
264
- "Bouchage correct",
265
- "Bouchage incorrect"
266
- ]
267
- },
268
- {
269
- "type": "classification",
270
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/BNY0rdZr902ZAHiTQJVC/model.onnx",
271
- "name": "Original + Augmented NOK + Stable Diffusion 1+2 - Experiment 1",
272
- "input_shape": 224,
273
- "mean": [
274
- 0.485,
275
- 0.456,
276
- 0.406
277
- ],
278
- "std": [
279
- 0.229,
280
- 0.224,
281
- 0.225
282
- ],
283
- "class_names": [
284
- "Bouchage correct",
285
- "Bouchage incorrect"
286
- ]
287
- },
288
- {
289
- "type": "classification",
290
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/9v0LPo1vqIrC3eTg4MGa/model.onnx",
291
- "name": "Original + Stable Diffusion 1+2 - Experiment 1",
292
- "input_shape": 224,
293
- "mean": [
294
- 0.485,
295
- 0.456,
296
- 0.406
297
- ],
298
- "std": [
299
- 0.229,
300
- 0.224,
301
- 0.225
302
- ],
303
- "class_names": [
304
- "Bouchage correct",
305
- "Bouchage incorrect"
306
- ]
307
- },
308
- {
309
- "type": "classification",
310
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/4GRWxgHz72C8bLp2uUrE/model.onnx",
311
- "name": "Original + Stable Diffusion 1+2 - Experiment 2",
312
- "input_shape": 224,
313
- "mean": [
314
- 0.485,
315
- 0.456,
316
- 0.406
317
- ],
318
- "std": [
319
- 0.229,
320
- 0.224,
321
- 0.225
322
- ],
323
- "class_names": [
324
- "Bouchage correct",
325
- "Bouchage incorrect"
326
- ]
327
- },
328
- {
329
- "type": "classification",
330
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/ruTW9is2RXQROxCJvTH5/model.onnx",
331
- "name": "Original + Best of Stable Diffusion 1+2 - Experiment 1",
332
- "input_shape": 224,
333
- "mean": [
334
- 0.485,
335
- 0.456,
336
- 0.406
337
- ],
338
- "std": [
339
- 0.229,
340
- 0.224,
341
- 0.225
342
- ],
343
- "class_names": [
344
- "Bouchage correct",
345
- "Bouchage incorrect"
346
- ]
347
- },
348
- {
349
- "type": "classification",
350
- "path": "https://automi-test-models.s3.eu-west-3.amazonaws.com/inference-pipeline/eMbXMRNbdUOGm6G9AYsF/model.onnx",
351
- "name": "Original + Best of Stable Diffusion 1+2 - Experiment 2",
352
- "input_shape": 224,
353
- "mean": [
354
- 0.485,
355
- 0.456,
356
- 0.406
357
- ],
358
- "std": [
359
- 0.229,
360
- 0.224,
361
- 0.225
362
- ],
363
- "class_names": [
364
- "Bouchage correct",
365
- "Bouchage incorrect"
366
- ]
367
- }
368
- ]
369
- }
370
- }
371
- }
372
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inferencer.py CHANGED
@@ -16,8 +16,8 @@ from config_parser import *
16
  from torchvision import transforms
17
 
18
 
19
- def make_func(model_number):
20
- def _analysis(task, product, image):
21
  """
22
  Main function that process inference and return results strings
23
  Args:
@@ -27,7 +27,7 @@ def make_func(model_number):
27
  Returns:
28
  - String including label and confidence of the model
29
  """
30
- input_image = pre_process_all(task, product, image, model_number=model_number)
31
  result = inference(task, product, input_image, model_number=model_number)
32
  logging.log(level=logging.DEBUG, msg=result)
33
  return result
@@ -63,7 +63,7 @@ for task in config["tasks"].keys():
63
  "model"
64
  ] = ort.InferenceSession(r if model_path.startswith("http") else model_path)
65
  inferencer_arr[task][product][str(model_number)]["function"] = make_func(
66
- model_number
67
  )
68
  inferencer_arr[task][product][str(model_number)]["input_name"] = (
69
  inferencer_arr[task][product][str(model_number)]["model"]
@@ -104,7 +104,7 @@ def is_anomalous_classification(task, product, model_number, prediction, meta_da
104
  return pred_label, pred_score
105
 
106
 
107
- def pre_process_all(task, product, image, model_number):
108
  # model_number = model_number-1
109
  logging.log(level=logging.INFO, msg=f"Task {task}")
110
  logging.log(level=logging.INFO, msg=f"Product {product}")
 
16
  from torchvision import transforms
17
 
18
 
19
+ def make_func(task, product, model_number):
20
+ def _analysis(image):
21
  """
22
  Main function that process inference and return results strings
23
  Args:
 
27
  Returns:
28
  - String including label and confidence of the model
29
  """
30
+ input_image = pre_process_all(task=task, product=product, model_number=model_number, image=image)
31
  result = inference(task, product, input_image, model_number=model_number)
32
  logging.log(level=logging.DEBUG, msg=result)
33
  return result
 
63
  "model"
64
  ] = ort.InferenceSession(r if model_path.startswith("http") else model_path)
65
  inferencer_arr[task][product][str(model_number)]["function"] = make_func(
66
+ task, product, model_number
67
  )
68
  inferencer_arr[task][product][str(model_number)]["input_name"] = (
69
  inferencer_arr[task][product][str(model_number)]["model"]
 
104
  return pred_label, pred_score
105
 
106
 
107
+ def pre_process_all(task, product, model_number, image):
108
  # model_number = model_number-1
109
  logging.log(level=logging.INFO, msg=f"Task {task}")
110
  logging.log(level=logging.INFO, msg=f"Product {product}")
requirements_poetry.txt ADDED
The diff for this file is too large to render. See raw diff