qqubb commited on
Commit
8cb26d4
·
1 Parent(s): a635b88

add code for processing data and model cards

Browse files
__pycache__/compliance_analysis.cpython-310.pyc CHANGED
Binary files a/__pycache__/compliance_analysis.cpython-310.pyc and b/__pycache__/compliance_analysis.cpython-310.pyc differ
 
app.py CHANGED
@@ -1,15 +1,25 @@
1
  import gradio as gr
2
  import yaml
3
- from compliance_analysis import run_compliance_analysis_on_project
 
4
 
5
  def process_files(files):
6
  results = []
7
  for file in files:
8
  with open(file.name, 'r') as f:
9
  content = f.read()
10
- project_cc_yaml = yaml.safe_load(content)
11
- msg = run_compliance_analysis_on_project(project_cc_yaml)
12
- results.append(msg)
 
 
 
 
 
 
 
 
 
13
 
14
  return results
15
 
 
1
  import gradio as gr
2
  import yaml
3
+ from pathlib import Path
4
+ from compliance_analysis import run_compliance_analysis_on_project, run_compliance_analysis_on_data, run_compliance_analysis_on_model
5
 
6
  def process_files(files):
7
  results = []
8
  for file in files:
9
  with open(file.name, 'r') as f:
10
  content = f.read()
11
+ if Path(file.name).name == "project_cc.yaml":
12
+ project_cc_yaml = yaml.safe_load(content)
13
+ msg = run_compliance_analysis_on_project(project_cc_yaml)
14
+ results.append(msg)
15
+ # if Path(file.name).name == "data_cc.yaml":
16
+ # data_cc_yaml = yaml.safe_load(content)
17
+ # msg = run_compliance_analysis_on_data(data_cc_yaml)
18
+ # results.append(msg)
19
+ # if Path(file.name).name == "model_cc.yaml":
20
+ # model_cc_yaml = yaml.safe_load(content)
21
+ # msg = run_compliance_analysis_on_model(model_cc_yaml)
22
+ # results.append(msg)
23
 
24
  return results
25
 
compliance_analysis.py CHANGED
@@ -76,45 +76,39 @@ def run_compliance_analysis_on_project(project_cc_yaml):
76
  return msg
77
 
78
  def run_compliance_analysis_on_data(data_cc_yaml):
79
- # Do this by examining any and all Data CCs too
80
- data_cc_yaml = yaml.safe_load(data_cc_yaml)
81
- filename = data_cc_yaml
82
 
83
  for key, value in data_cc_yaml['data_and_data_governance']:
84
  if not value:
85
- msg = (f"Because of the dataset represented by {filename}, this high-risk AI system fails the data and data governance requirements under Article 10.")
86
  for key, value in data_cc_yaml['technical_documentation']:
87
  if not value:
88
- msg = (f"Because of the dataset represented by {filename}, this high-risk AI system fails the technical documentation requirements under Article 11.")
89
  for key, value in data_cc_yaml['transparency_and_provision_of_information_to_deployers']:
90
  if not value:
91
- msg = (f"Because of the dataset represented by {filename}, this high-risk AI system fails the transparency requirements under Article 13.")
92
  for key, value in data_cc_yaml['quality_management_system']:
93
  if not value:
94
- msg = (f"Because of the dataset represented by {filename}, this high-risk AI system fails the quality management requirements under Article 17.")
95
 
96
  return msg
97
 
98
- def run_compliance_analysis_on_data(model_cc_yaml):
99
-
100
- model_cc_yaml = yaml.safe_load(model_cc_yaml)
101
- filename - model_cc_yaml
102
 
103
  for key, value in model_cc_yaml['risk_management_system']:
104
  if not value:
105
- msg = (f"Because of the model represented by {filename}, this high-risk AI system fails the risk management requirements under Article 9.")
106
  for key, value in data_cc_yaml['technical_documentation']:
107
  if not value:
108
- msg = (f"Because of the model represented by {filename}, this high-risk AI system fails the technical documentation requirements under Article 11.")
109
  for key, value in data_cc_yaml['transparency_and_provision_of_information_to_deployers']:
110
  if not value:
111
- msg = (f"Because of the model represented by {filename}, this high-risk AI system fails the transparency requirements under Article 13.")
112
  for key, value in data_cc_yaml['accuracy_robustness_cybersecurity']:
113
  if not value:
114
- msg = (f"Because of the model represented by {filename}, this high-risk AI system fails the quality management requirements under Article 15.")
115
  for key, value in data_cc_yaml['quality_management_system']:
116
  if not value:
117
- msg = (f"Because of the model represented by {filename}, this high-risk AI system fails the quality management requirements under Article 17.")
118
 
119
  return msg
120
 
 
76
  return msg
77
 
78
  def run_compliance_analysis_on_data(data_cc_yaml):
 
 
 
79
 
80
  for key, value in data_cc_yaml['data_and_data_governance']:
81
  if not value:
82
+ msg = (f"Because of the dataset represented by , this high-risk AI system fails the data and data governance requirements under Article 10.")
83
  for key, value in data_cc_yaml['technical_documentation']:
84
  if not value:
85
+ msg = (f"Because of the dataset represented by , this high-risk AI system fails the technical documentation requirements under Article 11.")
86
  for key, value in data_cc_yaml['transparency_and_provision_of_information_to_deployers']:
87
  if not value:
88
+ msg = (f"Because of the dataset represented by , this high-risk AI system fails the transparency requirements under Article 13.")
89
  for key, value in data_cc_yaml['quality_management_system']:
90
  if not value:
91
+ msg = (f"Because of the dataset represented by , this high-risk AI system fails the quality management requirements under Article 17.")
92
 
93
  return msg
94
 
