Akshayram1 commited on
Commit
940028c
1 Parent(s): d36b393

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  from pdfminer.high_level import extract_pages, extract_text
3
  from pdfminer.layout import LTTextContainer
 
4
 
5
  title = 'PDF Text Extraction Demo'
6
 
@@ -23,4 +24,25 @@ iface = gr.Interface(fn=extract_text_from_pdf_file,
23
  description="Upload a PDF file to extract its text.",
24
  theme="peach")
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  iface.launch()
 
1
  import gradio as gr
2
  from pdfminer.high_level import extract_pages, extract_text
3
  from pdfminer.layout import LTTextContainer
4
+ from transformers import pipeline
5
 
6
  title = 'PDF Text Extraction Demo'
7
 
 
24
  description="Upload a PDF file to extract its text.",
25
  theme="peach")
26
 
27
+
28
+
29
+ title = 'Question Answering demo with transformers and gradio'
30
+ context = "The Amazon rainforest (Portuguese: Floresta Amazônica or Amazônia; Spanish: Selva Amazónica, Amazonía or usually Amazonia; French: Forêt amazonienne; Dutch: Amazoneregenwoud), also known in English as Amazonia or the Amazon Jungle, is a moist broadleaf forest that covers most of the Amazon basin of South America. This basin encompasses 7,000,000 square kilometres (2,700,000 sq mi), of which 5,500,000 square kilometres (2,100,000 sq mi) are covered by the rainforest. This region includes territory belonging to nine nations. The majority of the forest is contained within Brazil, with 60% of the rainforest, followed by Peru with 13%, Colombia with 10%, and with minor amounts in Venezuela, Ecuador, Bolivia, Guyana, Suriname, and French Guiana. States or departments in four nations contain 'Amazonas' in their names. The Amazon represents over half of the planet's remaining rainforests, and comprises the largest and most biodiverse tract of tropical rainforest in the world, with an estimated 390 billion individual trees divided into 16,000 species."
31
+ question = "Which name is also used to describe the Amazon rainforest in English?"
32
+
33
+
34
+ question_answerer = pipeline("question-answering", model='distilbert-base-cased-distilled-squad')
35
+ #result = question_answerer(question = question, context=context)
36
+ #return result['answer']
37
+
38
+
39
+
40
+
41
+ interface = gr.Interface.from_pipeline(question_answerer,
42
+ title = title,
43
+ theme = "peach",
44
+ examples = [[context, question]]).launch()
45
+
46
+
47
+
48
  iface.launch()