qqubb commited on
Commit
2cb848b
·
1 Parent(s): 60c25d8

fix check_intended_use_aligned

Browse files
Files changed (2) hide show
  1. app.py +10 -3
  2. compliance_analysis.py +100 -99
app.py CHANGED
@@ -182,7 +182,14 @@ if uploaded_files:
182
  for key, details in items.items():
183
  if 'verbose' in details and 'value' in details:
184
  st.subheader(key.replace('_', ' ').title()) # section header
185
- details['value'] = st.checkbox(details['verbose'], value=details['value'])
 
 
 
 
 
 
 
186
  if 'verbose' not in details and 'value' not in details:
187
  st.subheader(key.replace('_', ' ').title()) # section header
188
  for key, details in details.items():
@@ -190,8 +197,8 @@ if uploaded_files:
190
  details['value'] = st.checkbox(details['verbose'], value=details['value'])
191
  st.divider()
192
  st.divider()
193
- # st.write("Updated Data:", data)
194
-
195
  yaml_data = yaml.dump(data)
196
 
197
  st.download_button(
 
182
  for key, details in items.items():
183
  if 'verbose' in details and 'value' in details:
184
  st.subheader(key.replace('_', ' ').title()) # section header
185
+ # details['value'] = st.checkbox(details['verbose'], value=details['value'])
186
+ # Determine the type of input based on the type of 'value'
187
+ if isinstance(details['value'], str):
188
+ # If the value is a string, use a text input box
189
+ details['value'] = st.text_input(details['verbose'], value=details['value'])
190
+ elif isinstance(details['value'], bool):
191
+ # If the value is a boolean, use a checkbox
192
+ details['value'] = st.checkbox(details['verbose'], value=details['value'])
193
  if 'verbose' not in details and 'value' not in details:
194
  st.subheader(key.replace('_', ' ').title()) # section header
195
  for key, details in details.items():
 
197
  details['value'] = st.checkbox(details['verbose'], value=details['value'])
198
  st.divider()
199
  st.divider()
200
+ st.write("Updated Data:", data)
201
+
202
  yaml_data = yaml.dump(data)
203
 
204
  st.download_button(
compliance_analysis.py CHANGED
@@ -116,105 +116,106 @@ def run_compliance_analysis_on_model(model_cc_yaml):
116
 
117
  return msg
118
 
119
- def_check_intended_use_aligned(): # We want to run this function for everything classified as a high_risk_ai_system
120
- # We also need to run it for all
121
-
122
- # Add any of the intended purposes of the overall project to a set of intended purposes
123
-
124
- if project_cc_yaml['high_risk_ai_system']['safety_component'] == True:
125
- intended_purpose = "safety_component"
126
- if project_cc_yaml['high_risk_ai_system']['product_regulated_machinery'] == True:
127
- intended_purpose = "product_regulated_machinery"
128
- if project_cc_yaml['high_risk_ai_system']['product_regulated_toy'] == True:
129
- intended_purpose = "product_regulated_toy"
130
- if project_cc_yaml['high_risk_ai_system']['product_regulated_watercraft'] == True:
131
- intended_purpose = "product_regulated_watercraft"
132
- if project_cc_yaml['high_risk_ai_system']['biometric_categorization'] == True:
133
- intended_purpose = "biometric_categorization"
134
- if project_cc_yaml['high_risk_ai_system']['emotion_recognition'] == True:
135
- intended_purpose = "emotion_recognition"
136
- if project_cc_yaml['high_risk_ai_system']['critical_infrastructure'] == True:
137
- intended_purpose = "critical_infrastructure"
138
- if project_cc_yaml['high_risk_ai_system']['admission'] == True:
139
- intended_purpose = "admission"
140
- if project_cc_yaml['high_risk_ai_system']['recruitment'] == True:
141
- intended_purpose = "recruitment"
142
- if project_cc_yaml['high_risk_ai_system']['public_assistance'] == True:
143
- intended_purpose = "public_assistance"
144
- if project_cc_yaml['high_risk_ai_system']['victim_assessment'] == True:
145
- intended_purpose = "victim_assessment"
146
- if project_cc_yaml['high_risk_ai_system']['polygraph'] == True:
147
- intended_purpose = "polygraph"
148
- if project_cc_yaml['high_risk_ai_system']['judicial'] == True:
149
- intended_purpose = "judicial"
150
-
151
- # For each Data CC, put the intended uses in a set and then make sure the Project's intended use is in the set
152
-
153
- dataset_intended_purpose = ()
154
-
155
- if data_cc_yaml['intended_purpose']['safety_component'] == True:
156
- dataset_intended_purpose.add("safety_component")
157
- if data_cc_yaml['intended_purpose']['product_regulated_machinery'] == True:
158
- dataset_intended_purpose.add("product_regulated_machinery")
159
- if data_cc_yaml['intended_purpose']['product_regulated_toy'] == True:
160
- dataset_intended_purpose.add("product_regulated_toy")
161
- if data_cc_yaml['intended_purpose']['product_regulated_watercraft'] == True:
162
- dataset_intended_purpose.add("product_regulated_watercraft")
163
- if data_cc_yaml['intended_purpose']['biometric_categorization'] == True:
164
- dataset_intended_purpose.add("biometric_categorization")
165
- if data_cc_yaml['intended_purpose']['emotion_recognition'] == True:
166
- dataset_intended_purpose.add("emotion_recognition")
167
- if data_cc_yaml['intended_purpose']['critical_infrastructure'] == True:
168
- dataset_intended_purpose.add("critical_infrastructure")
169
- if data_cc_yaml['intended_purpose']['admission'] == True:
170
- dataset_intended_purpose.add("admission")
171
- if data_cc_yaml['intended_purpose']['recruitment'] == True:
172
- dataset_intended_purpose.add("recruitment")
173
- if data_cc_yaml['intended_purpose']['public_assistance'] == True:
174
- dataset_intended_purpose.add("public_assistance")
175
- if data_cc_yaml['intended_purpose']['victim_assessment'] == True:
176
- dataset_intended_purpose.add("victim_assessment")
177
- if data_cc_yaml['intended_purpose']['polygraph'] == True:
178
- dataset_intended_purpose.add("polygraph")
179
- if data_cc_yaml['intended_purpose']['judicial'] == True:
180
- dataset_intended_purpose.add("judicial")
181
-
182
- if project_intended_purpose not in dataset_intended_purpose:
183
- print("You are not compliant")
184
-
185
- # Now do the exact same thing for all models
186
-
187
- model_intended_purpose = ()
188
-
189
- if model_cc_yaml['intended_purpose']['safety_component'] == True:
190
- dataset_intended_purpose.add("safety_component")
191
- if model_cc_yaml['intended_purpose']['product_regulated_machinery'] == True:
192
- dataset_intended_purpose.add("product_regulated_machinery")
193
- if model_cc_yaml['intended_purpose']['product_regulated_toy'] == True:
194
- dataset_intended_purpose.add("product_regulated_toy")
195
- if model_cc_yaml['intended_purpose']['product_regulated_watercraft'] == True:
196
- dataset_intended_purpose.add("product_regulated_watercraft")
197
- if model_cc_yaml['intended_purpose']['biometric_categorization'] == True:
198
- dataset_intended_purpose.add("biometric_categorization")
199
- if model_cc_yaml['intended_purpose']['emotion_recognition'] == True:
200
- dataset_intended_purpose.add("emotion_recognition")
201
- if model_cc_yaml['intended_purpose']['critical_infrastructure'] == True:
202
- dataset_intended_purpose.add("critical_infrastructure")
203
- if model_cc_yaml['intended_purpose']['admission'] == True:
204
- dataset_intended_purpose.add("admission")
205
- if model_cc_yaml['intended_purpose']['recruitment'] == True:
206
- dataset_intended_purpose.add("recruitment")
207
- if model_cc_yaml['intended_purpose']['public_assistance'] == True:
208
- dataset_intended_purpose.add("public_assistance")
209
- if model_cc_yaml['intended_purpose']['victim_assessment'] == True:
210
- dataset_intended_purpose.add("victim_assessment")
211
- if model_cc_yaml['intended_purpose']['polygraph'] == True:
212
- dataset_intended_purpose.add("polygraph")
213
- if model_cc_yaml['intended_purpose']['judicial'] == True:
214
- dataset_intended_purpose.add("judicial")
215
-
216
- if project_intended_purpose not in dataset_intended_purpose:
217
- print("You are not compliant")
 
218
 
219
 
220
 
 
116
 
117
  return msg
118
 
119
+ def check_intended_use_aligned():
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
+ if project_cc_yaml['high_risk_ai_system']['safety_component'] == True:
126
+ intended_purpose = "safety_component"
127
+ if project_cc_yaml['high_risk_ai_system']['product_regulated_machinery'] == True:
128
+ intended_purpose = "product_regulated_machinery"
129
+ if project_cc_yaml['high_risk_ai_system']['product_regulated_toy'] == True:
130
+ intended_purpose = "product_regulated_toy"
131
+ if project_cc_yaml['high_risk_ai_system']['product_regulated_watercraft'] == True:
132
+ intended_purpose = "product_regulated_watercraft"
133
+ if project_cc_yaml['high_risk_ai_system']['biometric_categorization'] == True:
134
+ intended_purpose = "biometric_categorization"
135
+ if project_cc_yaml['high_risk_ai_system']['emotion_recognition'] == True:
136
+ intended_purpose = "emotion_recognition"
137
+ if project_cc_yaml['high_risk_ai_system']['critical_infrastructure'] == True:
138
+ intended_purpose = "critical_infrastructure"
139
+ if project_cc_yaml['high_risk_ai_system']['admission'] == True:
140
+ intended_purpose = "admission"
141
+ if project_cc_yaml['high_risk_ai_system']['recruitment'] == True:
142
+ intended_purpose = "recruitment"
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
+ dataset_intended_purpose = ()
155
+
156
+ if data_cc_yaml['intended_purpose']['safety_component'] == True:
157
+ dataset_intended_purpose.add("safety_component")
158
+ if data_cc_yaml['intended_purpose']['product_regulated_machinery'] == True:
159
+ dataset_intended_purpose.add("product_regulated_machinery")
160
+ if data_cc_yaml['intended_purpose']['product_regulated_toy'] == True:
161
+ dataset_intended_purpose.add("product_regulated_toy")
162
+ if data_cc_yaml['intended_purpose']['product_regulated_watercraft'] == True:
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
+ model_intended_purpose = ()
189
+
190
+ if model_cc_yaml['intended_purpose']['safety_component'] == True:
191
+ dataset_intended_purpose.add("safety_component")
192
+ if model_cc_yaml['intended_purpose']['product_regulated_machinery'] == True:
193
+ dataset_intended_purpose.add("product_regulated_machinery")
194
+ if model_cc_yaml['intended_purpose']['product_regulated_toy'] == True:
195
+ dataset_intended_purpose.add("product_regulated_toy")
196
+ if model_cc_yaml['intended_purpose']['product_regulated_watercraft'] == True:
197
+ dataset_intended_purpose.add("product_regulated_watercraft")
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