Update app.py
Browse files
app.py
CHANGED
|
@@ -35,12 +35,15 @@ import altair as alt
|
|
| 35 |
from transformers import AutoTokenizer, AutoModelWithLMHead
|
| 36 |
#pytesseract.pytesseract.tesseract_cmd = r"./Tesseract-OCR/tesseract.exe"
|
| 37 |
from PIL import Image
|
|
|
|
| 38 |
API_URL0 = "https://api-inference.huggingface.co/models/csebuetnlp/mT5_multilingual_XLSum"
|
| 39 |
-
headers0 = {"Authorization": "Bearer
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
| 44 |
@st.cache
|
| 45 |
def read_pdf(file):
|
| 46 |
# images=pdf2image.convert_from_path(file)
|
|
@@ -94,15 +97,15 @@ def main():
|
|
| 94 |
def change_photo_state():
|
| 95 |
st.session_state["photo"]="done"
|
| 96 |
with st.container():
|
| 97 |
-
c1, c2, c3 = st.columns([2,2
|
| 98 |
message = c1.text_input("Type your text here!")
|
| 99 |
Capture=True
|
| 100 |
-
if
|
| 101 |
-
camera_photo =
|
| 102 |
-
if
|
| 103 |
Capture =False
|
| 104 |
|
| 105 |
-
uploaded_photo =
|
| 106 |
if st.session_state["photo"]=="done" or message:
|
| 107 |
if uploaded_photo and uploaded_photo.type=='application/pdf':
|
| 108 |
tet = read_pdf(uploaded_photo)
|
|
|
|
| 35 |
from transformers import AutoTokenizer, AutoModelWithLMHead
|
| 36 |
#pytesseract.pytesseract.tesseract_cmd = r"./Tesseract-OCR/tesseract.exe"
|
| 37 |
from PIL import Image
|
| 38 |
+
|
| 39 |
API_URL0 = "https://api-inference.huggingface.co/models/csebuetnlp/mT5_multilingual_XLSum"
|
| 40 |
+
headers0 = {"Authorization": "Bearer "+str(os.environ["t5multilingual"])}
|
| 41 |
+
|
| 42 |
+
# API_URL1 = "https://api-inference.huggingface.co/models/Michael-Vptn/text-summarization-t5-base"
|
| 43 |
+
# headers1 = {"Authorization": "Bearer "+str(os.environ["t5modeleng"])}
|
| 44 |
+
|
| 45 |
+
# API_URL2 = "https://api-inference.huggingface.co/models/gpt2"
|
| 46 |
+
# headers2 = {"Authorization": "Bearer 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"}
|
| 47 |
@st.cache
|
| 48 |
def read_pdf(file):
|
| 49 |
# images=pdf2image.convert_from_path(file)
|
|
|
|
| 97 |
def change_photo_state():
|
| 98 |
st.session_state["photo"]="done"
|
| 99 |
with st.container():
|
| 100 |
+
c1, c2, c3 = st.columns([2,1,2])
|
| 101 |
message = c1.text_input("Type your text here!")
|
| 102 |
Capture=True
|
| 103 |
+
if c3.button("Start Camera"):
|
| 104 |
+
camera_photo = c3.camera_input("Capture a photo to summarize: ", on_change=change_photo_state)
|
| 105 |
+
if c3.button("Stop Camera"):
|
| 106 |
Capture =False
|
| 107 |
|
| 108 |
+
uploaded_photo = c2.file_uploader("Upload your Images/PDF",type=['jpg','png','jpeg','pdf'], on_change=change_photo_state)
|
| 109 |
if st.session_state["photo"]=="done" or message:
|
| 110 |
if uploaded_photo and uploaded_photo.type=='application/pdf':
|
| 111 |
tet = read_pdf(uploaded_photo)
|