Saurabhz commited on
Commit
e7ee46c
·
1 Parent(s): e2e273d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Replace this with your own checkpoint
5
+ model_checkpoint = "huggingface-course/bert-finetuned-squad"
6
+ model = pipeline("question-answering", model=model_checkpoint)
7
+
8
+ def question_answer(context, question,model):
9
+ to_predict = [
10
+ {
11
+ "context": context,
12
+ "qas": [
13
+ {
14
+ "question": question,
15
+ "id": "0",
16
+ }
17
+ ],
18
+ }
19
+ ]
20
+ answers, probabilities = model.predict(to_predict)
21
+ return answers[0]['answer'][0]
22
+
23
+ gr.Interface(fn=question_answer, inputs=["text", "text"], outputs=["textbox"]).launch()