Update app.py
Browse files
app.py
CHANGED
@@ -35,7 +35,10 @@ import altair as alt
|
|
35 |
from PIL import Image
|
36 |
API_URL0 = "https://api-inference.huggingface.co/models/csebuetnlp/mT5_multilingual_XLSum"
|
37 |
headers0 = {"Authorization": "Bearer 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"}
|
38 |
-
|
|
|
|
|
|
|
39 |
|
40 |
def read_pdf(file):
|
41 |
# images=pdf2image.convert_from_path(file)
|
@@ -64,9 +67,6 @@ def read_pdf(file):
|
|
64 |
# #st.text(extracted_text)
|
65 |
# return extracted_text
|
66 |
def engsum(output):
|
67 |
-
API_URL1 = "https://api-inference.huggingface.co/models/Michael-Vptn/text-summarization-t5-base"
|
68 |
-
headers1 = {"Authorization": "Bearer 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"}
|
69 |
-
|
70 |
def query(payload):
|
71 |
response = requests.post(API_URL1, headers=headers1, json=payload)
|
72 |
return response.json()
|
@@ -155,21 +155,19 @@ def main():
|
|
155 |
text = message
|
156 |
|
157 |
if st.checkbox("English Text Generation"):
|
158 |
-
API_URL2 = "https://api-inference.huggingface.co/models/gpt2"
|
159 |
-
headers2 = {"Authorization": "Bearer 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"}
|
160 |
|
161 |
def query(payload):
|
162 |
response = requests.post(API_URL2, headers=headers2, json=payload)
|
163 |
return response.json()
|
164 |
|
165 |
-
|
166 |
"inputs": text,
|
167 |
})
|
168 |
-
if isinstance(
|
169 |
-
text_output =
|
170 |
st.success(text_output)
|
171 |
if st.checkbox("Summarize generated text"):
|
172 |
-
engsum(
|
173 |
|
174 |
if st.checkbox("Mark for Text Summarization"):
|
175 |
if b==1:
|
|
|
35 |
from PIL import Image
|
36 |
API_URL0 = "https://api-inference.huggingface.co/models/csebuetnlp/mT5_multilingual_XLSum"
|
37 |
headers0 = {"Authorization": "Bearer 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"}
|
38 |
+
API_URL1 = "https://api-inference.huggingface.co/models/Michael-Vptn/text-summarization-t5-base"
|
39 |
+
headers1 = {"Authorization": "Bearer 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"}
|
40 |
+
API_URL2 = "https://api-inference.huggingface.co/models/gpt2"
|
41 |
+
headers2 = {"Authorization": "Bearer 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"}
|
42 |
|
43 |
def read_pdf(file):
|
44 |
# images=pdf2image.convert_from_path(file)
|
|
|
67 |
# #st.text(extracted_text)
|
68 |
# return extracted_text
|
69 |
def engsum(output):
|
|
|
|
|
|
|
70 |
def query(payload):
|
71 |
response = requests.post(API_URL1, headers=headers1, json=payload)
|
72 |
return response.json()
|
|
|
155 |
text = message
|
156 |
|
157 |
if st.checkbox("English Text Generation"):
|
|
|
|
|
158 |
|
159 |
def query(payload):
|
160 |
response = requests.post(API_URL2, headers=headers2, json=payload)
|
161 |
return response.json()
|
162 |
|
163 |
+
out = query({
|
164 |
"inputs": text,
|
165 |
})
|
166 |
+
if isinstance(out, list) and out[0].get("generated_text"):
|
167 |
+
text_output = out[0]["generated_text"]
|
168 |
st.success(text_output)
|
169 |
if st.checkbox("Summarize generated text"):
|
170 |
+
engsum(text_output)
|
171 |
|
172 |
if st.checkbox("Mark for Text Summarization"):
|
173 |
if b==1:
|