devngho's picture
Update app.py
e276d6e verified
raw
history blame
1.17 kB
from transformers import pipeline
import gradio as gr
models = {
'devngho/ko_edu_classifier_v2_nlpai-lab_KoE5': pipeline("text-classification", model="devngho/ko_edu_classifier_v2_nlpai-lab_KoE5"),
'devngho/ko_edu_classifier_v2_lemon-mint_LaBSE-EnKo-Nano-Preview-v0.3': pipeline("text-classification", model="devngho/ko_edu_classifier_v2_lemon-mint_LaBSE-EnKo-Nano-Preview-v0.3"),
'devngho/ko_edu_classifier_v2_LaBSE': pipeline("text-classification", model="devngho/ko_edu_classifier_v2_LaBSE")
}
import gradio as gr
def evaluate_model(input_text):
return [model(input_text)[0]['score'] * 6 if model_name != 'devngho/ko_edu_classifier_v2_nlpai-lab_KoE5' else model('passage: ' + input_text)[0]['score'] * 6 for model_name, model in models.items()]
# Gradio interface
with gr.Blocks() as demo:
input_text = gr.Textbox(label="Input Text", lines=10)
submit_button = gr.Button("Evaluate")
output_scores = [gr.Number(f'Score by {name}', show_label=True) for name in models.keys()]
# Action to perform on button click
submit_button.click(evaluate_model, inputs=input_text, outputs=output_scores)
# Launch the app
demo.launch()