betterme
commited on
Commit
•
9317d88
1
Parent(s):
c71819a
update
Browse files- _👋_.py +1 -1
- pages/1_🔥_模型生成代码.py +0 -56
- pages/2_📚_PDF预览.py +0 -53
_👋_.py
CHANGED
@@ -4,6 +4,6 @@ st.set_page_config(
|
|
4 |
page_title='Streamlit组件清单',
|
5 |
page_icon="📖",
|
6 |
layout="wide",
|
7 |
-
|
8 |
)
|
9 |
st.text_input('业务搜索', '知识图谱')
|
|
|
4 |
page_title='Streamlit组件清单',
|
5 |
page_icon="📖",
|
6 |
layout="wide",
|
7 |
+
initial_sidebar_state="collapsed",
|
8 |
)
|
9 |
st.text_input('业务搜索', '知识图谱')
|
pages/1_🔥_模型生成代码.py
DELETED
@@ -1,56 +0,0 @@
|
|
1 |
-
from meutils.pipe import *
|
2 |
-
from appzoo.streamlit_app import Page
|
3 |
-
|
4 |
-
import streamlit as st
|
5 |
-
|
6 |
-
import m2cgen as m2c
|
7 |
-
|
8 |
-
|
9 |
-
class MyPage(Page):
|
10 |
-
|
11 |
-
def main(self):
|
12 |
-
with st.form("Coding"):
|
13 |
-
file = st.file_uploader('上传默模型文件')
|
14 |
-
if file:
|
15 |
-
estimator = joblib.load(file)
|
16 |
-
else:
|
17 |
-
estimator = joblib.load(get_resolve_path('../data/lr.pkl', __file__))
|
18 |
-
|
19 |
-
languages = [
|
20 |
-
'python',
|
21 |
-
'java',
|
22 |
-
'go',
|
23 |
-
'c',
|
24 |
-
'c_sharp',
|
25 |
-
'r',
|
26 |
-
'dart',
|
27 |
-
'elixir',
|
28 |
-
'f_sharp',
|
29 |
-
'haskell',
|
30 |
-
'javascript',
|
31 |
-
'php',
|
32 |
-
'powershell',
|
33 |
-
'ruby',
|
34 |
-
'rust',
|
35 |
-
'visual_basic'
|
36 |
-
]
|
37 |
-
|
38 |
-
_ = st.selectbox('选择输出语言', languages)
|
39 |
-
|
40 |
-
if st.form_submit_button('开始转换'):
|
41 |
-
code = m2c.__getattribute__(f'export_to_{_}')(estimator)
|
42 |
-
|
43 |
-
st.markdown("##### code:")
|
44 |
-
st.code(code)
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
if __name__ == '__main__':
|
49 |
-
app_title = "ModelToCode"
|
50 |
-
app_info = """
|
51 |
-
将训练过的统计模型转化为本地代码(`Python, C, Java, Go, JavaScript, Visual Basic, c#, PowerShell, R, PHP, Dart, Haskell, Ruby, f#, Rust, Elixir`)。
|
52 |
-
"""
|
53 |
-
MyPage(
|
54 |
-
app_title=f"# {app_title}",
|
55 |
-
app_info=f"> {app_info}",
|
56 |
-
).main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/2_📚_PDF预览.py
DELETED
@@ -1,53 +0,0 @@
|
|
1 |
-
from meutils.pipe import *
|
2 |
-
from appzoo.streamlit_app import Page
|
3 |
-
|
4 |
-
import streamlit as st
|
5 |
-
import streamlit.components.v1 as components
|
6 |
-
|
7 |
-
class MyPage(Page):
|
8 |
-
"""
|
9 |
-
https://zhuanlan.zhihu.com/p/518115802?utm_medium=social&utm_oi=1290068536690085888
|
10 |
-
"""
|
11 |
-
|
12 |
-
def main(self):
|
13 |
-
|
14 |
-
|
15 |
-
with st.form("PDF"):
|
16 |
-
file = st.file_uploader("选择待上传的PDF文件", type=['pdf', 'docx', 'xlsx'])
|
17 |
-
|
18 |
-
if st.form_submit_button('开始预览', help='先上传文件!!!'):
|
19 |
-
if file is not None:
|
20 |
-
base64_pdf = base64.b64encode(file.read()).decode('utf-8')
|
21 |
-
|
22 |
-
self.display_pdf(base64_pdf, width='100%', height=1000)
|
23 |
-
self.display_html()
|
24 |
-
|
25 |
-
def display_pdf(self, base64_pdf, width='100%', height=1000):
|
26 |
-
# https://blog.51cto.com/laok8/2395498
|
27 |
-
pdf_display = f"""<embed src="data:application/pdf;base64,{base64_pdf}" width="{width}" height="{height}" type="application/pdf">"""
|
28 |
-
# data_type = 'vnd.openxmlformats-officedocument.wordprocessingml.document'
|
29 |
-
# pdf_display = f"""<embed src="data:application/{data_type};base64,{base64_pdf}" width="{width}" height="{height}" type="application/{data_type}">"""
|
30 |
-
|
31 |
-
st.markdown(pdf_display, unsafe_allow_html=True)
|
32 |
-
|
33 |
-
def display_html(self, text='会飞的文字'):
|
34 |
-
_ = f"""
|
35 |
-
<marquee direction="down" width="100%" height="100%" behavior="alternate" style="border:solid" bgcolor="#00FF00">
|
36 |
-
|
37 |
-
<marquee behavior="alternate">
|
38 |
-
|
39 |
-
{text}
|
40 |
-
|
41 |
-
</marquee>
|
42 |
-
|
43 |
-
</marquee>
|
44 |
-
"""
|
45 |
-
st.markdown(_, unsafe_allow_html=True)
|
46 |
-
|
47 |
-
if __name__ == '__main__':
|
48 |
-
app_title = "# PDF应用"
|
49 |
-
app_info = "PDF预览"
|
50 |
-
MyPage(
|
51 |
-
app_title=app_title,
|
52 |
-
app_info=app_info,
|
53 |
-
).main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|