Spaces:
Sleeping
Sleeping
Chris Finlayson
commited on
Commit
·
eb2bab3
1
Parent(s):
1dfb9d3
initial
Browse files- application.py +29 -0
- flagged/file/905c51933114f0933157/The_Design_Space_of_Emergent_Scheduling_for_Distributed_Execution_Frameworks.pdf +0 -0
- flagged/file/e0e08e8da1f761969779/The_Design_Space_of_Emergent_Scheduling_for_Distributed_Execution_Frameworks.pdf +0 -0
- flagged/log.csv +3 -0
- requirements.txt +2 -0
application.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import PyPDF2
|
2 |
+
from transformers import pipeline
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
# Load the summarization pipeline
|
6 |
+
summarizer = pipeline("summarization", model="t5-base", tokenizer="t5-base", framework="pt")
|
7 |
+
|
8 |
+
def load_pdf(file, max_length, min_length, do_sample):
|
9 |
+
pdf = PyPDF2.PdfReader(file)
|
10 |
+
text = ""
|
11 |
+
for page in pdf.pages:
|
12 |
+
text += page.extract_text()
|
13 |
+
# Summarize the text
|
14 |
+
|
15 |
+
summary = summarizer(text, max_length=max_length, min_length=min_length, do_sample=do_sample)
|
16 |
+
# Return the summary
|
17 |
+
return summary[0]['summary_text']
|
18 |
+
# return summarize_pdf(pdf)
|
19 |
+
|
20 |
+
|
21 |
+
inputs = [
|
22 |
+
gr.File(label="Upload PDF"),
|
23 |
+
gr.Slider(500, 1500, value=1000, label="Max Length"),
|
24 |
+
gr.Slider(30, 500, value=300, label="Min Length"),
|
25 |
+
gr.Checkbox(label="Do Sample", value=False)
|
26 |
+
]
|
27 |
+
|
28 |
+
iface = gr.Interface(fn=load_pdf, inputs=inputs, outputs="text", title="PDF summariser")
|
29 |
+
iface.launch()
|
flagged/file/905c51933114f0933157/The_Design_Space_of_Emergent_Scheduling_for_Distributed_Execution_Frameworks.pdf
ADDED
Binary file (474 kB). View file
|
|
flagged/file/e0e08e8da1f761969779/The_Design_Space_of_Emergent_Scheduling_for_Distributed_Execution_Frameworks.pdf
ADDED
Binary file (474 kB). View file
|
|
flagged/log.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
file,output,flag,username,timestamp
|
2 |
+
"{""path"":""flagged/file/905c51933114f0933157/The_Design_Space_of_Emergent_Scheduling_for_Distributed_Execution_Frameworks.pdf"",""url"":""http://127.0.0.1:7860/file=/private/var/folders/jk/znm3f6kd1xj8w5_2n06stbqm0000gn/T/gradio/2be4325bfe343a3851a3fe2a62720746675b6c90/The_Design_Space_of_Emergent_Scheduling_for_Distributed_Execution_Frameworks.pdf"",""size"":474394,""orig_name"":""The_Design_Space_of_Emergent_Scheduling_for_Distributed_Execution_Frameworks.pdf"",""mime_type"":""""}",<PyPDF2._reader.PdfReader object at 0x2aca9eb50>,,,2023-11-10 16:58:42.638294
|
3 |
+
"{""path"":""flagged/file/e0e08e8da1f761969779/The_Design_Space_of_Emergent_Scheduling_for_Distributed_Execution_Frameworks.pdf"",""url"":""http://127.0.0.1:7860/file=/private/var/folders/jk/znm3f6kd1xj8w5_2n06stbqm0000gn/T/gradio/2be4325bfe343a3851a3fe2a62720746675b6c90/The_Design_Space_of_Emergent_Scheduling_for_Distributed_Execution_Frameworks.pdf"",""size"":474394,""orig_name"":""The_Design_Space_of_Emergent_Scheduling_for_Distributed_Execution_Frameworks.pdf"",""mime_type"":""""}",<PyPDF2._reader.PdfReader object at 0x2b07221d0>,,,2023-11-10 17:05:37.811292
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
pypdf2
|
2 |
+
transformers
|