danieldux's picture
Update app.py with Gradio interface
41dfd1b
raw
history blame
1.06 kB
# import evaluate
# from evaluate.utils import launch_gradio_widget
# module = evaluate.load("danieldux/metric_template_1")
# launch_gradio_widget(module)
import evaluate
import gradio as gr
# Load your metric module
module = evaluate.load("danieldux/metric_template_1")
# Define pre-populated examples
examples = [
{
"references": ["1111", "1112", "1113", "1114"],
"predictions": ["1111", "1113", "1120", "1211"],
}
# {"references": ["It is a sunny day."], "predictions": ["The day is sunny."]}
]
# Use the modules "compute" function that takes references and predictions
def compute_metric(references, predictions):
return module.compute(references=[references], predictions=[predictions])
# Create a Gradio interface
iface = gr.Interface(
fn=compute_metric,
inputs=[
gr.inputs.Textbox(lines=2, label="References"),
gr.inputs.Textbox(lines=2, label="Predictions"),
],
outputs="text",
examples=examples, # Pass the pre-populated examples here
)
# Launch the interface
iface.launch()