kimhung0011's picture
Update app.py
11338f1 verified
raw
history blame
685 Bytes
import subprocess
# Install transformers library
subprocess.check_call(["pip", "install", "transformers"])
subprocess.check_call(["pip", "install", "torch"])
import gradio as gr
from transformers import pipeline
# Replace this with your own checkpoint
model_checkpoint = "huggingface-course/bert-finetuned-squad"
question_answerer = pipeline("question-answering", model=model_checkpoint)
def answer_question(question, context):
answer = question_answerer(question=question, context=context)
return answer['answer']
iface = gr.Interface(
fn=answer_question,
inputs=["text", "text"],
outputs="text",
title="Hugging Face Question Answering"
)
iface.launch()