nicholasKluge commited on
Commit
158f906
1 Parent(s): 8436f0b

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +83 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from datasets import load_dataset
3
+ import pandas as pd
4
+
5
+ db = load_dataset("nicholasKluge/model-library", split='main')
6
+ db = db.to_pandas()
7
+
8
+ def display_model_information(value):
9
+ """
10
+ This function will display the model information for the selected model
11
+ """
12
+ # If the value is empty, return None
13
+ if value == '':
14
+ return None, None
15
+
16
+ # Get the model information
17
+ info = db.iloc[int(db[db.model_name_string == value].index.values)]
18
+
19
+ # Create the model details and model info
20
+ model_details = f"""## Model Details
21
+
22
+ - Name: {info.model_name_url}
23
+ - Model Size: {info.model_size_string}
24
+ - Dataset: {info.dataset}
25
+ - Input/Output Format: {info.data_type}
26
+ - Research Field: {info.research_field}
27
+ - Contains an Impact Assessment: {info.risks_and_limitations}
28
+ - Associated Risks: ☣️ {info.risk_types} ☣️
29
+ - Date of Publication: {info.publication_date}
30
+ - Organization: {info.organization_and_url} ({info.institution_type})
31
+ - Country/Origin: {info.country}
32
+ - License: {info.license}
33
+ - Publication: {info.paper_name_url}
34
+ """
35
+ model_info = f"""## Description
36
+
37
+ {info.model_description}
38
+
39
+ ## Organization
40
+
41
+ {info.organization_info}
42
+ """
43
+
44
+ return model_details, model_info
45
+
46
+ with open('data/risks_list.md', 'rb') as f:
47
+ risk_text = f.read().decode('utf-8')[44:]
48
+
49
+ with gr.Blocks(theme='HaleyCH/HaleyCH_Theme') as demo:
50
+
51
+ gr.Markdown("""<h1><center>Model Library</h1></center>""")
52
+
53
+ gr.HTML("""<center><img src="file/assets/logo.png" width="200" height="200"></center>""")
54
+
55
+ gr.HTML(f"<center><div style='max-width: 50%;'>The Model Library is a project that maps the risks associated with modern machine \
56
+ learning systems. Here, we assess some of the most recent and capable AI systems ever created. \
57
+ We have already mapped {len(db)} models from the AI community!</div></center>")
58
+
59
+ dropdown = gr.Dropdown(
60
+ choices=db.model_name_string.tolist(),
61
+ label="Choose a model",
62
+ info="These are the models we have already produced reports."
63
+ )
64
+
65
+ display = gr.Button(value="Display")
66
+
67
+ with gr.Row():
68
+ with gr.Column(scale=1):
69
+ model_details = gr.Markdown()
70
+ with gr.Column(scale=4):
71
+ model_info = gr.Markdown()
72
+
73
+ with gr.Accordion(label="Mapped Risks", open=False):
74
+ gr.Markdown(risk_text)
75
+
76
+ gr.HTML(f"<center><div style='max-width: 50%;'>If you would like to add a model, read our\
77
+ documentation and submit a PR on <a href='https://github.com/Nkluge-correa/ModelLibrary' \
78
+ target='_blank'>GitHub</a>!</div></center>")
79
+
80
+ display.click(fn=display_model_information, inputs=dropdown, outputs=[model_details, model_info])
81
+
82
+
83
+ demo.launch(debug=True, favicon_path="file/assets/favicon.ico")
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ datasets
2
+ gradio