Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,8 @@ import torch
|
|
4 |
import transformers
|
5 |
from transformers import pipeline
|
6 |
import re
|
7 |
-
import
|
|
|
8 |
|
9 |
def remove_references(text):
|
10 |
text = re.sub(r'\[\d+\]', '', text) ##[ref]
|
@@ -15,6 +16,13 @@ def remove_references(text):
|
|
15 |
return text
|
16 |
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
def model(model_name):
|
19 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
20 |
model = AutoModelForQuestionAnswering.from_pretrained(model_name,return_dict = False)
|
@@ -46,7 +54,9 @@ theme = gr.themes.Soft().set(
|
|
46 |
body_text_color_subdued='*body_text_color',
|
47 |
body_text_color_subdued_dark='*chatbot_code_background_color'
|
48 |
)
|
49 |
-
|
|
|
|
|
50 |
app = gr.Interface(fn=qa_result,
|
51 |
inputs = ['textbox', 'text'],
|
52 |
outputs = 'textbox', title = 'Ողջու՛յն։ Ես քո արհեստական բանականությամբ օգնականն եմ ', theme = theme, description = 'Տու՛ր ինձ տեքստ, ու տեքստին վերաբերող հարցեր, ու ես կօգնեմ քեզ պատասխանել հարցերին')
|
|
|
4 |
import transformers
|
5 |
from transformers import pipeline
|
6 |
import re
|
7 |
+
import HTML
|
8 |
+
from pypdf import PdfReader
|
9 |
|
10 |
def remove_references(text):
|
11 |
text = re.sub(r'\[\d+\]', '', text) ##[ref]
|
|
|
16 |
return text
|
17 |
|
18 |
|
19 |
+
def extract_text_from_pdf(file_path):
|
20 |
+
reader = PdfReader(file_path)
|
21 |
+
text = ""
|
22 |
+
for page in reader.pages:
|
23 |
+
text += page.extract_text() + "\n"
|
24 |
+
|
25 |
+
|
26 |
def model(model_name):
|
27 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
28 |
model = AutoModelForQuestionAnswering.from_pretrained(model_name,return_dict = False)
|
|
|
54 |
body_text_color_subdued='*body_text_color',
|
55 |
body_text_color_subdued_dark='*chatbot_code_background_color'
|
56 |
)
|
57 |
+
with gr.Column(scale=0.15, min_width=0):
|
58 |
+
btn = gr.UploadButton("📁", file_types=[".pdf",".csv",".doc"])
|
59 |
+
|
60 |
app = gr.Interface(fn=qa_result,
|
61 |
inputs = ['textbox', 'text'],
|
62 |
outputs = 'textbox', title = 'Ողջու՛յն։ Ես քո արհեստական բանականությամբ օգնականն եմ ', theme = theme, description = 'Տու՛ր ինձ տեքստ, ու տեքստին վերաբերող հարցեր, ու ես կօգնեմ քեզ պատասխանել հարցերին')
|