Spaces:
Runtime error
Runtime error
chaodreaming
commited on
Commit
•
e457e0e
1
Parent(s):
e74dd04
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,15 @@
|
|
1 |
-
import execjs
|
2 |
-
|
3 |
from PIL import Image
|
4 |
import streamlit
|
5 |
from simple_latex_ocr.models import Latex_OCR
|
6 |
-
|
7 |
-
js_code = """
|
8 |
-
function encodeToBase64(latex) {
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
}
|
13 |
-
"""
|
14 |
-
ctx = execjs.compile(js_code)
|
15 |
model = Latex_OCR()
|
16 |
if __name__ == '__main__':
|
17 |
streamlit.set_page_config(page_title='Simple-LaTeX-OCR')
|
@@ -36,11 +34,11 @@ if __name__ == '__main__':
|
|
36 |
response = model.predict(uploaded_file.getvalue())
|
37 |
if "formula" in response:
|
38 |
latex_code = response["formula"]
|
39 |
-
latex_encode = ctx.call("encodeToBase64", latex_code)
|
40 |
streamlit.code(latex_code, language='latex')
|
41 |
streamlit.markdown(f'$\\displaystyle {latex_code}$')
|
42 |
-
link_html = f'<a href="https://www.latexlive.com/#{latex_encode}" target="_blank"><button style="color: black;">Online Editing</button></a>'
|
43 |
-
streamlit.markdown(link_html, unsafe_allow_html=True)
|
44 |
else:
|
45 |
streamlit.error(response)
|
46 |
else:
|
|
|
|
|
|
|
1 |
from PIL import Image
|
2 |
import streamlit
|
3 |
from simple_latex_ocr.models import Latex_OCR
|
4 |
+
# import execjs
|
5 |
+
# js_code = """
|
6 |
+
# function encodeToBase64(latex) {
|
7 |
+
# var str = encodeURI(latex); // URL
|
8 |
+
# str = btoa(str); // Base64
|
9 |
+
# return str;
|
10 |
+
# }
|
11 |
+
# """
|
12 |
+
# ctx = execjs.compile(js_code)
|
13 |
model = Latex_OCR()
|
14 |
if __name__ == '__main__':
|
15 |
streamlit.set_page_config(page_title='Simple-LaTeX-OCR')
|
|
|
34 |
response = model.predict(uploaded_file.getvalue())
|
35 |
if "formula" in response:
|
36 |
latex_code = response["formula"]
|
37 |
+
# latex_encode = ctx.call("encodeToBase64", latex_code)
|
38 |
streamlit.code(latex_code, language='latex')
|
39 |
streamlit.markdown(f'$\\displaystyle {latex_code}$')
|
40 |
+
# link_html = f'<a href="https://www.latexlive.com/#{latex_encode}" target="_blank"><button style="color: black;">Online Editing</button></a>'
|
41 |
+
# streamlit.markdown(link_html, unsafe_allow_html=True)
|
42 |
else:
|
43 |
streamlit.error(response)
|
44 |
else:
|