Spaces:
No application file
No application file
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,43 +0,0 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
!pip install gradio
|
| 4 |
-
!pip install Transformers
|
| 5 |
-
import gradio as gr
|
| 6 |
-
|
| 7 |
-
from transformers import pipeline
|
| 8 |
-
|
| 9 |
-
# Replace this with your own checkpoint
|
| 10 |
-
model_checkpoint = "huggingface-course/bert-finetuned-squad"
|
| 11 |
-
question_answerer = pipeline("question-answering", model=model_checkpoint)
|
| 12 |
-
|
| 13 |
-
# # context = """
|
| 14 |
-
# Transformers are deep feed-forward artificial neural networks with a (self)attention mechanism.
|
| 15 |
-
# They have been tremendously successful in natural language processing tasks and other domains.
|
| 16 |
-
# Since their inception 5 years ago [VSP+17], many
|
| 17 |
-
# variants have been suggested [LWLQ21]. Descriptions are usually graphical, verbal, partial, or incremental. Despite their popularity, it seems no
|
| 18 |
-
# pseudocode has ever been published for any variant. Contrast this to other fields of computer
|
| 19 |
-
# science, even to “cousin” discipline reinforcement
|
| 20 |
-
# # learning [MKS+13, SBB18, EMK+21].
|
| 21 |
-
# # """
|
| 22 |
-
# # question = "Where are Transformers?"
|
| 23 |
-
# # question_answerer(question=question, context=context)
|
| 24 |
-
|
| 25 |
-
def fn1(context, question):
|
| 26 |
-
# pdfFile = open(file, 'rb')
|
| 27 |
-
# pdfReader = pdf.PdfFileReader(pdfFile)
|
| 28 |
-
# pageObj = pdf.getPage(0)
|
| 29 |
-
# context = pageObj.extractText()
|
| 30 |
-
return question_answerer(context = context, question = question)
|
| 31 |
-
# pdfFile.close()
|
| 32 |
-
|
| 33 |
-
# def upload_file(files):
|
| 34 |
-
# print("Here")
|
| 35 |
-
# file_paths = [file.name for file in files]
|
| 36 |
-
# return file_paths
|
| 37 |
-
# with gr.Blocks() as demo:
|
| 38 |
-
# file_output = gr.File()
|
| 39 |
-
# upload_button = gr.UploadButton("Click to upload the file",file_types=[".pdf",".csv",".doc"])
|
| 40 |
-
# upload_button.upload(upload_file, upload_button, file_output)
|
| 41 |
-
|
| 42 |
-
demo = gr.Interface(fn1, inputs = ["text", "text"], outputs = "text")
|
| 43 |
-
demo.launch(share = True, debug = True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|