Spaces:
Sleeping
Sleeping
from transformers import pipeline | |
import gradio as gr | |
import spaces | |
import torch | |
models = { | |
'devngho/ko_edu_classifier_v2_nlpai-lab_KoE5': pipeline("text-classification", model="devngho/ko_edu_classifier_v2_nlpai-lab_KoE5", device='cuda', torch_dtype=torch.bfloat16), | |
'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", device='cuda', torch_dtype=torch.bfloat16), | |
'devngho/ko_edu_classifier_v2_LaBSE': pipeline("text-classification", model="devngho/ko_edu_classifier_v2_LaBSE", device='cuda', torch_dtype=torch.bfloat16) | |
} | |
import gradio as gr | |
def evaluate_model(input_text): | |
return [model(input_text)[0]['score'] * 5 if model_name != 'devngho/ko_edu_classifier_v2_nlpai-lab_KoE5' else model('passage: ' + input_text)[0]['score'] * 5 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(label=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() | |