raannakasturi commited on
Commit
5f2c1c3
·
verified ·
1 Parent(s): c8669d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +57 -54
app.py CHANGED
@@ -1,54 +1,57 @@
1
- import gradio as gr
2
- from main import main
3
-
4
- def rexplore_summarizer(corpus):
5
- response = main(corpus)
6
- return response, response['summary'], response['mindmap']
7
-
8
- def clear_everything(text_corpus, raw_data, summary, mindmap):
9
- return None, None, None, None
10
-
11
- theme = gr.themes.Soft(
12
- primary_hue="purple",
13
- secondary_hue="cyan",
14
- neutral_hue="slate",
15
- font=[
16
- gr.themes.GoogleFont('Syne'),
17
- gr.themes.GoogleFont('Poppins'),
18
- gr.themes.GoogleFont('Poppins'),
19
- gr.themes.GoogleFont('Poppins')
20
- ],
21
- )
22
-
23
- with gr.Blocks(theme=theme, title="ReXplore Summarizer", fill_height=True) as app:
24
- gr.HTML(
25
- value ='''
26
- <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>
27
- <p style="text-align: center;">This app uses a hybrid approach to summarize PDF documents based on CPU as well as GPU.</p>
28
- <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>
29
- <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>
30
- ''')
31
- with gr.Row():
32
- with gr.Column():
33
- text_corpus = gr.TextArea(label="Text Corpus", placeholder="Paste the text corpus here", lines=5)
34
- with gr.Row():
35
- clear_btn = gr.Button(value="Clear", variant='stop')
36
- summarize_btn = gr.Button(value="Summarize", variant='primary')
37
- raw_data = gr.TextArea(label="Raw Data", placeholder="The generated raw data will be displayed here", lines=7, interactive=False, show_copy_button=True)
38
- with gr.Row():
39
- summary = gr.TextArea(label="Summary", placeholder="The generated summary will be displayed here", lines=7, interactive=False, show_copy_button=True)
40
- mindmap = gr.TextArea(label="Mindmap", placeholder="The generated mindmap will be displayed here", lines=7, interactive=False, show_copy_button=True)
41
-
42
- summarize_btn.click(
43
- rexplore_summarizer,
44
- inputs=[text_corpus],
45
- outputs=[raw_data, summary, mindmap],
46
- concurrency_limit=1,
47
- scroll_to_output=True,
48
- show_api=True,
49
- api_name="rexplore_summarizer",
50
- show_progress="full",
51
- )
52
- clear_btn.click(clear_everything, inputs=[text_corpus, raw_data, summary, mindmap], outputs=[text_corpus, raw_data, summary, mindmap], show_api=False)
53
-
54
- app.queue(default_concurrency_limit=1).launch(show_api=True)
 
 
 
 
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)