Spaces:
Sleeping
Sleeping
Commit
·
4a10621
1
Parent(s):
e3583d3
added the app.py file
Browse files- app.py +21 -4
- requirements.txt +1 -1
- src/TextSummarizer/pipeline/prediction.py +2 -1
app.py
CHANGED
@@ -1,8 +1,25 @@
|
|
1 |
import gradio as gr
|
2 |
|
|
|
3 |
|
4 |
-
def greet(name):
|
5 |
-
return "Hello " + name + "!!"
|
6 |
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
from src.TextSummarizer.pipeline.prediction import PredictionPipeline
|
4 |
|
|
|
|
|
5 |
|
6 |
+
def predict(document):
|
7 |
+
"""
|
8 |
+
Method will take the document and summarize it.
|
9 |
+
"""
|
10 |
+
|
11 |
+
# predict the summary using my own pre-trained model.
|
12 |
+
summary = PredictionPipeline().predict(document)
|
13 |
+
return summary
|
14 |
+
|
15 |
+
|
16 |
+
# Create the frontend.
|
17 |
+
input_interfaces: list = []
|
18 |
+
|
19 |
+
with gr.Blocks(theme=gr.theme.Soft()) as app:
|
20 |
+
with gr.Row():
|
21 |
+
title = "Text Summarizer..."
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
app.launch()
|
requirements.txt
CHANGED
@@ -13,7 +13,7 @@ transformers
|
|
13 |
# notebook
|
14 |
# boto3
|
15 |
# mypy-boto3-s3
|
16 |
-
|
17 |
# ensure==1.0.2
|
18 |
# fastapi==0.78.0
|
19 |
# uvicorn==0.18.3
|
|
|
13 |
# notebook
|
14 |
# boto3
|
15 |
# mypy-boto3-s3
|
16 |
+
python-box==6.0.2
|
17 |
# ensure==1.0.2
|
18 |
# fastapi==0.78.0
|
19 |
# uvicorn==0.18.3
|
src/TextSummarizer/pipeline/prediction.py
CHANGED
@@ -7,12 +7,13 @@ class PredictionPipeline:
|
|
7 |
def __init__(self):
|
8 |
self.config = ConfigManager().get_model_evaluation_config()
|
9 |
|
10 |
-
def predict(self,text):
|
11 |
"""
|
12 |
Predict the tex summarization for the given text.
|
13 |
"""
|
14 |
gen_kwargs = {"length_penalty": 0.8, "num_beams":8, "max_length": 128}
|
15 |
|
|
|
16 |
summarizer = pipeline("summarization", model=self.config.hub_model_name)
|
17 |
|
18 |
print("document:")
|
|
|
7 |
def __init__(self):
|
8 |
self.config = ConfigManager().get_model_evaluation_config()
|
9 |
|
10 |
+
def predict(self, text):
|
11 |
"""
|
12 |
Predict the tex summarization for the given text.
|
13 |
"""
|
14 |
gen_kwargs = {"length_penalty": 0.8, "num_beams":8, "max_length": 128}
|
15 |
|
16 |
+
# Call our own pretrained model from hugging face.
|
17 |
summarizer = pipeline("summarization", model=self.config.hub_model_name)
|
18 |
|
19 |
print("document:")
|