Spaces:
Sleeping
Sleeping
import evaluate | |
from evaluate.utils import infer_gradio_input_types, json_to_string_type, parse_readme | |
from fixed_f1 import FixedF1 | |
# from evaluate.utils import launch_gradio_widget # using this directly is erroneous - lets fix this | |
metric = FixedF1() | |
if isinstance(metric.features, list): | |
(feature_names, feature_types) = zip(*metric.features[0].items()) | |
else: | |
(feature_names, feature_types) = zip(*metric.features.items()) | |
gradio_input_types = infer_gradio_input_types(feature_types) | |
gradio_input_types = infer_gradio_input_types(feature_types) | |
def compute(): | |
metric._compute() | |
import gradio as gr | |
space = gr.Interface( | |
fn=compute, | |
inputs=gr.Dataframe( | |
headers=feature_names, | |
col_count=len(feature_names), | |
row_count=1, | |
datatype=json_to_string_type(gradio_input_types), | |
), | |
outputs=gr.Textbox(label=metric.name), | |
description=( | |
metric.info.description + "\nIf this is a text-based metric, make sure to wrap your input in double quotes." | |
" Alternatively you can use a JSON-formatted list as input." | |
), | |
title=f"Metric: {metric.name}", | |
article=parse_readme("./README.md"), | |
# TODO: load test cases and use them to populate examples | |
# examples=[parse_test_cases(test_cases, feature_names, gradio_input_types)] | |
) | |
space.launch() |