Spaces:
Sleeping
Sleeping
qqubb
commited on
Commit
·
6cbc9d8
1
Parent(s):
ffb48a2
improve code in check_intended_purpose
Browse files- compliance_analysis.py +38 -89
- data_cc.yaml +1 -1
- project_cc.yaml +2 -2
compliance_analysis.py
CHANGED
@@ -116,106 +116,55 @@ def run_compliance_analysis_on_model(model_cc_yaml):
|
|
116 |
|
117 |
return msg
|
118 |
|
119 |
-
def
|
120 |
|
121 |
# We want to run this function for everything classified as a high_risk_ai_system
|
122 |
# We also need to run it for all
|
123 |
# Add any of the intended purposes of the overall project to a set of intended purposes
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
if project_cc_yaml['high_risk_ai_system']['public_assistance'] == True:
|
144 |
-
intended_purpose = "public_assistance"
|
145 |
-
if project_cc_yaml['high_risk_ai_system']['victim_assessment'] == True:
|
146 |
-
intended_purpose = "victim_assessment"
|
147 |
-
if project_cc_yaml['high_risk_ai_system']['polygraph'] == True:
|
148 |
-
intended_purpose = "polygraph"
|
149 |
-
if project_cc_yaml['high_risk_ai_system']['judicial'] == True:
|
150 |
-
intended_purpose = "judicial"
|
151 |
|
152 |
# For each Data CC, put the intended uses in a set and then make sure the Project's intended use is in the set
|
153 |
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
dataset_intended_purpose.add("product_regulated_watercraft")
|
164 |
-
if data_cc_yaml['intended_purpose']['biometric_categorization'] == True:
|
165 |
-
dataset_intended_purpose.add("biometric_categorization")
|
166 |
-
if data_cc_yaml['intended_purpose']['emotion_recognition'] == True:
|
167 |
-
dataset_intended_purpose.add("emotion_recognition")
|
168 |
-
if data_cc_yaml['intended_purpose']['critical_infrastructure'] == True:
|
169 |
-
dataset_intended_purpose.add("critical_infrastructure")
|
170 |
-
if data_cc_yaml['intended_purpose']['admission'] == True:
|
171 |
-
dataset_intended_purpose.add("admission")
|
172 |
-
if data_cc_yaml['intended_purpose']['recruitment'] == True:
|
173 |
-
dataset_intended_purpose.add("recruitment")
|
174 |
-
if data_cc_yaml['intended_purpose']['public_assistance'] == True:
|
175 |
-
dataset_intended_purpose.add("public_assistance")
|
176 |
-
if data_cc_yaml['intended_purpose']['victim_assessment'] == True:
|
177 |
-
dataset_intended_purpose.add("victim_assessment")
|
178 |
-
if data_cc_yaml['intended_purpose']['polygraph'] == True:
|
179 |
-
dataset_intended_purpose.add("polygraph")
|
180 |
-
if data_cc_yaml['intended_purpose']['judicial'] == True:
|
181 |
-
dataset_intended_purpose.add("judicial")
|
182 |
-
|
183 |
-
if project_intended_purpose not in dataset_intended_purpose:
|
184 |
-
print("You are not compliant")
|
185 |
|
186 |
# Now do the exact same thing for all models
|
187 |
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
if model_cc_yaml['intended_purpose']['biometric_categorization'] == True:
|
199 |
-
dataset_intended_purpose.add("biometric_categorization")
|
200 |
-
if model_cc_yaml['intended_purpose']['emotion_recognition'] == True:
|
201 |
-
dataset_intended_purpose.add("emotion_recognition")
|
202 |
-
if model_cc_yaml['intended_purpose']['critical_infrastructure'] == True:
|
203 |
-
dataset_intended_purpose.add("critical_infrastructure")
|
204 |
-
if model_cc_yaml['intended_purpose']['admission'] == True:
|
205 |
-
dataset_intended_purpose.add("admission")
|
206 |
-
if model_cc_yaml['intended_purpose']['recruitment'] == True:
|
207 |
-
dataset_intended_purpose.add("recruitment")
|
208 |
-
if model_cc_yaml['intended_purpose']['public_assistance'] == True:
|
209 |
-
dataset_intended_purpose.add("public_assistance")
|
210 |
-
if model_cc_yaml['intended_purpose']['victim_assessment'] == True:
|
211 |
-
dataset_intended_purpose.add("victim_assessment")
|
212 |
-
if model_cc_yaml['intended_purpose']['polygraph'] == True:
|
213 |
-
dataset_intended_purpose.add("polygraph")
|
214 |
-
if model_cc_yaml['intended_purpose']['judicial'] == True:
|
215 |
-
dataset_intended_purpose.add("judicial")
|
216 |
-
|
217 |
-
if project_intended_purpose not in dataset_intended_purpose:
|
218 |
-
print("You are not compliant")
|
219 |
|
220 |
|
221 |
|
|
|
116 |
|
117 |
return msg
|
118 |
|
119 |
+
def check_intended_purpose():
|
120 |
|
121 |
# We want to run this function for everything classified as a high_risk_ai_system
|
122 |
# We also need to run it for all
|
123 |
# Add any of the intended purposes of the overall project to a set of intended purposes
|
124 |
|
125 |
+
# intended_purpose = ['safety_component',
|
126 |
+
# "product_regulated_machinery",
|
127 |
+
# "product_regulated_toy",
|
128 |
+
# "product_regulated_watercraft",
|
129 |
+
# "biometric_categorization",
|
130 |
+
# "emotion_recognition",
|
131 |
+
# "critical_infrastructure",
|
132 |
+
# "admission",
|
133 |
+
# "recruitment",
|
134 |
+
# "public_assistance",
|
135 |
+
# "victim_assessment",
|
136 |
+
# "polygraph",
|
137 |
+
# "judicial"]
|
138 |
+
|
139 |
+
project_intended_purposes = []
|
140 |
+
for key in project_cc_yaml['high_risk_ai_system']:
|
141 |
+
if project_cc_yaml['high_risk_ai_system'][f'{key}']['value']:
|
142 |
+
project_intended_purposes.append(key)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
|
144 |
# For each Data CC, put the intended uses in a set and then make sure the Project's intended use is in the set
|
145 |
|
146 |
+
msg = ''
|
147 |
+
dataset_intended_purposes = []
|
148 |
+
for key in data_cc_yaml['high_risk_ai_system']:
|
149 |
+
if data_cc_yaml['high_risk_ai_system'][f'{key}']['value']:
|
150 |
+
dataset_intended_purposes.append(key)
|
151 |
+
|
152 |
+
for purpose in project_intended_purposes:
|
153 |
+
if purpose not in dataset_intended_purposes:
|
154 |
+
msg = f"You are not compliant because {purpose} is not a valid purpose"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
|
156 |
# Now do the exact same thing for all models
|
157 |
|
158 |
+
model_intended_purposes = []
|
159 |
+
for key in model_cc_yaml['high_risk_ai_system']:
|
160 |
+
if model_cc_yaml['high_risk_ai_system'][f'{key}']['value']:
|
161 |
+
model_intended_purposes.append(key)
|
162 |
+
|
163 |
+
for purpose in project_intended_purposes:
|
164 |
+
if purpose not in model_intended_purposes:
|
165 |
+
msg = f"You are not compliant because {purpose} is not a valid purpose"
|
166 |
+
|
167 |
+
return msg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
|
169 |
|
170 |
|
data_cc.yaml
CHANGED
@@ -19,7 +19,7 @@ intended_purpose:
|
|
19 |
value: !!bool false
|
20 |
critical_infrastructure: # Art. 6(2); Annex III(2)
|
21 |
verbose: 'This dataset is appropriate to use for AI projects involving safety components in the management and operation of critical digital infrastructure, road traffic, or in the supply of water, gas, heating or electricity'
|
22 |
-
value: !!bool
|
23 |
admission: # Art. 6(2); Annex III(3)(a)
|
24 |
verbose: 'This dataset is appropriate to use for AI projects involving the determination of access or admission or to assigning natural persons to educational and vocational training institutions at all levels'
|
25 |
value: !!bool false
|
|
|
19 |
value: !!bool false
|
20 |
critical_infrastructure: # Art. 6(2); Annex III(2)
|
21 |
verbose: 'This dataset is appropriate to use for AI projects involving safety components in the management and operation of critical digital infrastructure, road traffic, or in the supply of water, gas, heating or electricity'
|
22 |
+
value: !!bool true
|
23 |
admission: # Art. 6(2); Annex III(3)(a)
|
24 |
verbose: 'This dataset is appropriate to use for AI projects involving the determination of access or admission or to assigning natural persons to educational and vocational training institutions at all levels'
|
25 |
value: !!bool false
|
project_cc.yaml
CHANGED
@@ -152,10 +152,10 @@ high_risk_ai_system:
|
|
152 |
value: !!bool false
|
153 |
emotion_recognition: # Art. 6(2); Annex III(1)(c)
|
154 |
verbose: 'AI project is intended to be used for emotion recognition'
|
155 |
-
value: !!bool
|
156 |
critical_infrastructure: # Art. 6(2); Annex III(2)
|
157 |
verbose: 'AI project is intended to be used as a safety component in the management and operation of critical digital infrastructure, road traffic, or in the supply of water, gas, heating or electricity'
|
158 |
-
value: !!bool
|
159 |
admission: # Art. 6(2); Annex III(3)(a)
|
160 |
verbose: 'AI project is intended to be used to determine access or admission or to assign natural persons to educational and vocational training institutions at all levels'
|
161 |
value: !!bool false
|
|
|
152 |
value: !!bool false
|
153 |
emotion_recognition: # Art. 6(2); Annex III(1)(c)
|
154 |
verbose: 'AI project is intended to be used for emotion recognition'
|
155 |
+
value: !!bool true
|
156 |
critical_infrastructure: # Art. 6(2); Annex III(2)
|
157 |
verbose: 'AI project is intended to be used as a safety component in the management and operation of critical digital infrastructure, road traffic, or in the supply of water, gas, heating or electricity'
|
158 |
+
value: !!bool true
|
159 |
admission: # Art. 6(2); Annex III(3)(a)
|
160 |
verbose: 'AI project is intended to be used to determine access or admission or to assign natural persons to educational and vocational training institutions at all levels'
|
161 |
value: !!bool false
|