mmathys commited on
Commit
6b551f5
1 Parent(s): 534a595

u p d a t e

Browse files
Files changed (5) hide show
  1. .gitignore +190 -0
  2. .vscode/settings.json +6 -0
  3. app.py +44 -16
  4. data.csv +6 -6
  5. flagged/log.csv +2 -0
.gitignore ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Python ###
2
+ # Byte-compiled / optimized / DLL files
3
+ __pycache__/
4
+ *.py[cod]
5
+ *$py.class
6
+
7
+ # C extensions
8
+ *.so
9
+
10
+ # Distribution / packaging
11
+ .Python
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ #Pipfile.lock
97
+
98
+ # poetry
99
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103
+ #poetry.lock
104
+
105
+ # pdm
106
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107
+ #pdm.lock
108
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109
+ # in version control.
110
+ # https://pdm.fming.dev/#use-with-ide
111
+ .pdm.toml
112
+
113
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
114
+ __pypackages__/
115
+
116
+ # Celery stuff
117
+ celerybeat-schedule
118
+ celerybeat.pid
119
+
120
+ # SageMath parsed files
121
+ *.sage.py
122
+
123
+ # Environments
124
+ .env
125
+ .venv
126
+ env/
127
+ venv/
128
+ ENV/
129
+ env.bak/
130
+ venv.bak/
131
+
132
+ # Spyder project settings
133
+ .spyderproject
134
+ .spyproject
135
+
136
+ # Rope project settings
137
+ .ropeproject
138
+
139
+ # mkdocs documentation
140
+ /site
141
+
142
+ # mypy
143
+ .mypy_cache/
144
+ .dmypy.json
145
+ dmypy.json
146
+
147
+ # Pyre type checker
148
+ .pyre/
149
+
150
+ # pytype static type analyzer
151
+ .pytype/
152
+
153
+ # Cython debug symbols
154
+ cython_debug/
155
+
156
+ # PyCharm
157
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
158
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
159
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
160
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
161
+ #.idea/
162
+
163
+ ### Python Patch ###
164
+ # Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
165
+ poetry.toml
166
+
167
+ # ruff
168
+ .ruff_cache/
169
+
170
+ # LSP config files
171
+ pyrightconfig.json
172
+
173
+ ### VisualStudioCode ###
174
+ .vscode/*
175
+ !.vscode/settings.json
176
+ !.vscode/tasks.json
177
+ !.vscode/launch.json
178
+ !.vscode/extensions.json
179
+ !.vscode/*.code-snippets
180
+
181
+ # Local History for Visual Studio Code
182
+ .history/
183
+
184
+ # Built Visual Studio Code Extensions
185
+ *.vsix
186
+
187
+ ### VisualStudioCode Patch ###
188
+ # Ignore all local history of files
189
+ .history
190
+ .ionide
.vscode/settings.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "[python]": {
3
+ "editor.defaultFormatter": "ms-python.black-formatter"
4
+ },
5
+ "python.formatting.provider": "none"
6
+ }
app.py CHANGED
@@ -1,5 +1,6 @@
1
- # %%
2
  import pandas as pd
 
3
  df = pd.read_csv("data.csv")
4
  df
5
 
@@ -7,33 +8,60 @@ df
7
  import gradio as gr
8
 
9
 
10
- def sentence_builder(model, dataset):
11
- return f"Safety card for {model} and {dataset}."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  iface = gr.Interface(
14
  sentence_builder,
15
  [
16
  gr.Dropdown(
17
- list(df["friendly_name"]), label="Model", info="Select a model to use for testing."
 
 
 
18
  ),
19
  gr.Dropdown(
20
- ["marmal88/skin_cancer"], value="marmal88/skin_cancer", label="Dataset", info="Select the sampling dataset to use for testing."
 
 
 
21
  ),
22
- #gr.CheckboxGroup(["USA", "Japan", "Pakistan"], label="Countries", info="Where are they from?"),
23
- #gr.Radio(["park", "zoo", "road"], label="Location", info="Where did they go?"),
24
- #gr.Dropdown(
25
  # ["ran", "swam", "ate", "slept"], value=["swam", "slept"], multiselect=True, label="Activity", info="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed auctor, nisl eget ultricies aliquam, nunc nisl aliquet nunc, eget aliquam nisl nunc vel nisl."
26
- #),
27
- #gr.Checkbox(label="Morning", info="Did they do it in the morning?"),
28
  ],
29
- gr.Label(num_top_classes=4),
30
  examples=[
31
  ["ViT", "marmal88/skin_cancer"],
32
- #[2, "cat", ["Japan", "Pakistan"], "park", ["ate", "swam"], True],
33
- #[4, "dog", ["Japan"], "zoo", ["ate", "swam"], False],
34
- #[10, "bird", ["USA", "Pakistan"], "road", ["ran"], False],
35
- #[8, "cat", ["Pakistan"], "zoo", ["ate"], True],
36
- ]
37
  )
38
 
39
  iface.launch()
 
1
+ # %%
2
  import pandas as pd
3
+
4
  df = pd.read_csv("data.csv")
5
  df
6
 
 
8
  import gradio as gr
9
 
10
 
11
+ def sentence_builder(model, dataset, displayed_metrics):
12
+ row = df[df["friendly_name"] == model]
13
+ str = (
14
+ f"## 🚧 Safety card\n"
15
+ f"Model: {model}\n"
16
+ f"Evaluating on dataset `{dataset}`"
17
+ )
18
+
19
+ if "Accuracy" in displayed_metrics:
20
+ str += f"\nAccuracy: `{row['accuracy'].values[0]}`"
21
+
22
+ if "Precision" in displayed_metrics:
23
+ str += f"\nPrecision: `{row['precision_weighted'].values[0]}`"
24
+
25
+ if "Recall" in displayed_metrics:
26
+ str += f"\nRecall: `{row['recall_weighted'].values[0]}`"
27
+
28
+ if "Robustness" in displayed_metrics:
29
+ str += f"\nRobustness: `{100-row['robustness'].values[0]}`"
30
+
31
+ if "Fairness" in displayed_metrics:
32
+ str += f"\nFairness: `{0}`"
33
+
34
+ str += "\n<div style='text-align: right'>⛶ Expand safety card</div>"
35
+
36
+ return str
37
+
38
 
39
  iface = gr.Interface(
40
  sentence_builder,
41
  [
42
  gr.Dropdown(
43
+ list(df["friendly_name"]),
44
+ label="Model",
45
+ value="ViT",
46
+ info="Select a model to use for testing.",
47
  ),
48
  gr.Dropdown(
49
+ ["marmal88/skin_cancer"],
50
+ value="marmal88/skin_cancer",
51
+ label="Dataset",
52
+ info="Select the sampling dataset to use for testing.",
53
  ),
54
+ gr.CheckboxGroup(["Accuracy", "Precision", "Recall", "Robustness", "Fairness"], value=["Accuracy", "Robustness"], label="Metrics", info="Select displayed metrics."),
55
+ # gr.Radio(["park", "zoo", "road"], label="Location", info="Where did they go?"),
56
+ # gr.Dropdown(
57
  # ["ran", "swam", "ate", "slept"], value=["swam", "slept"], multiselect=True, label="Activity", info="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed auctor, nisl eget ultricies aliquam, nunc nisl aliquet nunc, eget aliquam nisl nunc vel nisl."
58
+ # ),
59
+ # gr.Checkbox(label="Morning", info="Did they do it in the morning?"),
60
  ],
61
+ "markdown",
62
  examples=[
63
  ["ViT", "marmal88/skin_cancer"],
64
+ ],
 
 
 
 
65
  )
66
 
67
  iface.launch()
data.csv CHANGED
@@ -1,6 +1,6 @@
1
- id,loss,accuracy,f1_macro,f1_micro,f1_weighted,precision_macro,precision_micro,precision_weighted,recall_macro,recall_micro,recall_weighted,friendly_name
2
- #50807121081,0.0514,0.9867,0.9839,0.9867,0.9867,0.9845,0.9867,0.9873,0.9841,0.9867,0.9867,Swin Transformer (small)
3
- #50807121082,0.0341,0.9933,0.9920,0.9933,0.9933,0.9922,0.9933,0.9935,0.9919,0.9933,0.9933,ViT
4
- #50807121083,0.9992,0.5067,0.3474,0.5067,0.3968,0.6261,0.5067,0.5996,0.4095,0.5067,0.5067,ResNet
5
- #50807121084,0.0523,0.9800,0.9805,0.9800,0.9800,0.9857,0.9800,0.9809,0.9760,0.9800,0.9800,Swin Transformer (large)
6
- #50807121085,0.0393,0.9733,0.9707,0.9733,0.9732,0.9739,0.9733,0.9734,0.9679,0.9733,0.9733,BEiT
 
1
+ id,loss,accuracy,f1_macro,f1_micro,f1_weighted,precision_macro,precision_micro,precision_weighted,recall_macro,recall_micro,recall_weighted,friendly_name,robustness
2
+ #50807121081,0.0514,0.9867,0.9839,0.9867,0.9867,0.9845,0.9867,0.9873,0.9841,0.9867,0.9867,Swin Transformer (small),24
3
+ #50807121082,0.0341,0.9933,0.9920,0.9933,0.9933,0.9922,0.9933,0.9935,0.9919,0.9933,0.9933,ViT,27
4
+ #50807121083,0.9992,0.5067,0.3474,0.5067,0.3968,0.6261,0.5067,0.5996,0.4095,0.5067,0.5067,ResNet,3
5
+ #50807121084,0.0523,0.9800,0.9805,0.9800,0.9800,0.9857,0.9800,0.9809,0.9760,0.9800,0.9800,Swin Transformer (large),19
6
+ #50807121085,0.0393,0.9733,0.9707,0.9733,0.9732,0.9739,0.9733,0.9734,0.9679,0.9733,0.9733,BEiT,19
flagged/log.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ Model,Dataset,output,flag,username,timestamp
2
+ Swin Transformer (small),marmal88/skin_cancer,,,,2023-04-20 16:57:05.091724