Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import spaces
|
3 |
+
|
4 |
+
from transformers import pipeline
|
5 |
+
|
6 |
+
pipe = pipeline(task="question-answering", model="decodingchris/distilbert-base-uncased-finetuned-squad-v2")
|
7 |
+
|
8 |
+
@spaces.GPU
|
9 |
+
def get_answer(context, question):
|
10 |
+
result = pipe(context=context, question=question)
|
11 |
+
return result['answer']
|
12 |
+
|
13 |
+
demo = gr.Interface(fn=get_answer, inputs=["textarea", "text"], outputs=gr.Textbox(label="answer"))
|
14 |
+
|
15 |
+
demo.launch()
|