nurindahpratiwi
commited on
Commit
·
e3b62d5
1
Parent(s):
6665931
fix line
Browse files
app.py
CHANGED
@@ -7,32 +7,8 @@ import torch
|
|
7 |
import base64
|
8 |
from PIL import Image
|
9 |
|
10 |
-
#image = Image.open('../banner.png')
|
11 |
st.image("https://huggingface.co/spaces/wiwaaw/summary/resolve/main/banner.png")
|
12 |
|
13 |
-
#st.image(image)
|
14 |
-
|
15 |
-
custom_html = """
|
16 |
-
<div class="banner">
|
17 |
-
<img src="https://huggingface.co/spaces/wiwaaw/summary/resolve/main/banner.png" alt="Banner Image">
|
18 |
-
</div>
|
19 |
-
<style>
|
20 |
-
.banner {
|
21 |
-
width: 160%;
|
22 |
-
height: 100%;
|
23 |
-
overflow: hidden;
|
24 |
-
}
|
25 |
-
.banner img {
|
26 |
-
width: 100%;
|
27 |
-
height: 100%;
|
28 |
-
object-fit: cover;
|
29 |
-
}
|
30 |
-
</style>
|
31 |
-
"""
|
32 |
-
# Display the custom HTML
|
33 |
-
#st.components.v1.html(custom_html)
|
34 |
-
|
35 |
-
|
36 |
# Model and tokenizer
|
37 |
model_checkpoint = "MBZUAI/LaMini-Flan-T5-783M"
|
38 |
model_tokenizer = T5Tokenizer.from_pretrained(model_checkpoint)
|
@@ -56,7 +32,7 @@ def language_model_pipeline(filepath, maxlength):
|
|
56 |
model=model,
|
57 |
tokenizer=model_tokenizer,
|
58 |
max_length=maxlength,
|
59 |
-
min_length=
|
60 |
input_text = preprocess_pdf(filepath)
|
61 |
summary_result = summarization_pipeline(input_text)
|
62 |
summarized_text = summary_result[0]['summary_text']
|
@@ -71,9 +47,6 @@ def display_pdf(file):
|
|
71 |
pdf_display = f'<object data="data:application/pdf;base64,{base64_pdf}" width="100%" height="600" type="application/pdf"></object>'
|
72 |
st.markdown(pdf_display, unsafe_allow_html=True)
|
73 |
|
74 |
-
# Streamlit code
|
75 |
-
#st.set_page_config(layout="wide")
|
76 |
-
|
77 |
def main():
|
78 |
st.title("PDF Summarization App using Language Model")
|
79 |
|
@@ -88,7 +61,6 @@ def main():
|
|
88 |
temp_file.write(uploaded_file.read())
|
89 |
with col1:
|
90 |
st.success("File Uploaded")
|
91 |
-
#pdf_view = display_pdf(filepath)
|
92 |
|
93 |
with col2:
|
94 |
summarized_result = language_model_pipeline(filepath, maxlength)
|
|
|
7 |
import base64
|
8 |
from PIL import Image
|
9 |
|
|
|
10 |
st.image("https://huggingface.co/spaces/wiwaaw/summary/resolve/main/banner.png")
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
# Model and tokenizer
|
13 |
model_checkpoint = "MBZUAI/LaMini-Flan-T5-783M"
|
14 |
model_tokenizer = T5Tokenizer.from_pretrained(model_checkpoint)
|
|
|
32 |
model=model,
|
33 |
tokenizer=model_tokenizer,
|
34 |
max_length=maxlength,
|
35 |
+
min_length=32)
|
36 |
input_text = preprocess_pdf(filepath)
|
37 |
summary_result = summarization_pipeline(input_text)
|
38 |
summarized_text = summary_result[0]['summary_text']
|
|
|
47 |
pdf_display = f'<object data="data:application/pdf;base64,{base64_pdf}" width="100%" height="600" type="application/pdf"></object>'
|
48 |
st.markdown(pdf_display, unsafe_allow_html=True)
|
49 |
|
|
|
|
|
|
|
50 |
def main():
|
51 |
st.title("PDF Summarization App using Language Model")
|
52 |
|
|
|
61 |
temp_file.write(uploaded_file.read())
|
62 |
with col1:
|
63 |
st.success("File Uploaded")
|
|
|
64 |
|
65 |
with col2:
|
66 |
summarized_result = language_model_pipeline(filepath, maxlength)
|