Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,54 +1,57 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from main import main
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
gr.themes.GoogleFont('
|
18 |
-
gr.themes.GoogleFont('Poppins'),
|
19 |
-
gr.themes.GoogleFont('Poppins')
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
<
|
28 |
-
<p style="text-align: center;">
|
29 |
-
<p style="text-align: center;">The
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from main import main
|
3 |
+
import nltk
|
4 |
+
|
5 |
+
def rexplore_summarizer(corpus):
|
6 |
+
response = main(corpus)
|
7 |
+
return response, response['summary'], response['mindmap']
|
8 |
+
|
9 |
+
def clear_everything(text_corpus, raw_data, summary, mindmap):
|
10 |
+
return None, None, None, None
|
11 |
+
|
12 |
+
theme = gr.themes.Soft(
|
13 |
+
primary_hue="purple",
|
14 |
+
secondary_hue="cyan",
|
15 |
+
neutral_hue="slate",
|
16 |
+
font=[
|
17 |
+
gr.themes.GoogleFont('Syne'),
|
18 |
+
gr.themes.GoogleFont('Poppins'),
|
19 |
+
gr.themes.GoogleFont('Poppins'),
|
20 |
+
gr.themes.GoogleFont('Poppins')
|
21 |
+
],
|
22 |
+
)
|
23 |
+
|
24 |
+
with gr.Blocks(theme=theme, title="ReXplore Summarizer", fill_height=True) as app:
|
25 |
+
gr.HTML(
|
26 |
+
value ='''
|
27 |
+
<h1 style="text-align: center;">ReXplore Summarizer <p style="text-align: center;">Designed and Developed by <a href='https://raannakasturi.eu.org' target="_blank" rel="nofollow noreferrer external">Nayan Kasturi</a></p> </h1>
|
28 |
+
<p style="text-align: center;">This app uses a hybrid approach to summarize PDF documents based on CPU as well as GPU.</p>
|
29 |
+
<p style="text-align: center;">The app uses traditional methodologies such as TextRank, LSA, Luhn algorithms as well as large language model (LLM) to generate summaries as well as mindmaps.</p>
|
30 |
+
<p style="text-align: center;">The summarization process can take some time depending on the size of the text corpus and the complexity of the content.</p>
|
31 |
+
''')
|
32 |
+
with gr.Row():
|
33 |
+
with gr.Column():
|
34 |
+
text_corpus = gr.TextArea(label="Text Corpus", placeholder="Paste the text corpus here", lines=5)
|
35 |
+
with gr.Row():
|
36 |
+
clear_btn = gr.Button(value="Clear", variant='stop')
|
37 |
+
summarize_btn = gr.Button(value="Summarize", variant='primary')
|
38 |
+
raw_data = gr.TextArea(label="Raw Data", placeholder="The generated raw data will be displayed here", lines=7, interactive=False, show_copy_button=True)
|
39 |
+
with gr.Row():
|
40 |
+
summary = gr.TextArea(label="Summary", placeholder="The generated summary will be displayed here", lines=7, interactive=False, show_copy_button=True)
|
41 |
+
mindmap = gr.TextArea(label="Mindmap", placeholder="The generated mindmap will be displayed here", lines=7, interactive=False, show_copy_button=True)
|
42 |
+
|
43 |
+
summarize_btn.click(
|
44 |
+
rexplore_summarizer,
|
45 |
+
inputs=[text_corpus],
|
46 |
+
outputs=[raw_data, summary, mindmap],
|
47 |
+
concurrency_limit=1,
|
48 |
+
scroll_to_output=True,
|
49 |
+
show_api=True,
|
50 |
+
api_name="rexplore_summarizer",
|
51 |
+
show_progress="full",
|
52 |
+
)
|
53 |
+
clear_btn.click(clear_everything, inputs=[text_corpus, raw_data, summary, mindmap], outputs=[text_corpus, raw_data, summary, mindmap], show_api=False)
|
54 |
+
|
55 |
+
nltk.download('punkt')
|
56 |
+
nltk.download('punkt_tab')
|
57 |
+
app.queue(default_concurrency_limit=1).launch(show_api=True)
|