Spaces:
Sleeping
Sleeping
qqubb
commited on
Commit
·
2cb848b
1
Parent(s):
60c25d8
fix check_intended_use_aligned
Browse files- app.py +10 -3
- 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 |
-
|
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 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
|
|
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 |
|