import gradio as gr from transformers import pipeline print("Loading models...") quality_pipe = pipeline("text-classification", model="FareehaAly/fator-argument-quality", top_k=None) fallacy_pipe = pipeline("text-classification", model="FareehaAly/fator-fallacy-detector", top_k=None) print("Models loaded!") def predict_quality(text): return quality_pipe(text[:512]) def predict_fallacy(text): return fallacy_pipe(text[:512]) with gr.Blocks() as demo: gr.Markdown("## FATOR NLP API - Running") with gr.Row(): txt = gr.Textbox(label="Input text", scale=4) with gr.Row(): btn_q = gr.Button("Quality") btn_f = gr.Button("Fallacy") out_q = gr.JSON(label="Quality Result") out_f = gr.JSON(label="Fallacy Result") btn_q.click(predict_quality, inputs=txt, outputs=out_q, api_name="quality") btn_f.click(predict_fallacy, inputs=txt, outputs=out_f, api_name="fallacy") demo.launch(server_name="0.0.0.0", server_port=7860)