Spaces:
Runtime error
Runtime error
gorkaartola
commited on
Commit
•
997f044
1
Parent(s):
0a9ff46
Upload app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,40 @@
|
|
1 |
-
import
|
2 |
-
|
|
|
|
|
|
|
3 |
|
|
|
4 |
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import run
|
3 |
+
import options as op
|
4 |
+
import re
|
5 |
+
import os
|
6 |
|
7 |
+
REGEX_YAML_BLOCK = re.compile(r"---[\n\r]+([\S\s]*?)[\n\r]+---[\n\r]")
|
8 |
|
9 |
+
def parse_readme(filepath):
|
10 |
+
"""Parses a repositories README and removes"""
|
11 |
+
if not os.path.exists(filepath):
|
12 |
+
return "No README.md found."
|
13 |
+
with open(filepath, "r") as f:
|
14 |
+
text = f.read()
|
15 |
+
match = REGEX_YAML_BLOCK.search(text)
|
16 |
+
if match:
|
17 |
+
text = text[match.end() :]
|
18 |
+
return text
|
19 |
+
|
20 |
+
queries = []
|
21 |
+
for query_dataset in op.queries.keys():
|
22 |
+
for query_file in op.queries[query_dataset].keys():
|
23 |
+
queries.append(query_dataset+'-'+query_file)
|
24 |
+
|
25 |
+
iface = gr.Interface(
|
26 |
+
run.tp_tf_test,
|
27 |
+
[
|
28 |
+
gr.Radio(list(op.models.keys())),
|
29 |
+
gr.Radio(list(op.test_datasets.keys())),
|
30 |
+
gr.Radio(queries),
|
31 |
+
gr.Radio(list(op.prompts.keys())),
|
32 |
+
gr.Radio(list(op.metrics.keys())),
|
33 |
+
gr.CheckboxGroup(list(op.prediction_strategy_options.keys())),
|
34 |
+
],
|
35 |
+
gr.File(),
|
36 |
+
title="Zero Shot Classifier Tester for True Positive and False Positive Samples",
|
37 |
+
article=parse_readme("README.md"),
|
38 |
+
)
|
39 |
+
|
40 |
+
iface.launch()
|