Spaces:
Sleeping
Sleeping
Alex Clefos commited on
Commit ·
5f814e7
1
Parent(s): c5203f5
Update code and update requirements
Browse files- .gitignore +1 -0
- app.py +23 -18
- flagged/log.csv +2 -0
- requirements.txt +94 -5
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
venv
|
app.py
CHANGED
|
@@ -1,14 +1,25 @@
|
|
| 1 |
-
#importing the necessary library
|
| 2 |
import re
|
| 3 |
-
import nltk
|
| 4 |
-
import spacy
|
| 5 |
import math
|
|
|
|
|
|
|
|
|
|
| 6 |
from nltk.tokenize import sent_tokenize
|
| 7 |
nltk.download('punkt')
|
|
|
|
|
|
|
|
|
|
| 8 |
from transformers import pipeline
|
| 9 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 10 |
-
import gradio as gr
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
def clean_text(text):
|
| 14 |
text = text
|
|
@@ -24,16 +35,11 @@ def clean_text(text):
|
|
| 24 |
" +", " ", text
|
| 25 |
).strip() # get rid of multiple spaces and replace with a single
|
| 26 |
return text
|
| 27 |
-
#initailizing the model pipeline
|
| 28 |
-
from transformers import BartTokenizer, BartForConditionalGeneration
|
| 29 |
|
| 30 |
-
model = BartForConditionalGeneration.from_pretrained("sshleifer/distilbart-cnn-12-6")
|
| 31 |
-
tokenizer = BartTokenizer.from_pretrained("sshleifer/distilbart-cnn-12-6")
|
| 32 |
-
nlp = spacy.load("en_core_web_sm")
|
| 33 |
|
| 34 |
-
#Defining a function to get the summary of the article
|
| 35 |
def final_summary(text):
|
| 36 |
-
#reading in the text and tokenizing it into sentence
|
| 37 |
text = text
|
| 38 |
bullet_points = 10
|
| 39 |
|
|
@@ -114,13 +120,12 @@ def final_summary(text):
|
|
| 114 |
|
| 115 |
return summary_bullet
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
#creating an interface for the headline generator using gradio
|
| 120 |
-
demo = gr.Interface(final_summary, inputs=[gr.inputs.Textbox(label="Drop your article here", optional=False)],
|
| 121 |
title = "ARTICLE SUMMARIZER",
|
| 122 |
-
outputs=[gr.
|
| 123 |
-
|
| 124 |
-
|
|
|
|
| 125 |
if __name__ == "__main__":
|
| 126 |
demo.launch(debug=True)
|
|
|
|
| 1 |
+
# importing the necessary library
|
| 2 |
import re
|
|
|
|
|
|
|
| 3 |
import math
|
| 4 |
+
|
| 5 |
+
import spacy
|
| 6 |
+
import nltk
|
| 7 |
from nltk.tokenize import sent_tokenize
|
| 8 |
nltk.download('punkt')
|
| 9 |
+
|
| 10 |
+
import gradio as gr
|
| 11 |
+
|
| 12 |
from transformers import pipeline
|
| 13 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
|
|
|
| 14 |
|
| 15 |
+
from transformers import BartTokenizer, BartForConditionalGeneration
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
# initailizing the model pipeline
|
| 19 |
+
model = BartForConditionalGeneration.from_pretrained("sshleifer/distilbart-cnn-12-6")
|
| 20 |
+
tokenizer = BartTokenizer.from_pretrained("sshleifer/distilbart-cnn-12-6")
|
| 21 |
+
nlp = spacy.load("en_core_web_sm")
|
| 22 |
+
|
| 23 |
|
| 24 |
def clean_text(text):
|
| 25 |
text = text
|
|
|
|
| 35 |
" +", " ", text
|
| 36 |
).strip() # get rid of multiple spaces and replace with a single
|
| 37 |
return text
|
|
|
|
|
|
|
| 38 |
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
# Defining a function to get the summary of the article
|
| 41 |
def final_summary(text):
|
| 42 |
+
# reading in the text and tokenizing it into sentence
|
| 43 |
text = text
|
| 44 |
bullet_points = 10
|
| 45 |
|
|
|
|
| 120 |
|
| 121 |
return summary_bullet
|
| 122 |
|
| 123 |
+
# creating an interface for the headline generator using gradio
|
| 124 |
+
demo = gr.Interface(final_summary, inputs=[gr.Textbox(label="Drop your article here")],
|
|
|
|
|
|
|
| 125 |
title = "ARTICLE SUMMARIZER",
|
| 126 |
+
outputs=[gr.Textbox(label="Summary")],
|
| 127 |
+
)
|
| 128 |
+
|
| 129 |
+
# launching the app
|
| 130 |
if __name__ == "__main__":
|
| 131 |
demo.launch(debug=True)
|
flagged/log.csv
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Drop your article here,Summary,flag,username,timestamp
|
| 2 |
+
,,,,2024-01-11 18:51:55.836880
|
requirements.txt
CHANGED
|
@@ -1,6 +1,95 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
sentencepiece==0.1.96
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
aiofiles==23.2.1
|
| 2 |
+
altair==5.2.0
|
| 3 |
+
annotated-types==0.6.0
|
| 4 |
+
anyio==4.2.0
|
| 5 |
+
attrs==23.2.0
|
| 6 |
+
blis==0.7.11
|
| 7 |
+
catalogue==2.0.10
|
| 8 |
+
certifi==2023.11.17
|
| 9 |
+
charset-normalizer==3.3.2
|
| 10 |
+
click==8.1.7
|
| 11 |
+
cloudpathlib==0.16.0
|
| 12 |
+
colorama==0.4.6
|
| 13 |
+
confection==0.1.4
|
| 14 |
+
contourpy==1.1.1
|
| 15 |
+
cycler==0.12.1
|
| 16 |
+
cymem==2.0.8
|
| 17 |
+
en-core-web-sm @ https://huggingface.co/spacy/en_core_web_sm/resolve/main/en_core_web_sm-any-py3-none-any.whl
|
| 18 |
+
exceptiongroup==1.2.0
|
| 19 |
+
fastapi==0.109.0
|
| 20 |
+
ffmpy==0.3.1
|
| 21 |
+
filelock==3.13.1
|
| 22 |
+
fonttools==4.47.2
|
| 23 |
+
fsspec==2023.12.2
|
| 24 |
+
gradio==4.14.0
|
| 25 |
+
gradio-client==0.8.0
|
| 26 |
+
h11==0.14.0
|
| 27 |
+
httpcore==1.0.2
|
| 28 |
+
httpx==0.26.0
|
| 29 |
+
huggingface-hub==0.20.2
|
| 30 |
+
idna==3.6
|
| 31 |
+
importlib-resources==6.1.1
|
| 32 |
+
Jinja2==3.1.3
|
| 33 |
+
joblib==1.3.2
|
| 34 |
+
jsonschema==4.20.0
|
| 35 |
+
jsonschema-specifications==2023.12.1
|
| 36 |
+
kiwisolver==1.4.5
|
| 37 |
+
langcodes==3.3.0
|
| 38 |
+
markdown-it-py==3.0.0
|
| 39 |
+
MarkupSafe==2.1.3
|
| 40 |
+
matplotlib==3.7.4
|
| 41 |
+
mdurl==0.1.2
|
| 42 |
+
mpmath==1.3.0
|
| 43 |
+
murmurhash==1.0.10
|
| 44 |
+
networkx==3.1
|
| 45 |
+
nltk==3.8.1
|
| 46 |
+
numpy==1.24.4
|
| 47 |
+
orjson==3.9.10
|
| 48 |
+
packaging==23.2
|
| 49 |
+
pandas==2.0.3
|
| 50 |
+
pillow==10.2.0
|
| 51 |
+
pkgutil-resolve-name==1.3.10
|
| 52 |
+
preshed==3.0.9
|
| 53 |
+
pydantic==2.5.3
|
| 54 |
+
pydantic-core==2.14.6
|
| 55 |
+
pydub==0.25.1
|
| 56 |
+
pygments==2.17.2
|
| 57 |
+
pyparsing==3.1.1
|
| 58 |
+
python-dateutil==2.8.2
|
| 59 |
+
python-multipart==0.0.6
|
| 60 |
+
pytz==2023.3.post1
|
| 61 |
+
PyYAML==6.0.1
|
| 62 |
+
referencing==0.32.1
|
| 63 |
+
regex==2023.12.25
|
| 64 |
+
requests==2.31.0
|
| 65 |
+
rich==13.7.0
|
| 66 |
+
rpds-py==0.16.2
|
| 67 |
+
sacremoses==0.1.1
|
| 68 |
+
semantic-version==2.10.0
|
| 69 |
sentencepiece==0.1.96
|
| 70 |
+
shellingham==1.5.4
|
| 71 |
+
six==1.16.0
|
| 72 |
+
smart-open==6.4.0
|
| 73 |
+
sniffio==1.3.0
|
| 74 |
+
spacy==3.7.2
|
| 75 |
+
spacy-legacy==3.0.12
|
| 76 |
+
spacy-loggers==1.0.5
|
| 77 |
+
srsly==2.4.8
|
| 78 |
+
starlette==0.35.0
|
| 79 |
+
sympy==1.12
|
| 80 |
+
thinc==8.2.2
|
| 81 |
+
tokenizers==0.10.3
|
| 82 |
+
tomlkit==0.12.0
|
| 83 |
+
toolz==0.12.0
|
| 84 |
+
torch==2.1.2
|
| 85 |
+
tqdm==4.66.1
|
| 86 |
+
transformers==4.10.2
|
| 87 |
+
typer==0.9.0
|
| 88 |
+
typing-extensions==4.9.0
|
| 89 |
+
tzdata==2023.4
|
| 90 |
+
urllib3==2.1.0
|
| 91 |
+
uvicorn==0.25.0
|
| 92 |
+
wasabi==1.1.2
|
| 93 |
+
weasel==0.3.4
|
| 94 |
+
websockets==11.0.3
|
| 95 |
+
zipp==3.17.0
|