raannakasturi commited on
Commit
a99ee48
·
verified ·
1 Parent(s): af1f176

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +67 -69
app.py CHANGED
@@ -1,69 +1,67 @@
1
- import os
2
- import sys
3
- from generate_markdown import load_llm_model, generate_markdown
4
- from generate_mindmap import generate_mindmap_svg
5
- import gradio as gr
6
- import subprocess
7
-
8
- llm = load_llm_model()
9
-
10
- def generate(file):
11
- summary = "This is a summary of the research paper"
12
- mindmap_markdown = generate_markdown(llm, file)
13
- mindmap_svg = generate_mindmap_svg(mindmap_markdown)
14
- return summary, mindmap_markdown, mindmap_svg
15
-
16
- theme = gr.themes.Soft(
17
- primary_hue="purple",
18
- secondary_hue="cyan",
19
- neutral_hue="slate",
20
- font=[gr.themes.GoogleFont('Syne'), gr.themes.GoogleFont('poppins'), gr.themes.GoogleFont('poppins'), gr.themes.GoogleFont('poppins')],
21
- )
22
-
23
- with gr.Blocks(theme=theme, title="Binary Biology") as app:
24
- file = gr.File(file_count='single', label='Upload Research Paper PDF file')
25
- summary = gr.TextArea(label='Summary', lines=5, interactive=False, show_copy_button=True)
26
- markdown_mindmap = gr.Textbox(label='Mindmap', lines=5, interactive=False, show_copy_button=True)
27
- graphical_mindmap = gr.Image(label='Graphical Mindmap', interactive=False, show_download_button=True)
28
- submit = gr.Button(value='Submit')
29
-
30
- submit.click(generate,
31
- inputs=[file],
32
- outputs=[summary, markdown_mindmap, graphical_mindmap],
33
- scroll_to_output=True,
34
- show_progress=True,
35
- queue=True,
36
- )
37
-
38
- if __name__ == "__main__":
39
- # Download models
40
- subprocess.run(['wget', '-o', 'model.gguf', 'https://huggingface.co/featherless-ai-quants/amazon-MegaBeam-Mistral-7B-300k-GGUF/resolve/main/amazon-MegaBeam-Mistral-7B-300k-Q6_K.gguf?download=true'])
41
- # run entire command: "CMAKE_ARGS="-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python"
42
- try:
43
- env = os.environ.copy()
44
- env["CMAKE_ARGS"] = "-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS"
45
- cmd = ["pip", "install", "llama-cpp-python"]
46
- subprocess.run(cmd, env=env)
47
- except:
48
- cmd = ["pip", "install", "llama-cpp-python"]
49
- subprocess.run(cmd)
50
- try:
51
- try:
52
- subprocess.run(['apt', 'install', '-y', 'graphviz'])
53
- print("Graphviz installed successfully")
54
- except:
55
- subprocess.run(['sudo', 'apt', 'install', '-y', 'graphviz'])
56
- print("Graphviz installed successfully")
57
- except:
58
- print("Graphviz installation failed")
59
- sys.exit(1)
60
- print("Model loaded successfully")
61
- llm = load_llm_model()
62
- print("Model loaded successfully")
63
- app.queue(default_concurrency_limit=5).launch(show_error=True)
64
- # summary, markdown_mindmap, graphical_mindmap = generate("cr1c00107.pdf")
65
- # print(summary)
66
- # print("\n\n")
67
- # print(markdown_mindmap)
68
- # print("\n\n")
69
- # print(graphical_mindmap)
 
1
+ import os
2
+ import sys
3
+ from generate_markdown import load_llm_model, generate_markdown
4
+ from generate_mindmap import generate_mindmap_svg
5
+ import gradio as gr
6
+ import subprocess
7
+
8
+ llm = load_llm_model()
9
+
10
+ def generate(file):
11
+ summary = "This is a summary of the research paper"
12
+ mindmap_markdown = generate_markdown(llm, file)
13
+ mindmap_svg = generate_mindmap_svg(mindmap_markdown)
14
+ return summary, mindmap_markdown, mindmap_svg
15
+
16
+ theme = gr.themes.Soft(
17
+ primary_hue="purple",
18
+ secondary_hue="cyan",
19
+ neutral_hue="slate",
20
+ font=[gr.themes.GoogleFont('Syne'), gr.themes.GoogleFont('poppins'), gr.themes.GoogleFont('poppins'), gr.themes.GoogleFont('poppins')],
21
+ )
22
+
23
+ with gr.Blocks(theme=theme, title="Binary Biology") as app:
24
+ file = gr.File(file_count='single', label='Upload Research Paper PDF file')
25
+ summary = gr.TextArea(label='Summary', lines=5, interactive=False, show_copy_button=True)
26
+ markdown_mindmap = gr.Textbox(label='Mindmap', lines=5, interactive=False, show_copy_button=True)
27
+ graphical_mindmap = gr.Image(label='Graphical Mindmap', interactive=False, show_download_button=True)
28
+ submit = gr.Button(value='Submit')
29
+
30
+ submit.click(generate,
31
+ inputs=[file],
32
+ outputs=[summary, markdown_mindmap, graphical_mindmap],
33
+ scroll_to_output=True,
34
+ show_progress=True,
35
+ queue=True,
36
+ )
37
+
38
+ if __name__ == "__main__":
39
+ # run entire command: "CMAKE_ARGS="-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python"
40
+ try:
41
+ env = os.environ.copy()
42
+ env["CMAKE_ARGS"] = "-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS"
43
+ cmd = ["pip", "install", "llama-cpp-python"]
44
+ subprocess.run(cmd, env=env)
45
+ except:
46
+ cmd = ["pip", "install", "llama-cpp-python"]
47
+ subprocess.run(cmd)
48
+ try:
49
+ try:
50
+ subprocess.run(['apt', 'install', '-y', 'graphviz'])
51
+ print("Graphviz installed successfully")
52
+ except:
53
+ subprocess.run(['sudo', 'apt', 'install', '-y', 'graphviz'])
54
+ print("Graphviz installed successfully")
55
+ except:
56
+ print("Graphviz installation failed")
57
+ sys.exit(1)
58
+ print("Model loaded successfully")
59
+ llm = load_llm_model()
60
+ print("Model loaded successfully")
61
+ app.queue(default_concurrency_limit=5).launch(show_error=True)
62
+ # summary, markdown_mindmap, graphical_mindmap = generate("cr1c00107.pdf")
63
+ # print(summary)
64
+ # print("\n\n")
65
+ # print(markdown_mindmap)
66
+ # print("\n\n")
67
+ # print(graphical_mindmap)