95
+ def run_compliance_analysis_on_model(model_cc_yaml):
 
 
 
96
 
97
  for key, value in model_cc_yaml['risk_management_system']:
98
  if not value:
99
+ msg = (f"Because of the model represented by , this high-risk AI system fails the risk management requirements under Article 9.")
100
  for key, value in data_cc_yaml['technical_documentation']:
101
  if not value:
102
+ msg = (f"Because of the model represented by , this high-risk AI system fails the technical documentation requirements under Article 11.")
103
  for key, value in data_cc_yaml['transparency_and_provision_of_information_to_deployers']:
104
  if not value:
105
+ msg = (f"Because of the model represented by , this high-risk AI system fails the transparency requirements under Article 13.")
106
  for key, value in data_cc_yaml['accuracy_robustness_cybersecurity']:
107
  if not value:
108
+ msg = (f"Because of the model represented by , this high-risk AI system fails the quality management requirements under Article 15.")
109
  for key, value in data_cc_yaml['quality_management_system']:
110
  if not value:
111
+ msg = (f"Because of the model represented by , this high-risk AI system fails the quality management requirements under Article 17.")
112
 
113
  return msg
114
 
data_cc.yaml CHANGED
@@ -68,13 +68,13 @@ data_and_data_governance:
68
  personal_data_deletion: # Art. 10(5)(e)
69
  verbose: 'Where special categories of personal data have been used to ensure the detection and correction of possible biases that are likely to affect the health and safety of persons, have a negative impact on fundamental rights or lead to discrimination prohibited under Union law, especially where data outputs influence inputs for future operations, the special categories of personal data were deleted once the bias was corrected or the personal data reached the end of its retention period (whichever came first)'
70
  value: !!bool false
71
- personal_data_necessary: # Art. 10(5)(f)
72
  verbose: 'Where special categories of personal data have been used to ensure the detection and correction of possible biases that are likely to affect the health and safety of persons, have a negative impact on fundamental rights or lead to discrimination prohibited under Union law, especially where data outputs influence inputs for future operations, the records of processing activities pursuant to Regulations (EU) 2016/679 and (EU) 2018/1725 and Directive (EU) 2016/680 include the reasons why the processing of special categories of personal data was strictly necessary to detect and correct biases, and why that objective could not be achieved by processing other data'
73
  value: !!bool false
74
 
75
  technical_documentation:
76
  general_description: # Art. 11; Annex IV(2)(d)
77
- verbose: 'Dataset carries technical documention, such as a dataseet, including a general description of the dataset."
78
  value: !!bool false
79
  provenance: # Art. 11; Annex IV(2)(d)
80
  verbose: 'Dataset carries technical documention, such as a dataseet, including information about its provenance'
 
68
  personal_data_deletion: # Art. 10(5)(e)
69
  verbose: 'Where special categories of personal data have been used to ensure the detection and correction of possible biases that are likely to affect the health and safety of persons, have a negative impact on fundamental rights or lead to discrimination prohibited under Union law, especially where data outputs influence inputs for future operations, the special categories of personal data were deleted once the bias was corrected or the personal data reached the end of its retention period (whichever came first)'
70
  value: !!bool false
71
+ personal_data_necessary_105f: # Art. 10(5)(f)
72
  verbose: 'Where special categories of personal data have been used to ensure the detection and correction of possible biases that are likely to affect the health and safety of persons, have a negative impact on fundamental rights or lead to discrimination prohibited under Union law, especially where data outputs influence inputs for future operations, the records of processing activities pursuant to Regulations (EU) 2016/679 and (EU) 2018/1725 and Directive (EU) 2016/680 include the reasons why the processing of special categories of personal data was strictly necessary to detect and correct biases, and why that objective could not be achieved by processing other data'
73
  value: !!bool false
74
 
75
  technical_documentation:
76
  general_description: # Art. 11; Annex IV(2)(d)
77
+ verbose: 'Dataset carries technical documention, such as a dataseet, including a general description of the dataset.'
78
  value: !!bool false
79
  provenance: # Art. 11; Annex IV(2)(d)
80
  verbose: 'Dataset carries technical documention, such as a dataseet, including information about its provenance'
model_cc.yaml CHANGED
@@ -13,7 +13,7 @@ risk_management_system:
13
  value: !!bool false
14
  testing_compliance: # Art. 9(6)
15
  verbose: 'Testing to ensure model complies with Act'
16
- value: !!bool false
17
  testing_benchmark: # Art. 9(8)
18
  verbose: 'Testing against prior defined metrics appropriate to intended purpose'
19
  value: !!bool false
@@ -87,7 +87,7 @@ accuracy_robustness_cybersecurity:
87
  verbose: 'Model is designed and developed to achieve appropriate level of accuracy'
88
  value: !!bool false
89
  robustiness: # Art. 15(1)
90
- verbose 'Model is designed and developed to achieve appropriate level of robustness'
91
  value: !!bool false
92
  cybersecurity: # Art. 15(1)
93
  verbose: 'Model is designed and developed to achieve appropriate level of cybersecurity'
 
13
  value: !!bool false
14
  testing_compliance: # Art. 9(6)
15
  verbose: 'Testing to ensure model complies with Act'
16
+ value: !!bool false
17
  testing_benchmark: # Art. 9(8)
18
  verbose: 'Testing against prior defined metrics appropriate to intended purpose'
19
  value: !!bool false
 
87
  verbose: 'Model is designed and developed to achieve appropriate level of accuracy'
88
  value: !!bool false
89
  robustiness: # Art. 15(1)
90
+ verbose: 'Model is designed and developed to achieve appropriate level of robustness'
91
  value: !!bool false
92
  cybersecurity: # Art. 15(1)
93
  verbose: 'Model is designed and developed to achieve appropriate level of cybersecurity'