Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
pipe = pipeline("question-answering", model="huggingface-course/bert-finetuned-squad")
|
| 5 |
+
|
| 6 |
+
def qa(question, answer):
|
| 7 |
+
return pipe(question=question, context=context)
|
| 8 |
+
|
| 9 |
+
with gr.Blocks() as demo:
|
| 10 |
+
with gr.Row():
|
| 11 |
+
with gr.Column():
|
| 12 |
+
question = gr.Textbox(label= 'Question')
|
| 13 |
+
context = gr.Textbox(label= 'Context')
|
| 14 |
+
submit_btn = gr.Button(value = 'Submit')
|
| 15 |
+
with gr.Column():
|
| 16 |
+
answer = gr.Textbox(label= 'Answer')
|
| 17 |
+
|
| 18 |
+
submit_btn.click(qa, inputs = [question, context], outputs = answer)
|
| 19 |
+
|
| 20 |
+
demo.launch()
|
| 21 |
+
|