hagara/Medical-Text-Classification
0
1import gradio as gr2from transformers import pipeline3 4 5model_checkpoint = "hagara/roberta-large-2"6 7 8# Load the text classification pipeline9pipe = pipeline("text-classification", model=model_checkpoint)10 11def classify_text(text, question):12 result = pipe(question, text)13 if result[0]['label'] == 'LABEL_0':14 result[0]['label'] = 'yes'15 elif result[0]['label'] == 'LABEL_1':16 result[0]['label'] = 'no'17 return result[0]['label'], result[0]['score']18 19# Create the Gradio interface20iface = gr.Interface(21 fn=classify_text,22 inputs=["text", "text"],23 outputs=["text", "number"],24 layout="vertical",25 live=True,26 title="Get yes/no answer for your medical question",27 description="Predict if a statement is true or false."28)29 30# Launch the Gradio interface31iface.launch()32 