Update app.py
Browse files
app.py
CHANGED
|
@@ -16,7 +16,7 @@ os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
|
| 16 |
#os.system('pip install -q pytesseract')
|
| 17 |
#os.system('conda install -c conda-forge poppler')
|
| 18 |
import streamlit as st
|
| 19 |
-
|
| 20 |
st.title("Bangla and English Summarizer: Upload Images/Pdf or input texts to summarize!")
|
| 21 |
import torch
|
| 22 |
import docx2txt
|
|
@@ -40,7 +40,7 @@ API_URL1 = "https://api-inference.huggingface.co/models/Michael-Vptn/text-summar
|
|
| 40 |
headers1 = {"Authorization": "Bearer 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"}
|
| 41 |
API_URL2 = "https://api-inference.huggingface.co/models/gpt2"
|
| 42 |
headers2 = {"Authorization": "Bearer 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"}
|
| 43 |
-
|
| 44 |
def read_pdf(file):
|
| 45 |
# images=pdf2image.convert_from_path(file)
|
| 46 |
# # print(type(images))
|
|
@@ -85,7 +85,7 @@ def bansum(text):
|
|
| 85 |
|
| 86 |
if "photo" not in st.session_state:
|
| 87 |
st.session_state["photo"]="not done"
|
| 88 |
-
c2, c3 = st.columns([2
|
| 89 |
def change_photo_state():
|
| 90 |
st.session_state["photo"]="done"
|
| 91 |
message = st.text_input("Type your text here!")
|
|
@@ -119,11 +119,12 @@ if st.session_state["photo"]=="done" or message:
|
|
| 119 |
img = img.save("img.png")
|
| 120 |
img = cv2.imread("img.png")
|
| 121 |
st.text("Select the summarization type:")
|
| 122 |
-
|
|
|
|
| 123 |
text = pytesseract.image_to_string(img, lang="ben")
|
| 124 |
st.subheader("সারাংশ/সারমর্ম")
|
| 125 |
bansum(text)
|
| 126 |
-
if
|
| 127 |
text=pytesseract.image_to_string(img)
|
| 128 |
st.subheader("Summarized Text")
|
| 129 |
engsum(text)
|
|
@@ -135,20 +136,22 @@ if st.session_state["photo"]=="done" or message:
|
|
| 135 |
img = cv2.imread("img.png")
|
| 136 |
#text = pytesseract.image_to_string(img) if st.checkbox("Bangla") else pytesseract.image_to_string(img, lang="ben")
|
| 137 |
st.text("Select the summarization type:")
|
| 138 |
-
|
|
|
|
| 139 |
text = pytesseract.image_to_string(img, lang="ben")
|
| 140 |
st.subheader("সারাংশ/সারমর্ম")
|
| 141 |
bansum(text)
|
| 142 |
-
if
|
| 143 |
text=pytesseract.image_to_string(img)
|
| 144 |
st.subheader("Summarized Text")
|
| 145 |
engsum(text)
|
| 146 |
else:
|
| 147 |
text=None
|
| 148 |
text = message
|
| 149 |
-
|
|
|
|
| 150 |
bansum(text)
|
| 151 |
-
if
|
| 152 |
engsum(text)
|
| 153 |
# if st.button("English Text Generation"):
|
| 154 |
# def query(payload):
|
|
|
|
| 16 |
#os.system('pip install -q pytesseract')
|
| 17 |
#os.system('conda install -c conda-forge poppler')
|
| 18 |
import streamlit as st
|
| 19 |
+
st.set_page_config(page_title="Summarization Tool", layout="wide", initial_sidebar_state="expanded")
|
| 20 |
st.title("Bangla and English Summarizer: Upload Images/Pdf or input texts to summarize!")
|
| 21 |
import torch
|
| 22 |
import docx2txt
|
|
|
|
| 40 |
headers1 = {"Authorization": "Bearer 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"}
|
| 41 |
API_URL2 = "https://api-inference.huggingface.co/models/gpt2"
|
| 42 |
headers2 = {"Authorization": "Bearer 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"}
|
| 43 |
+
@st.cache
|
| 44 |
def read_pdf(file):
|
| 45 |
# images=pdf2image.convert_from_path(file)
|
| 46 |
# # print(type(images))
|
|
|
|
| 85 |
|
| 86 |
if "photo" not in st.session_state:
|
| 87 |
st.session_state["photo"]="not done"
|
| 88 |
+
c2, c3 = st.columns([2,1])
|
| 89 |
def change_photo_state():
|
| 90 |
st.session_state["photo"]="done"
|
| 91 |
message = st.text_input("Type your text here!")
|
|
|
|
| 119 |
img = img.save("img.png")
|
| 120 |
img = cv2.imread("img.png")
|
| 121 |
st.text("Select the summarization type:")
|
| 122 |
+
c4, c5 = st.columns([1,1])
|
| 123 |
+
if c4.button("BENGALI"):
|
| 124 |
text = pytesseract.image_to_string(img, lang="ben")
|
| 125 |
st.subheader("সারাংশ/সারমর্ম")
|
| 126 |
bansum(text)
|
| 127 |
+
if c5.button("ENGLISH"):
|
| 128 |
text=pytesseract.image_to_string(img)
|
| 129 |
st.subheader("Summarized Text")
|
| 130 |
engsum(text)
|
|
|
|
| 136 |
img = cv2.imread("img.png")
|
| 137 |
#text = pytesseract.image_to_string(img) if st.checkbox("Bangla") else pytesseract.image_to_string(img, lang="ben")
|
| 138 |
st.text("Select the summarization type:")
|
| 139 |
+
c6, c7 = st.columns([1,1])
|
| 140 |
+
if c6.button("Bangla"):
|
| 141 |
text = pytesseract.image_to_string(img, lang="ben")
|
| 142 |
st.subheader("সারাংশ/সারমর্ম")
|
| 143 |
bansum(text)
|
| 144 |
+
if c7.button("English"):
|
| 145 |
text=pytesseract.image_to_string(img)
|
| 146 |
st.subheader("Summarized Text")
|
| 147 |
engsum(text)
|
| 148 |
else:
|
| 149 |
text=None
|
| 150 |
text = message
|
| 151 |
+
c8, c9 = st.columns([1,1])
|
| 152 |
+
if c8.button("Bangla"):
|
| 153 |
bansum(text)
|
| 154 |
+
if c9.button("English"):
|
| 155 |
engsum(text)
|
| 156 |
# if st.button("English Text Generation"):
|
| 157 |
# def query(payload):
|