Muhammad Anas Akhtar commited on
Commit
cc30266
·
verified ·
1 Parent(s): d5ea22f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -8,6 +8,8 @@ from transformers import pipeline
8
  question_answer = pipeline("question-answering",
9
  model="deepset/roberta-base-squad2")
10
 
 
 
11
 
12
  def read_file_content(file_obj):
13
  """
@@ -26,15 +28,16 @@ def read_file_content(file_obj):
26
 
27
 
28
 
 
29
  def get_answer(file, question):
30
  context = read_file_content(file)
31
  answer = question_answer(question=question, context=context)
32
  return answer["answer"]
33
 
34
  demo = gr.Interface(fn=get_answer,
35
- inputs=[gr.File(label="Upload your file (.txt)"), gr.Textbox(label="Input your question",lines=1)],
36
  outputs=[gr.Textbox(label="Answer text",lines=1)],
37
- title="Document Question And Answer
38
  description="THIS APPLICATION WILL BE USED TO ANSER QUESTIONS BASED ON CONTEXT PROVIDED.")
39
 
40
  demo.launch()
 
8
  question_answer = pipeline("question-answering",
9
  model="deepset/roberta-base-squad2")
10
 
11
+ # question_answer = pipeline("question-answering",
12
+ # model=model_path)
13
 
14
  def read_file_content(file_obj):
15
  """
 
28
 
29
 
30
 
31
+
32
  def get_answer(file, question):
33
  context = read_file_content(file)
34
  answer = question_answer(question=question, context=context)
35
  return answer["answer"]
36
 
37
  demo = gr.Interface(fn=get_answer,
38
+ inputs=[gr.File(label="Upload your file"), gr.Textbox(label="Input your question",lines=1)],
39
  outputs=[gr.Textbox(label="Answer text",lines=1)],
40
+ title="Document Q & A",
41
  description="THIS APPLICATION WILL BE USED TO ANSER QUESTIONS BASED ON CONTEXT PROVIDED.")
42
 
43
  demo.launch()