Spaces:
Runtime error
Runtime error
saicharan2804
commited on
Commit
·
7447c8f
1
Parent(s):
9d55a3f
compute change
Browse files- app.py +55 -55
- my_metric.py +2 -2
app.py
CHANGED
@@ -1,55 +1,55 @@
|
|
1 |
-
import evaluate
|
2 |
-
from evaluate.utils import launch_gradio_widget
|
3 |
-
from pathlib import Path
|
4 |
-
import sys
|
5 |
-
import os
|
6 |
-
|
7 |
-
from .logging import get_logger
|
8 |
-
logger = get_logger(__name__)
|
9 |
-
|
10 |
-
###
|
11 |
-
def launch_gradio_widget(metric):
|
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 |
-
module = evaluate.load("saicharan2804/my_metric")
|
55 |
-
launch_gradio_widget(module)
|
|
|
1 |
+
# import evaluate
|
2 |
+
# from evaluate.utils import launch_gradio_widget
|
3 |
+
# from pathlib import Path
|
4 |
+
# import sys
|
5 |
+
# import os
|
6 |
+
|
7 |
+
# from .logging import get_logger
|
8 |
+
# logger = get_logger(__name__)
|
9 |
+
|
10 |
+
# ###
|
11 |
+
# def launch_gradio_widget(metric):
|
12 |
+
# """Launches `metric` widget with Gradio."""
|
13 |
+
|
14 |
+
# try:
|
15 |
+
# import gradio as gr
|
16 |
+
# except ImportError as error:
|
17 |
+
# logger.error("To create a metric widget with Gradio make sure gradio is installed.")
|
18 |
+
# raise error
|
19 |
+
|
20 |
+
# local_path = Path(sys.path[0])
|
21 |
+
# # if there are several input types, use first as default.
|
22 |
+
# if isinstance(metric.features, list):
|
23 |
+
# (feature_names, feature_types) = zip(*metric.features[0].items())
|
24 |
+
# else:
|
25 |
+
# (feature_names, feature_types) = zip(*metric.features.items())
|
26 |
+
# gradio_input_types = infer_gradio_input_types(feature_types)
|
27 |
+
|
28 |
+
# def compute(data):
|
29 |
+
# return metric.compute(**parse_gradio_data(data, gradio_input_types))
|
30 |
+
|
31 |
+
# iface = gr.Interface(
|
32 |
+
# fn=compute,
|
33 |
+
# inputs=gr.Dataframe(
|
34 |
+
# headers=feature_names,
|
35 |
+
# col_count=len(feature_names),
|
36 |
+
# row_count=1,
|
37 |
+
# datatype=json_to_string_type(gradio_input_types),
|
38 |
+
# ),
|
39 |
+
# outputs=gr.Textbox(label=metric.name),
|
40 |
+
# description=(
|
41 |
+
# metric.info.description + "\nIf this is a text-based metric, make sure to wrap you input in double quotes."
|
42 |
+
# " Alternatively you can use a JSON-formatted list as input."
|
43 |
+
# ),
|
44 |
+
# title=f"Metric: {metric.name}",
|
45 |
+
# article=parse_readme(local_path / "README.md"),
|
46 |
+
# # TODO: load test cases and use them to populate examples
|
47 |
+
# # examples=[parse_test_cases(test_cases, feature_names, gradio_input_types)]
|
48 |
+
# )
|
49 |
+
|
50 |
+
# iface.launch()
|
51 |
+
# ###
|
52 |
+
|
53 |
+
|
54 |
+
# module = evaluate.load("saicharan2804/my_metric")
|
55 |
+
# launch_gradio_widget(module)
|
my_metric.py
CHANGED
@@ -6,8 +6,8 @@ import pandas as pd
|
|
6 |
|
7 |
def _compute(self, list_of_generated_smiles):
|
8 |
test_set = moses.get_dataset('test')
|
9 |
-
preprocessed_smiles = [smile for smile in list_of_generated_smiles if moses.utils.canonicalize_smiles(smile)]
|
10 |
-
|
11 |
results = metrics.get_all_metrics(preprocessed_smiles, test_set)
|
12 |
|
13 |
return results
|
|
|
6 |
|
7 |
def _compute(self, list_of_generated_smiles):
|
8 |
test_set = moses.get_dataset('test')
|
9 |
+
# preprocessed_smiles = [smile for smile in list_of_generated_smiles if moses.utils.canonicalize_smiles(smile)]
|
10 |
+
preprocessed_smiles = list_of_generated_smiles
|
11 |
results = metrics.get_all_metrics(preprocessed_smiles, test_set)
|
12 |
|
13 |
return results
|