File size: 2,721 Bytes
158f906
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d2cbbfd
158f906
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2d22ed1
158f906
 
 
 
 
 
65cef6a
158f906
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d92c0c7
158f906
 
 
 
 
65cef6a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import gradio as gr
from datasets import load_dataset

db = load_dataset("nicholasKluge/model-library", split='main')
db = db.to_pandas()

def display_model_information(value):
    """
    This function will display the model information for the selected model
    """
    # If the value is empty, return None
    if value == '':
        return None, None

    # Get the model information
    info = db.iloc[int(db[db.model_name_string == value].index.values)]
    
    # Create the model details and model info
    model_details = f"""## Model Details

- Name: {info.model_name_url}
- Model Size: {info.model_size_string}
- Dataset: {info.dataset}
- Input/Output Format: {info.data_type}
- Research Field: {info.research_field}
- Contains an Impact Assessment: {info.risks_and_limitations}
- Associated Risks: ☣️ {info.risk_types} ☣️
- Date of Publication: {info.publication_date}
- Organization: {info.organization_and_url}
- Country/Origin: {info.country}
- License: {info.license}
- Publication: {info.paper_name_url}
"""
    model_info = f"""## Description

{info.model_description}

## Organization

{info.organization_info}
"""

    return model_details, model_info

with open('risks_list.md', 'rb') as f:
    risk_text = f.read().decode('utf-8')[44:]

with gr.Blocks(theme='HaleyCH/HaleyCH_Theme') as demo:

    gr.Markdown("""<h1><center>Model Library</h1></center>""")

    gr.HTML("""<center><img src="file/logo.png" width="200" height="200"></center>""")

    gr.HTML(f"<center><div style='max-width: 50%;'>The Model Library is a project that maps the risks associated with modern machine \
        learning systems. Here, we assess some of the most recent and capable AI systems ever created. \
            We have already mapped {len(db)} models from the AI community!</div></center>")

    dropdown = gr.Dropdown(
        choices=db.model_name_string.tolist(),
        label="Choose a model", 
        info="These are the models we have already produced reports."
    )

    display = gr.Button(value="Display")

    with gr.Row():
        with gr.Column(scale=1):
            model_details = gr.Markdown()
        with gr.Column(scale=4):
            model_info = gr.Markdown()
    
    with gr.Accordion(label="Mapped Risks", open=False):
        gr.Markdown(risk_text)
    
    gr.HTML(f"<center><div style='max-width: 50%;'>If you would like to add a model, read our\
        documentation and submit a PR on <a href='https://github.com/Nkluge-correa/Model-Library' \
            target='_blank'>GitHub</a>!</div></center>")
    
    display.click(fn=display_model_information, inputs=dropdown, outputs=[model_details, model_info])
    

demo.launch(debug=True, favicon_path="file/favicon.ico")