Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
|
3 |
+
# Importing Dependancies
|
4 |
+
|
5 |
+
import gradio as gr
|
6 |
+
from transformers import pipeline
|
7 |
+
|
8 |
+
"""# Loading Model Name"""
|
9 |
+
|
10 |
+
model_name = "deepset/roberta-base-squad2"
|
11 |
+
|
12 |
+
"""# Get Predictions
|
13 |
+
"""
|
14 |
+
|
15 |
+
nlu = pipeline('question-answering', model=model_name, tokenizer=model_name)
|
16 |
+
|
17 |
+
def func(context, question):
|
18 |
+
input = {
|
19 |
+
'question':question,
|
20 |
+
'context':context
|
21 |
+
}
|
22 |
+
res = nlu(input)
|
23 |
+
return res["answer", "score"]
|
24 |
+
|
25 |
+
descr = "This is a question and Answer Web app, you give it a context and ask it questions based on the context provided"
|
26 |
+
|
27 |
+
app = gr.Interface(fn=func, inputs=[gr.inputs.Textbox(lines=3, placeholder="put in your context here..."),"text"], outputs="text", title="Question Answer App", description=descr)
|
28 |
+
|
29 |
+
app.launch()
|