Spaces:
Running
Running
File size: 4,089 Bytes
5f2c1c3 4a5f826 1e94a7d 5f2c1c3 a90f1c4 66ae007 4a5f826 9183d8e 4a5f826 9183d8e 4a5f826 66ae007 5f2c1c3 a90f1c4 48f0f78 5f2c1c3 9183d8e 5f2c1c3 9183d8e 5f2c1c3 9183d8e 5f2c1c3 48f0f78 a90f1c4 9183d8e 5f2c1c3 9183d8e 5f2c1c3 a90f1c4 5f2c1c3 3c576d2 5f2c1c3 a90f1c4 5f2c1c3 1e94a7d 5bf95ef |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
import gradio as gr
from main import main
import json
import subprocess
def installChrome():
subprocess.run(['apt-get', 'update'])
subprocess.run(['apt-get', 'install', '-y', 'wget', 'unzip'])
subprocess.run(['wget', 'https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb'])
subprocess.run(['apt-get', 'install', '-y', './google-chrome-stable_current_amd64.deb'])
subprocess.run(['rm', 'google-chrome-stable_current_amd64.deb'])
subprocess.run(['apt-get', 'clean'])
def rexplore_summarizer(url, title, id, citation, access_key):
response = json.loads(main(url, title, id, citation, access_key))
data = json.dumps(response, ensure_ascii=False, indent=4)
if response["mindmap_status"] != "success":
mindmap = "error"
else:
mindmap = response["mindmap"]
if response["summary_status"] != "success":
summary = "error"
else:
summary = response["summary"]
return data, summary, mindmap
def clear_everything(url, title, id, citation, access_key, raw_data, summary, mindmap):
return None, None, None, None, None, None
theme = gr.themes.Soft(
primary_hue="purple",
secondary_hue="cyan",
neutral_hue="slate",
font=[
gr.themes.GoogleFont("Syne"),
gr.themes.GoogleFont("Poppins"),
gr.themes.GoogleFont("Poppins"),
gr.themes.GoogleFont("Poppins")
],
)
with gr.Blocks(theme=theme, title="ReXplore Summarizer", fill_height=True) as app:
gr.HTML(
value ="""
<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>
<p style="text-align: center;">This app uses a hybrid approach to summarize PDF documents based on CPU as well as GPU.</p>
<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>
<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>
""")
with gr.Row():
with gr.Column():
url = gr.Textbox(label="PDF URL", placeholder="Paste the PDF URL here")
title = gr.Textbox(label="Title", placeholder="Enter the title Research Paper")
id = gr.Textbox(label="DOI/arXiv ID", placeholder="Enter the DOI or arXiv ID of the Research Paper")
citation = gr.Textbox(label="Citation", placeholder="Enter the citation of the Research Paper")
access_key = gr.Textbox(label="Access Key", placeholder="Enter the Access Key", type="password")
with gr.Row():
clear_btn = gr.Button(value="Clear", variant="stop")
summarize_btn = gr.Button(value="Summarize", variant="primary")
raw_data = gr.TextArea(label="Raw Data", placeholder="The generated raw data will be displayed here", lines=7, interactive=False, show_copy_button=True)
with gr.Row():
summary = gr.TextArea(label="Summary", placeholder="The generated summary will be displayed here", lines=7, interactive=False, show_copy_button=True)
mindmap = gr.TextArea(label="Mindmap", placeholder="The generated mindmap will be displayed here", lines=7, interactive=False, show_copy_button=True)
summarize_btn.click(
rexplore_summarizer,
inputs=[url, title, id, citation, access_key],
outputs=[raw_data, summary, mindmap],
concurrency_limit=25,
scroll_to_output=True,
show_api=True,
api_name="rexplore_summarizer",
show_progress="full",
)
clear_btn.click(clear_everything, inputs=[url, title, id, citation, raw_data, summary, mindmap, access_key], outputs=[url, id, raw_data, summary, mindmap, access_key], show_api=False)
installChrome()
app.queue(default_concurrency_limit=25).launch(show_api=True, ssr_mode=False)
|