betterme
commited on
Commit
•
dcf1188
1
Parent(s):
b966bc9
update
Browse files- pages/0_留言板.py +0 -18
- pages/1000_文本标识.py +0 -38
- pages/1001_多选组件.py +0 -51
- pages/1002_pandas_profiling.py +0 -21
- pages/1003_streamlit_authenticator.py +0 -92
- pages/1004_streamlit_option_menu.py +0 -33
- pages/111_📚_PDF简单表格提取.py +0 -38
- pages/112_📚_简单的配置界面.py +0 -27
- pages/113_💰_穿透.py +0 -27
- pages/3_🐧_分词.py +0 -47
- pages/4_🤩_Apps.py +0 -23
- pages/5_👍_Postman.py +0 -28
- pages/6666_🐧_hr.py +0 -50
- pages/666_😝_TEST.py +0 -69
- pages/66_🔥_ASCII字符画.py +0 -107
- pages/6_🕷_coding.py +0 -20
- pages/7_登录.py +0 -64
- pages/888_🌰_demo.py +0 -29
- pages/889_机器监控.py +0 -118
- pages/8_内容审核.py +0 -74
- pages/990_streamlit_autorefresh.py +0 -19
- pages/991_streamlit_apex_charts.py +0 -19
- pages/992_streamlit_chat.py +0 -25
- pages/993_streamlit_text_rating.py +0 -11
- pages/994_自定义style.py +0 -39
- pages/995_streamlit_echarts.py +0 -25
- pages/996_streamlit_pyecharts.py +0 -73
- pages/997_streamlit_aggrid.py +0 -24
- pages/998_streamlit_agraph.py +0 -49
- pages/998_知识图谱.py +0 -39
- pages/999_draw_table.py +0 -129
- pages/__init__.py +0 -11
- pages/chart.py +0 -20
- pages/demo-aggrid-width-center.py +0 -64
- pages/iframe.py +0 -36
- pages/xxxx.py +0 -9
- pages/多轮对话.py +2 -25
- requirements.txt +3 -0
pages/0_留言板.py
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
from meutils.pipe import *
|
2 |
-
from appzoo.streamlit_app import Page
|
3 |
-
|
4 |
-
import streamlit as st
|
5 |
-
from streamlit.components.v1 import html, iframe
|
6 |
-
|
7 |
-
|
8 |
-
class MyPage(Page):
|
9 |
-
|
10 |
-
def main(self):
|
11 |
-
text = ""
|
12 |
-
with open("./data/x.html") as fp: # 如果遇到decode错误,就加上合适的encoding
|
13 |
-
text = fp.read()
|
14 |
-
html(text)
|
15 |
-
|
16 |
-
|
17 |
-
if __name__ == '__main__':
|
18 |
-
MyPage().main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/1000_文本标识.py
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : Python.
|
4 |
-
# @File : 8000_文本标识
|
5 |
-
# @Time : 2022/10/17 下午1:39
|
6 |
-
# @Author : yuanjie
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description :
|
10 |
-
|
11 |
-
|
12 |
-
import streamlit as st
|
13 |
-
from annotated_text import annotated_text, annotation
|
14 |
-
|
15 |
-
annotated_text(
|
16 |
-
"我 ",
|
17 |
-
("热爱", "", "#8ef"),
|
18 |
-
" 我们 ",
|
19 |
-
("非常棒", "", "#faa"),
|
20 |
-
("而", "", "#afa"),
|
21 |
-
" 有用的 ",
|
22 |
-
("Streamlit", "", "#fea"),
|
23 |
-
("社区", "", "#8ef"),
|
24 |
-
("!", "", "#afa"),
|
25 |
-
)
|
26 |
-
|
27 |
-
annotated_text(
|
28 |
-
"I ",
|
29 |
-
("Love", "", "#8ef"),
|
30 |
-
" our ",
|
31 |
-
("Great", "", "#faa"),
|
32 |
-
("and", "", "#afa"),
|
33 |
-
" Useful ",
|
34 |
-
("Streamlit", "", "#fea"),
|
35 |
-
("Community", "", "#8ef"),
|
36 |
-
("!", "", "#afa"),
|
37 |
-
)
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/1001_多选组件.py
DELETED
@@ -1,51 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : Python.
|
4 |
-
# @File : 1001_多选组件
|
5 |
-
# @Time : 2022/10/17 下午1:41
|
6 |
-
# @Author : yuanjie
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description :
|
10 |
-
|
11 |
-
import streamlit as st
|
12 |
-
from streamlit_tree_select import tree_select
|
13 |
-
nodes = [
|
14 |
-
{"label": "北京", "value": "北京"},
|
15 |
-
{
|
16 |
-
"label": "上海",
|
17 |
-
"value": "上海",
|
18 |
-
"children": [
|
19 |
-
{"label": "浦东", "value": "浦东"},
|
20 |
-
{"label": "杨浦", "value": "杨浦"},
|
21 |
-
{"label": "虹口", "value": "虹口"},
|
22 |
-
{"label": "黄浦", "value": "黄浦"},
|
23 |
-
],
|
24 |
-
},
|
25 |
-
{
|
26 |
-
"label": "广州",
|
27 |
-
"value": "广州",
|
28 |
-
"children": [
|
29 |
-
{"label": "番禺区", "value": "番禺区"},
|
30 |
-
{
|
31 |
-
"label": "白云区",
|
32 |
-
"value": "白云区",
|
33 |
-
"children": [
|
34 |
-
{"label": "三元里街", "value": "三元里街"},
|
35 |
-
{"label": "松洲街", "value": "松洲街"},
|
36 |
-
],
|
37 |
-
},
|
38 |
-
{"label": "珠江新区", "value": "珠江新区"},
|
39 |
-
],
|
40 |
-
},
|
41 |
-
]
|
42 |
-
|
43 |
-
c1, c2 = st.columns(2)
|
44 |
-
|
45 |
-
with c1:
|
46 |
-
|
47 |
-
return_select = tree_select(nodes)
|
48 |
-
|
49 |
-
with c2:
|
50 |
-
st.write(return_select["checked"])
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/1002_pandas_profiling.py
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : Python.
|
4 |
-
# @File : 1002_profile
|
5 |
-
# @Time : 2022/10/17 下午2:34
|
6 |
-
# @Author : yuanjie
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description :
|
10 |
-
|
11 |
-
|
12 |
-
import pandas as pd
|
13 |
-
import pandas_profiling
|
14 |
-
import streamlit as st
|
15 |
-
|
16 |
-
from streamlit_pandas_profiling import st_profile_report
|
17 |
-
|
18 |
-
df = pd.read_csv("./data/train.csv")
|
19 |
-
pr = df.profile_report()
|
20 |
-
|
21 |
-
st_profile_report(pr)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/1003_streamlit_authenticator.py
DELETED
@@ -1,92 +0,0 @@
|
|
1 |
-
from meutils.pipe import *
|
2 |
-
|
3 |
-
import streamlit as st
|
4 |
-
import streamlit_authenticator as stauth
|
5 |
-
from streamlit_authenticator import Authenticate
|
6 |
-
|
7 |
-
from streamlit_option_menu import option_menu
|
8 |
-
|
9 |
-
# https://github.com/mkhorasani/Streamlit-Authenticator
|
10 |
-
|
11 |
-
st.set_page_config(page_title="Platform tester", page_icon=":rainbow:", layout="centered", initial_sidebar_state="auto")
|
12 |
-
# 如下代码数据,可以来自数据库
|
13 |
-
hashed_passwords = stauth.Hasher(['123', '456']).generate()
|
14 |
-
print(hashed_passwords)
|
15 |
-
|
16 |
-
_ = f"""
|
17 |
-
credentials:
|
18 |
-
usernames:
|
19 |
-
nesc:
|
20 |
-
email: [email protected]
|
21 |
-
name: nesc
|
22 |
-
password: {hashed_passwords[0]} # To be replaced with hashed password
|
23 |
-
|
24 |
-
jsmith:
|
25 |
-
email: [email protected]
|
26 |
-
name: John Smith
|
27 |
-
password: 123 # To be replaced with hashed password
|
28 |
-
|
29 |
-
rbriggs:
|
30 |
-
email: [email protected]
|
31 |
-
name: Rebecca Briggs
|
32 |
-
password: 456 # To be replaced with hashed password
|
33 |
-
|
34 |
-
x:
|
35 |
-
email: [email protected]
|
36 |
-
name: x
|
37 |
-
password: xxx # To be replaced with hashed password
|
38 |
-
cookie:
|
39 |
-
expiry_days: 30
|
40 |
-
key: some_signature_key
|
41 |
-
name: some_cookie_name
|
42 |
-
preauthorized:
|
43 |
-
emails:
|
44 | |
45 |
-
"""
|
46 |
-
|
47 |
-
config = yaml.load(_)
|
48 |
-
|
49 |
-
authenticator = Authenticate(
|
50 |
-
config['credentials'],
|
51 |
-
config['cookie']['name'],
|
52 |
-
config['cookie']['key'],
|
53 |
-
config['cookie']['expiry_days'],
|
54 |
-
config['preauthorized']
|
55 |
-
)
|
56 |
-
|
57 |
-
name, authentication_status, username = authenticator.login('Login', 'main')
|
58 |
-
|
59 |
-
if authentication_status:
|
60 |
-
authenticator.logout('Logout', 'main')
|
61 |
-
st.write(f'Welcome *{name}*')
|
62 |
-
st.title('Some content')
|
63 |
-
elif authentication_status == False:
|
64 |
-
st.error('Username/password is incorrect')
|
65 |
-
elif authentication_status == None:
|
66 |
-
st.warning('Please enter your username and password')
|
67 |
-
|
68 |
-
|
69 |
-
if authentication_status:
|
70 |
-
try:
|
71 |
-
if authenticator.reset_password(username, 'Reset password'):
|
72 |
-
st.success('Password modified successfully')
|
73 |
-
except Exception as e:
|
74 |
-
st.error(e)
|
75 |
-
|
76 |
-
|
77 |
-
try:
|
78 |
-
if authenticator.register_user('Register user', preauthorization=False):
|
79 |
-
st.success('User registered successfully')
|
80 |
-
except Exception as e:
|
81 |
-
st.error(e)
|
82 |
-
|
83 |
-
|
84 |
-
try:
|
85 |
-
username_forgot_pw, email_forgot_password, random_password = authenticator.forgot_password('Forgot password')
|
86 |
-
if username_forgot_pw:
|
87 |
-
st.success('New password sent securely')
|
88 |
-
# Random password to be transferred to user securely
|
89 |
-
elif username_forgot_pw == False:
|
90 |
-
st.error('Username not found')
|
91 |
-
except Exception as e:
|
92 |
-
st.error(e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/1004_streamlit_option_menu.py
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
from meutils.pipe import *
|
2 |
-
|
3 |
-
import streamlit as st
|
4 |
-
from streamlit_option_menu import option_menu
|
5 |
-
|
6 |
-
st.set_page_config(page_title="Option Menu", layout="wide")
|
7 |
-
with st.sidebar:
|
8 |
-
selected = option_menu("Main Menu", ["Home", "Upload", "---", "Tasks", 'Settings'],
|
9 |
-
icons=['house', 'cloud-upload', None, "list-task", 'gear'], menu_icon="cast",
|
10 |
-
default_index=1)
|
11 |
-
|
12 |
-
selected2 = option_menu(None, ["Home", "Upload", "---", "Tasks", 'Settings'],
|
13 |
-
icons=['house', 'cloud-upload', None, "list-task", 'gear'],
|
14 |
-
menu_icon="cast", default_index=0, orientation="horizontal")
|
15 |
-
|
16 |
-
selected3 = option_menu(None, ["Home", "Upload", "Tasks", 'Settings'],
|
17 |
-
icons=['house', 'cloud-upload', "list-task", 'gear'],
|
18 |
-
menu_icon="cast", default_index=0, orientation="horizontal",
|
19 |
-
styles={
|
20 |
-
"container": {"padding": "0!important", "background-color": "#fafafa"},
|
21 |
-
"icon": {"color": "orange", "font-size": "25px"},
|
22 |
-
"nav-link": {"font-size": "25px", "text-align": "left", "margin": "0px",
|
23 |
-
"--hover-color": "#eee"},
|
24 |
-
"nav-link-selected": {"background-color": "green"},
|
25 |
-
}
|
26 |
-
)
|
27 |
-
|
28 |
-
# choice = option_menu(
|
29 |
-
# "Menu", ["首页", "HIVE", "KUDU", "MYSQL"],
|
30 |
-
# icons=['house', 'chat-square', 'chat-square-dots', 'chat-square-text'], menu_icon="hammer",
|
31 |
-
# default_index=0)
|
32 |
-
|
33 |
-
# df.style.set_precision
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/111_📚_PDF简单表格提取.py
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : Python.
|
4 |
-
# @File : 111_📚_PDF简单表格提取
|
5 |
-
# @Time : 2022/11/3 下午6:09
|
6 |
-
# @Author : yuanjie
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description :
|
10 |
-
|
11 |
-
|
12 |
-
from appzoo.streamlit_app import Page
|
13 |
-
import streamlit as st
|
14 |
-
from st_aggrid import AgGrid
|
15 |
-
|
16 |
-
import camelot
|
17 |
-
|
18 |
-
|
19 |
-
class MyPage(Page):
|
20 |
-
|
21 |
-
def main(self):
|
22 |
-
with st.form("Coding"):
|
23 |
-
file = st.file_uploader("选择待上传的PDF文件", type=['pdf', 'docx', 'xlsx'])
|
24 |
-
if file:
|
25 |
-
open(file.name, 'wb').write(file.read())
|
26 |
-
|
27 |
-
if st.form_submit_button('开始转换'):
|
28 |
-
tables = camelot.read_pdf(file.name)
|
29 |
-
df = tables[0].df
|
30 |
-
print(df)
|
31 |
-
|
32 |
-
st.dataframe(df)
|
33 |
-
|
34 |
-
|
35 |
-
if __name__ == '__main__':
|
36 |
-
app_title = "# 切词"
|
37 |
-
app_info = ""
|
38 |
-
MyPage(app_title=app_title, app_info=app_info, layout='wide').main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/112_📚_简单的配置界面.py
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : Python.
|
4 |
-
# @File : 111_📚_PDF简单表格提取
|
5 |
-
# @Time : 2022/11/3 下午6:09
|
6 |
-
# @Author : yuanjie
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description :
|
10 |
-
|
11 |
-
|
12 |
-
from appzoo.streamlit_app import Page
|
13 |
-
import streamlit as st
|
14 |
-
from meutils.pipe import *
|
15 |
-
from meutils.path_utils import file2json
|
16 |
-
|
17 |
-
|
18 |
-
class MyPage(Page):
|
19 |
-
|
20 |
-
def main(self):
|
21 |
-
cfg = file2json(get_resolve_path('../data/config.yml', __file__) )
|
22 |
-
st.json(cfg)
|
23 |
-
|
24 |
-
|
25 |
-
if __name__ == '__main__':
|
26 |
-
app_title = "# 配置"
|
27 |
-
MyPage(app_title=app_title, layout='wide').main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/113_💰_穿透.py
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : Python.
|
4 |
-
# @File : 111_📚_PDF简单表格提取
|
5 |
-
# @Time : 2022/11/3 下午6:09
|
6 |
-
# @Author : yuanjie
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description :
|
10 |
-
|
11 |
-
|
12 |
-
from appzoo.streamlit_app import Page
|
13 |
-
import streamlit as st
|
14 |
-
from meutils.pipe import *
|
15 |
-
from meutils.path_utils import file2json
|
16 |
-
|
17 |
-
|
18 |
-
class MyPage(Page):
|
19 |
-
|
20 |
-
def main(self):
|
21 |
-
cfg = file2json(get_resolve_path('../data/config.yml', __file__) )
|
22 |
-
st.json(cfg)
|
23 |
-
|
24 |
-
|
25 |
-
if __name__ == '__main__':
|
26 |
-
app_title = "# 配置"
|
27 |
-
MyPage(app_title=app_title, layout='wide').main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/3_🐧_分词.py
DELETED
@@ -1,47 +0,0 @@
|
|
1 |
-
from meutils.pipe import *
|
2 |
-
|
3 |
-
from appzoo.streamlit_app import Page
|
4 |
-
|
5 |
-
import streamlit as st
|
6 |
-
|
7 |
-
from LAC import LAC as _LAC
|
8 |
-
|
9 |
-
LAC = st.experimental_singleton(_LAC)
|
10 |
-
|
11 |
-
|
12 |
-
# @st.cache(func=None, persist=False, hash_funcs={'LAC.lac.LAC': str})
|
13 |
-
# def tokenizer():
|
14 |
-
# print('Loading tokenizer1...')
|
15 |
-
# return LAC()
|
16 |
-
|
17 |
-
@ttl_cache(key=str)
|
18 |
-
@disk_cache()
|
19 |
-
def tokenizer(texts):
|
20 |
-
return LAC().run(texts) | xmap_(lambda r: list(zip(*r)))
|
21 |
-
|
22 |
-
|
23 |
-
class MyPage(Page):
|
24 |
-
|
25 |
-
def main(self):
|
26 |
-
with st.form("Coding"):
|
27 |
-
|
28 |
-
texts = st.text_area("输入文本", ["为什么东北证券那么牛?"]*3 | xjoin('\n')).split("\n")
|
29 |
-
|
30 |
-
if st.form_submit_button('开始转换'):
|
31 |
-
_ = tokenizer(texts)
|
32 |
-
|
33 |
-
# st.json(_)
|
34 |
-
# st.text(_)
|
35 |
-
# st.dataframe(pd.DataFrame(_))
|
36 |
-
|
37 |
-
|
38 |
-
from annotated_text import annotated_text
|
39 |
-
|
40 |
-
for text in _:
|
41 |
-
annotated_text(*text)
|
42 |
-
|
43 |
-
|
44 |
-
if __name__ == '__main__':
|
45 |
-
app_title = "# 切词"
|
46 |
-
app_info = ""
|
47 |
-
MyPage(app_title=app_title, app_info=app_info).main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/4_🤩_Apps.py
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
from urllib.parse import urlencode, parse_qs, parse_qsl, quote_plus, unquote_plus
|
3 |
-
|
4 |
-
# query_params = st.session_state.get("initial_query_params", {})
|
5 |
-
query_params = st.experimental_get_query_params()
|
6 |
-
query_params = {k: v[0] for k, v in query_params.items()}
|
7 |
-
|
8 |
-
|
9 |
-
# st.experimental_set_query_params(parse_qs('a=b&c=d')) # parse_qs
|
10 |
-
st.write("Initial query params of the session:", query_params)
|
11 |
-
|
12 |
-
if query_params.get('appid') == '1':
|
13 |
-
st.markdown("# App1")
|
14 |
-
|
15 |
-
elif query_params.get('appid') == '2':
|
16 |
-
st.markdown("# App2")
|
17 |
-
|
18 |
-
|
19 |
-
import time
|
20 |
-
|
21 |
-
st.session_state.file = time.time()
|
22 |
-
|
23 |
-
st.write(st.session_state.file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/5_👍_Postman.py
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
from meutils.pipe import *
|
2 |
-
from meutils.request_utils import request4retry
|
3 |
-
|
4 |
-
from appzoo.streamlit_app import Page
|
5 |
-
|
6 |
-
import streamlit as st
|
7 |
-
from streamlit.components.v1 import html, iframe
|
8 |
-
|
9 |
-
|
10 |
-
class MyPage(Page):
|
11 |
-
|
12 |
-
def main(self):
|
13 |
-
with st.form("Coding"):
|
14 |
-
col, *_ = st.columns(4)
|
15 |
-
method = col.selectbox('method', ['GET', 'POST'])
|
16 |
-
|
17 |
-
url = st.text_input('url')
|
18 |
-
data = st.text_area('data', {})
|
19 |
-
data = json.loads(data)
|
20 |
-
kwargs = {}
|
21 |
-
|
22 |
-
if st.form_submit_button("开始请求"):
|
23 |
-
_ = requests.request(method, url, json=data, **kwargs)
|
24 |
-
return st.json(_)
|
25 |
-
|
26 |
-
|
27 |
-
if __name__ == '__main__':
|
28 |
-
MyPage(layout='wide').main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/6666_🐧_hr.py
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
from meutils.pipe import *
|
2 |
-
|
3 |
-
from appzoo.streamlit_app import Page
|
4 |
-
|
5 |
-
import streamlit as st
|
6 |
-
|
7 |
-
from aip import AipOcr
|
8 |
-
|
9 |
-
APP_ID, API_KEY, SECRET_KEY = "25308860,GmAPqlyBDNLaoAqO2mrFhjS2,vXIoxFUdx2jiuRnGLvZSDMEczEaZsc1K".split(',')
|
10 |
-
|
11 |
-
client = AipOcr(APP_ID, API_KEY, SECRET_KEY)
|
12 |
-
|
13 |
-
""" 读取图片 """
|
14 |
-
|
15 |
-
|
16 |
-
def get_file_content(filePath):
|
17 |
-
with open(filePath, 'rb') as fp:
|
18 |
-
return fp.read()
|
19 |
-
|
20 |
-
|
21 |
-
""" 如果有可选参数 """
|
22 |
-
options = {}
|
23 |
-
options["language_type"] = "CHN_ENG"
|
24 |
-
options["detect_direction"] = "true"
|
25 |
-
options["detect_language"] = "true"
|
26 |
-
options["probability"] = "true"
|
27 |
-
|
28 |
-
|
29 |
-
class MyPage(Page):
|
30 |
-
|
31 |
-
def main(self):
|
32 |
-
with st.form("Coding"):
|
33 |
-
file = st.file_uploader("请上传不动产证明😄", "")
|
34 |
-
|
35 |
-
if st.form_submit_button('开始认证'):
|
36 |
-
if file:
|
37 |
-
r = client.basicGeneral(file.read())
|
38 |
-
r = '\n'.join(list(map(lambda d: d.get('words'), r['words_result'][4:11])))
|
39 |
-
st.text(r)
|
40 |
-
|
41 |
-
else:
|
42 |
-
st.markdown("# 请上传不动产证明😄再点认证👆🏻")
|
43 |
-
_ = '2022年11月16日,根据查询人\n张三李四\n申请,经查询,结果如下:\n编号:\n202211160344242218\n坐落\n雨花台区西善桥街道云上润府观庭 - 6幢6单元2206室'
|
44 |
-
st.text(_)
|
45 |
-
|
46 |
-
|
47 |
-
if __name__ == '__main__':
|
48 |
-
app_title = "# 认证"
|
49 |
-
app_info = ""
|
50 |
-
MyPage(app_title=app_title, app_info=app_info).main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/666_😝_TEST.py
DELETED
@@ -1,69 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : Python.
|
4 |
-
# @File : 666_😝_TEST
|
5 |
-
# @Time : 2023/3/9 上午10:28
|
6 |
-
# @Author : yuanjie
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description : https://github.com/streamlit/example-app-commenting/blob/main/streamlit_app.py
|
10 |
-
|
11 |
-
|
12 |
-
"""
|
13 |
-
不断刷新数据图表
|
14 |
-
https://blog.csdn.net/qq_42761569/article/details/123418493
|
15 |
-
http://cw.hubwiz.com/card/c/streamlit-manual/1/6/13/
|
16 |
-
"""
|
17 |
-
import altair as alt
|
18 |
-
|
19 |
-
|
20 |
-
def get_chart(data):
|
21 |
-
# 鼠标悬停
|
22 |
-
hover = alt.selection_single(
|
23 |
-
fields=["date"],
|
24 |
-
nearest=True,
|
25 |
-
on="mouseover",
|
26 |
-
empty="none",
|
27 |
-
)
|
28 |
-
|
29 |
-
lines = (
|
30 |
-
alt.Chart(data, title="Evolution of stock prices")
|
31 |
-
.mark_line()
|
32 |
-
.encode(
|
33 |
-
x="date",
|
34 |
-
y="price",
|
35 |
-
color="symbol",
|
36 |
-
strokeDash="symbol",
|
37 |
-
)
|
38 |
-
)
|
39 |
-
|
40 |
-
# Draw points on the line, and highlight based on selection
|
41 |
-
points = lines.transform_filter(hover).mark_circle(size=65)
|
42 |
-
|
43 |
-
# Draw a rule at the location of the selection
|
44 |
-
tooltips = (
|
45 |
-
alt.Chart(data)
|
46 |
-
.mark_rule()
|
47 |
-
.encode(
|
48 |
-
x="date",
|
49 |
-
y="price",
|
50 |
-
opacity=alt.condition(hover, alt.value(0.3), alt.value(0)),
|
51 |
-
tooltip=[
|
52 |
-
alt.Tooltip("date", title="Date"),
|
53 |
-
alt.Tooltip("price", title="Price (USD)"),
|
54 |
-
],
|
55 |
-
)
|
56 |
-
.add_selection(hover)
|
57 |
-
)
|
58 |
-
|
59 |
-
return (lines + points + tooltips).interactive()
|
60 |
-
|
61 |
-
|
62 |
-
# source = data.stocks()
|
63 |
-
# all_symbols = source.symbol.unique()
|
64 |
-
# symbols = st.multiselect("Choose stocks to visualize", all_symbols, all_symbols[:3])
|
65 |
-
#
|
66 |
-
#
|
67 |
-
# source = source[source.symbol.isin(symbols)]
|
68 |
-
# chart = get_chart(source)
|
69 |
-
# st.altair_chart(chart, use_container_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/66_🔥_ASCII字符画.py
DELETED
@@ -1,107 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
from numpy import load
|
3 |
-
from numpy import expand_dims
|
4 |
-
from matplotlib import pyplot
|
5 |
-
from PIL import Image, ImageDraw, ImageFont, ImageFile
|
6 |
-
import numpy as np
|
7 |
-
import os
|
8 |
-
|
9 |
-
st.set_page_config(page_title='ASCII字符画生成器', page_icon="🅰", layout="wide")
|
10 |
-
|
11 |
-
st.header("上传一张图片生成ASCII字符画")
|
12 |
-
|
13 |
-
ImageFile.LOAD_TRUNCATED_IMAGES = True
|
14 |
-
Image.MAX_IMAGE_PIXELS = None
|
15 |
-
|
16 |
-
color_fornt = st.sidebar.color_picker('选择前景色', '#00b8e6')
|
17 |
-
color_background = st.sidebar.color_picker('选择背景色', '#ffffff')
|
18 |
-
|
19 |
-
sc_control = st.sidebar.slider('选择密度参数1', 0.1, 0.9, 0.5, 0.1)
|
20 |
-
gcf_control = st.sidebar.slider('选择密度参数2', 0.5, 4.5, 2.1, 0.1)
|
21 |
-
|
22 |
-
uploaded_file = st.file_uploader("选择一张图片", type=["png", "jpg", "bmp", "jpeg"])
|
23 |
-
|
24 |
-
|
25 |
-
@st.cache()
|
26 |
-
def asciiart(in_f, SC, GCF, out_f, bgcolor=color_background):
|
27 |
-
chars = np.asarray(list(' .,:irs?@9B&#*$%!~'))
|
28 |
-
|
29 |
-
font = ImageFont.load_default()
|
30 |
-
letter_width = font.getsize("x")[0]
|
31 |
-
letter_height = font.getsize("x")[1]
|
32 |
-
WCF = letter_height / letter_width
|
33 |
-
img = Image.open(in_f)
|
34 |
-
widthByLetter = round(img.size[0] * SC * WCF)
|
35 |
-
heightByLetter = round(img.size[1] * SC)
|
36 |
-
S = (widthByLetter, heightByLetter)
|
37 |
-
img = img.resize(S)
|
38 |
-
img = np.sum(np.asarray(img), axis=2)
|
39 |
-
img -= img.min()
|
40 |
-
img = (1.0 - img / img.max()) ** GCF * (chars.size - 1)
|
41 |
-
lines = ("\n".join(("".join(r) for r in chars[img.astype(int)]))).split("\n")
|
42 |
-
nbins = len(lines)
|
43 |
-
newImg_width = letter_width * widthByLetter
|
44 |
-
newImg_height = letter_height * heightByLetter
|
45 |
-
newImg = Image.new("RGBA", (newImg_width, newImg_height), bgcolor)
|
46 |
-
draw = ImageDraw.Draw(newImg)
|
47 |
-
leftpadding = 0
|
48 |
-
y = 0
|
49 |
-
lineIdx = 0
|
50 |
-
|
51 |
-
for line in lines:
|
52 |
-
color = color_fornt
|
53 |
-
lineIdx += 1
|
54 |
-
draw.text((leftpadding, y), line, color, font=font)
|
55 |
-
y += letter_height
|
56 |
-
|
57 |
-
newImg.save(out_f)
|
58 |
-
|
59 |
-
|
60 |
-
@st.cache()
|
61 |
-
def load_image(filename, size=(512, 512)):
|
62 |
-
pixels = load_img(filename, target_size=size)
|
63 |
-
pixels = img_to_array(pixels)
|
64 |
-
pixels = (pixels - 127.5) / 127.5
|
65 |
-
pixels = expand_dims(pixels, 0)
|
66 |
-
return pixels
|
67 |
-
|
68 |
-
|
69 |
-
@st.cache()
|
70 |
-
def imgGen2(img1):
|
71 |
-
inputf = img1
|
72 |
-
SC = sc_control
|
73 |
-
GCF = gcf_control
|
74 |
-
asciiart(inputf, SC, GCF, "results.png", color_background)
|
75 |
-
img = Image.open(img1)
|
76 |
-
img2 = Image.open('results.png').resize(img.size)
|
77 |
-
|
78 |
-
return img2
|
79 |
-
|
80 |
-
|
81 |
-
# 下载按钮效果设置
|
82 |
-
css = """<style>
|
83 |
-
.stDownloadButton>button {
|
84 |
-
background-color: #0099ff;
|
85 |
-
color:#ffffff;
|
86 |
-
}
|
87 |
-
|
88 |
-
.stDownloadButton>button:hover {
|
89 |
-
background-color: green;
|
90 |
-
color:white;
|
91 |
-
}
|
92 |
-
</style>
|
93 |
-
"""
|
94 |
-
st.markdown(css, unsafe_allow_html=True)
|
95 |
-
|
96 |
-
if uploaded_file is not None:
|
97 |
-
st.sidebar.image(uploaded_file, caption='原始图片', use_column_width=True)
|
98 |
-
im = imgGen2(uploaded_file)
|
99 |
-
st.image(im, width=700)
|
100 |
-
with open("results.png", "rb") as file:
|
101 |
-
# st.image("图片.jpg")
|
102 |
-
btn = st.download_button(
|
103 |
-
label="点我下载生成的ASCII字符画",
|
104 |
-
data=file,
|
105 |
-
file_name="ASCII字符画.png",
|
106 |
-
mime="image/png"
|
107 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/6_🕷_coding.py
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : Python.
|
4 |
-
# @File : 6_🕷_coding
|
5 |
-
# @Time : 2022/10/27 下午4:54
|
6 |
-
# @Author : yuanjie
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description :
|
10 |
-
|
11 |
-
|
12 |
-
import streamlit as st
|
13 |
-
|
14 |
-
from streamlit_ace import st_ace
|
15 |
-
|
16 |
-
# Spawn a new Ace editor
|
17 |
-
content = st_ace()
|
18 |
-
|
19 |
-
# Display editor's content as you type
|
20 |
-
content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/7_登录.py
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : Python.
|
4 |
-
# @File : 7_登录
|
5 |
-
# @Time : 2023/3/14 下午4:02
|
6 |
-
# @Author : yuanjie
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description :
|
10 |
-
|
11 |
-
import wenxin_api
|
12 |
-
from wenxin_api.tasks.text_to_image import TextToImage
|
13 |
-
|
14 |
-
import streamlit as st
|
15 |
-
import streamlit_authenticator as stauth
|
16 |
-
from streamlit_authenticator import Authenticate
|
17 |
-
|
18 |
-
# ME
|
19 |
-
from meutils.pipe import *
|
20 |
-
|
21 |
-
st.set_page_config(page_title="文本标注平台", page_icon=":rainbow:", layout="centered", initial_sidebar_state="auto")
|
22 |
-
|
23 |
-
# 如下代码数据,可以来自数据库
|
24 |
-
admin_password = '123456'
|
25 |
-
|
26 |
-
_ = f"""
|
27 |
-
credentials:
|
28 |
-
usernames:
|
29 |
-
admin:
|
30 |
-
email: [email protected]
|
31 |
-
name: admin
|
32 |
-
password: {stauth.Hasher([admin_password]).generate()[0]} # To be replaced with hashed password
|
33 |
-
|
34 |
-
cookie:
|
35 |
-
expiry_days: 30
|
36 |
-
key: some_signature_key
|
37 |
-
name: some_cookie_name
|
38 |
-
preauthorized:
|
39 |
-
|
40 |
-
emails:
|
41 | |
42 |
-
"""
|
43 |
-
|
44 |
-
config = yaml.safe_load(_)
|
45 |
-
|
46 |
-
authenticator = Authenticate(
|
47 |
-
config['credentials'],
|
48 |
-
config['cookie']['name'],
|
49 |
-
config['cookie']['key'],
|
50 |
-
config['cookie']['expiry_days'],
|
51 |
-
config['preauthorized']
|
52 |
-
)
|
53 |
-
|
54 |
-
name, authentication_status, username = authenticator.login('图像生成系统', 'main')
|
55 |
-
|
56 |
-
if authentication_status:
|
57 |
-
authenticator.logout('退出', 'sidebar')
|
58 |
-
st.write('# 图像生成系统')
|
59 |
-
|
60 |
-
elif authentication_status == False:
|
61 |
-
st.error('Username/password is incorrect')
|
62 |
-
|
63 |
-
# elif authentication_status == None:
|
64 |
-
# st.warning('Please enter your username and password')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/888_🌰_demo.py
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
from urllib.parse import urlencode, parse_qs
|
2 |
-
import streamlit as st
|
3 |
-
|
4 |
-
|
5 |
-
st.json(st.session_state)
|
6 |
-
initial_query_params = st.session_state.get("initial_query_params")
|
7 |
-
query_params = {k: v[0] for k, v in st.experimental_get_query_params().items()}
|
8 |
-
if not initial_query_params:
|
9 |
-
initial_query_params = query_params.copy()
|
10 |
-
st.session_state["initial_query_params"] = initial_query_params.copy()
|
11 |
-
|
12 |
-
st.write("Initial query params of the session:", initial_query_params)
|
13 |
-
st.write("Query params before setting new ones:", query_params)
|
14 |
-
|
15 |
-
new_query_string = st.text_area("New query params string (like 'a=b&c=d')", value=urlencode(initial_query_params))
|
16 |
-
if st.button("Set new query params without starting new session"):
|
17 |
-
st.experimental_set_query_params(**parse_qs(new_query_string))
|
18 |
-
|
19 |
-
with st.sidebar:
|
20 |
-
st.markdown("---")
|
21 |
-
st.markdown(
|
22 |
-
'<h6>Made in  <img src="https://streamlit.io/images/brand/streamlit-mark-color.png" alt="Streamlit logo" height="16">  by <a href="https://twitter.com/andfanilo">@andfanilo</a></h6>',
|
23 |
-
unsafe_allow_html=True,
|
24 |
-
)
|
25 |
-
st.markdown(
|
26 |
-
'<div style="margin-top: 0.75em;"><a href="https://www.buymeacoffee.com/andfanilo" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a></div>',
|
27 |
-
unsafe_allow_html=True,
|
28 |
-
)
|
29 |
-
st.json(st.session_state)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/889_机器监控.py
DELETED
@@ -1,118 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : Python.
|
4 |
-
# @File : 991_streamlit_apex_charts
|
5 |
-
# @Time : 2022/10/17 上午10:48
|
6 |
-
# @Author : yuanjie
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description :
|
10 |
-
|
11 |
-
|
12 |
-
import psutil
|
13 |
-
import streamlit as st
|
14 |
-
import time
|
15 |
-
import datetime
|
16 |
-
from streamlit_autorefresh import st_autorefresh
|
17 |
-
from streamlit_apex_charts import bar_chart, pie_chart
|
18 |
-
import pandas as pd
|
19 |
-
import platform
|
20 |
-
import os
|
21 |
-
|
22 |
-
|
23 |
-
st.set_page_config(page_title="系统信息查看器", page_icon="💻", layout="wide")
|
24 |
-
|
25 |
-
#st_autorefresh(interval=5000, limit=100000, key="Mr.R")
|
26 |
-
|
27 |
-
st.header("系统信息查看器")
|
28 |
-
base_infor = [[datetime.datetime.now().strftime("%Y-%m-%d %H: %M: %S"),str(psutil.users()[0][0]),platform.platform()]]
|
29 |
-
df_base_infor = pd.DataFrame(base_infor, columns=["当前时间","登陆者","操作系统"])
|
30 |
-
st.table(df_base_infor)
|
31 |
-
|
32 |
-
#获取网卡名称
|
33 |
-
def get_key():
|
34 |
-
key_info = psutil.net_io_counters(pernic=True).keys() # 获取网卡名称
|
35 |
-
recv = {}
|
36 |
-
sent = {}
|
37 |
-
for key in key_info:
|
38 |
-
recv.setdefault(key, psutil.net_io_counters(pernic=True).get(key).bytes_recv) # 各网卡接收的字节数
|
39 |
-
sent.setdefault(key, psutil.net_io_counters(pernic=True).get(key).bytes_sent) # 各网卡发送的字节数
|
40 |
-
return key_info, recv, sent
|
41 |
-
|
42 |
-
#获取网卡速率
|
43 |
-
def get_rate(func):
|
44 |
-
key_info, old_recv, old_sent = func() # 上一秒收集的数据
|
45 |
-
time.sleep(1)
|
46 |
-
key_info, now_recv, now_sent = func() # 当前所收集的数据
|
47 |
-
net_in = {}
|
48 |
-
net_out = {}
|
49 |
-
for key in key_info:
|
50 |
-
net_in.setdefault(key, (now_recv.get(key) - old_recv.get(key)) / 1024) # 每秒接收速率
|
51 |
-
net_out.setdefault(key, (now_sent.get(key) - old_sent.get(key)) / 1024) # 每秒发送速率
|
52 |
-
return key_info, net_in, net_out
|
53 |
-
|
54 |
-
|
55 |
-
c1, c2, c3 = st.columns(3)
|
56 |
-
|
57 |
-
with c1:
|
58 |
-
#内存
|
59 |
-
mem = psutil.virtual_memory()
|
60 |
-
zj = float(mem.total) / 1024 / 1024 / 1024
|
61 |
-
ysy = float(mem.used) / 1024 / 1024 / 1024
|
62 |
-
kx = float(mem.free) / 1024 / 1024 / 1024
|
63 |
-
|
64 |
-
data_neicun = [[round(ysy,2),round(kx, 2)]]
|
65 |
-
df_neicun = pd.DataFrame(data_neicun, columns=["已用内存","空闲内存"])
|
66 |
-
pie_chart("内存使用情况(GB)", df_neicun)
|
67 |
-
|
68 |
-
|
69 |
-
#CPU
|
70 |
-
cpu_liyonglv = (str(psutil.cpu_percent(1))) + '%'
|
71 |
-
cpu_data = [[cpu_liyonglv]]
|
72 |
-
df_cpu = pd.DataFrame(cpu_data, columns=["CPU利用率"])
|
73 |
-
bar_chart("CPU利用率(%)", df_cpu)
|
74 |
-
|
75 |
-
with c2:
|
76 |
-
#磁盘
|
77 |
-
dk = psutil.disk_usage('/')
|
78 |
-
total = dk.total / 1024 / 1024 / 1024
|
79 |
-
used = dk.used / 1024 / 1024 / 1024
|
80 |
-
free = dk.free / 1024 / 1024 / 1024
|
81 |
-
|
82 |
-
cipan_shiyong = [[used, free]]
|
83 |
-
df_cipan = pd.DataFrame(cipan_shiyong, columns=["已使用磁盘大小","空闲磁盘大小"])
|
84 |
-
pie_chart("磁盘使用率(%)", df_cipan)
|
85 |
-
|
86 |
-
#网络速率
|
87 |
-
key_info, net_in, net_out = get_rate(get_key)
|
88 |
-
wangka_liuliang = []
|
89 |
-
for key in key_info:
|
90 |
-
wangka_liuliang.append([net_in.get(key),net_out.get(key)])
|
91 |
-
speed_internet = wangka_liuliang
|
92 |
-
df_speed = pd.DataFrame(speed_internet, columns=["下行速率","上行速率"])
|
93 |
-
bar_chart("网络速率(kb/s)", df_speed)
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
with c3:
|
98 |
-
#进程信息
|
99 |
-
pids = psutil.pids()
|
100 |
-
process = []
|
101 |
-
for pid in pids:
|
102 |
-
p = psutil.Process(pid)
|
103 |
-
process_name = p.name()
|
104 |
-
process.append([pid, process_name, p.is_running()])
|
105 |
-
|
106 |
-
df_process = pd.DataFrame(process, columns=["PID","进程名","是否还在运行"])
|
107 |
-
st.dataframe(df_process)
|
108 |
-
|
109 |
-
# #已安装软件
|
110 |
-
# import wmi
|
111 |
-
# c = wmi.WMI()
|
112 |
-
# software_list = []
|
113 |
-
# for s in c.Win32_Product():
|
114 |
-
# software_list.append([s.Caption, s.Vendor, s.Version])
|
115 |
-
# if len(software_list)>1:
|
116 |
-
# st.dataframe(pd.DataFrame(software_list, columns=["名称","发布人","版本"]))
|
117 |
-
# else:
|
118 |
-
# st.info("正在导出已安装的软件程序列表")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/8_内容审核.py
DELETED
@@ -1,74 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : Python.
|
4 |
-
# @File : 8_内容审核
|
5 |
-
# @Time : 2023/3/15 上午10:40
|
6 |
-
# @Author : yuanjie
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description : pip install baidu-aip
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
from functools import lru_cache
|
15 |
-
from aip import AipImageCensor, AipOcr
|
16 |
-
|
17 |
-
_ = """
|
18 |
-
31294942
|
19 |
-
d8pnIpxUaZ7ce65StreDuOY0
|
20 |
-
lldWlW574LV8n3mIG2xQvcL6Wa7MXi5q
|
21 |
-
""".strip().split()
|
22 |
-
ai = AipImageCensor(*_)
|
23 |
-
|
24 |
-
@lru_cache()
|
25 |
-
def text_censor(text='一群垃圾去找小姐'):
|
26 |
-
data = ai.textCensorUserDefined(text).get('data', [])
|
27 |
-
rst = []
|
28 |
-
for _ in data:
|
29 |
-
d = {}
|
30 |
-
d['msg'] = _['msg']
|
31 |
-
hits = _['hits']
|
32 |
-
d['words'] = sum([hit['words'] for hit in hits], [])
|
33 |
-
rst.append(d)
|
34 |
-
return rst if rst else ['合规']
|
35 |
-
|
36 |
-
@lru_cache()
|
37 |
-
def image_censor(img): # open('hao123 logo.png', 'rb').read()
|
38 |
-
data = ai.imageCensorUserDefined(img).get('data', [])
|
39 |
-
rst = []
|
40 |
-
for _ in data:
|
41 |
-
d = {}
|
42 |
-
d['msg'] = _['msg']
|
43 |
-
# hits = _['hits']
|
44 |
-
# d['words'] = sum([hit['words'] for hit in hits], [])
|
45 |
-
rst.append(d)
|
46 |
-
return rst if rst else ['合规']
|
47 |
-
|
48 |
-
import streamlit as st
|
49 |
-
|
50 |
-
tab1, tab2, tab3 = st.tabs(["文本审核", "图片审核", "视频审核"])
|
51 |
-
|
52 |
-
with tab1:
|
53 |
-
st.header("文本审核")
|
54 |
-
text= st.text_input('请输入文本', value='一群垃圾去找小姐')
|
55 |
-
button = st.button('开始审核文本')
|
56 |
-
if button:
|
57 |
-
st.json(text_censor(text))
|
58 |
-
|
59 |
-
with tab2:
|
60 |
-
st.header("图像审核")
|
61 |
-
file = st.file_uploader('请上传图片')
|
62 |
-
button = st.button('开始审核图片')
|
63 |
-
|
64 |
-
if file and button:
|
65 |
-
col1, col2 = st.columns(2)
|
66 |
-
with col1:
|
67 |
-
st.image(file)
|
68 |
-
with col2:
|
69 |
-
st.json(image_censor(file.read()))
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
with tab3:
|
74 |
-
st.header("视频审核")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/990_streamlit_autorefresh.py
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
from streamlit_autorefresh import st_autorefresh
|
3 |
-
|
4 |
-
# Run the autorefresh about every 2000 milliseconds (2 seconds) and stop
|
5 |
-
# after it's been refreshed 100 times.
|
6 |
-
count = st_autorefresh(interval=2000, limit=100, key="fizzbuzzcounter")
|
7 |
-
|
8 |
-
# The function returns a counter for number of refreshes. This allows the
|
9 |
-
# ability to make special requests at different intervals based on the count
|
10 |
-
if count == 0:
|
11 |
-
st.write("Count is zero")
|
12 |
-
elif count % 3 == 0 and count % 5 == 0:
|
13 |
-
st.write("FizzBuzz")
|
14 |
-
elif count % 3 == 0:
|
15 |
-
st.write("Fizz")
|
16 |
-
elif count % 5 == 0:
|
17 |
-
st.write("Buzz")
|
18 |
-
else:
|
19 |
-
st.write(f"Count: {count}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/991_streamlit_apex_charts.py
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
import numpy as np
|
2 |
-
import pandas as pd
|
3 |
-
import streamlit as st
|
4 |
-
from streamlit_apex_charts import line_chart, bar_chart, pie_chart, area_chart, radar_chart
|
5 |
-
|
6 |
-
st.set_page_config(layout="wide")
|
7 |
-
|
8 |
-
df = pd.DataFrame(np.random.randint(1, 10, size=(10, 3)), columns=['Apple', 'Microsoft', 'Google'])
|
9 |
-
|
10 |
-
line_chart('Line chart', df)
|
11 |
-
c1, c2 = st.columns(2)
|
12 |
-
with c1:
|
13 |
-
bar_chart('Bar chart', df)
|
14 |
-
pie_chart('Pie chart', df)
|
15 |
-
with c2:
|
16 |
-
area_chart('Area chart', df)
|
17 |
-
radar_chart('Radar chart', df)
|
18 |
-
|
19 |
-
# https://discuss.streamlit.io/t/new-component-streamlit-apex-charts/18769/3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/992_streamlit_chat.py
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : Python.
|
4 |
-
# @File : 991_streamlit_apex_charts
|
5 |
-
# @Time : 2022/10/17 上午10:48
|
6 |
-
# @Author : yuanjie
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description :
|
10 |
-
import streamlit as st
|
11 |
-
from streamlit_chat import message
|
12 |
-
|
13 |
-
message_history = ["你好!我是你的电影小助手,很高兴为您服务。"]
|
14 |
-
|
15 |
-
for message_ in message_history:
|
16 |
-
message(message_, avatar_style='adventurer') # display all the previous message
|
17 |
-
|
18 |
-
placeholder = st.empty() # placeholder for latest message
|
19 |
-
input_ = st.text_input("请向我提问:")
|
20 |
-
message_history.append(input_)
|
21 |
-
|
22 |
-
with placeholder.container():
|
23 |
-
# message(message_history[-1], avatar_style='adventurer') # display the latest message
|
24 |
-
message(message_history[-1], is_user=True) # align's the message to the right
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/993_streamlit_text_rating.py
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
from streamlit_text_rating.st_text_rater import st_text_rater
|
2 |
-
|
3 |
-
|
4 |
-
import streamlit as st
|
5 |
-
|
6 |
-
|
7 |
-
st.title("Awesome App")
|
8 |
-
for text in ["Is this text helpful?", "Do you like this text?"]:
|
9 |
-
response = st_text_rater(text=text)
|
10 |
-
st.write(f"response --> {response}")
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/994_自定义style.py
DELETED
@@ -1,39 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : Python.
|
4 |
-
# @File : 994_自定义style
|
5 |
-
# @Time : 2022/10/17 上午11:45
|
6 |
-
# @Author : yuanjie
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description :
|
10 |
-
|
11 |
-
|
12 |
-
import streamlit as st
|
13 |
-
from streamlit.components.v1 import html
|
14 |
-
|
15 |
-
st.button('button背景色?换一个吧')
|
16 |
-
st.text_area('del', placeholder='Label多余?删了就好')
|
17 |
-
st.radio('想放大label字号, 修改字体吗?', ['想', '很想'])
|
18 |
-
|
19 |
-
st.markdown('''<style>
|
20 |
-
/* radio label字号、字体 */
|
21 |
-
#root > div:nth-child(1) > div > div > div > div > section > div > div:nth-child(1) > div > div:nth-child(3) > div > label {
|
22 |
-
font-size: 50px;
|
23 |
-
font-family: "Times New Roman", serif;
|
24 |
-
}
|
25 |
-
/* button背景色 */
|
26 |
-
#root > div:nth-child(1) > div > div > div > div > section > div > div:nth-child(1) > div > div:nth-child(1) > div > button {
|
27 |
-
background-color: black;
|
28 |
-
color: white;
|
29 |
-
}
|
30 |
-
/* radio选中项颜色 */
|
31 |
-
#root > div:nth-child(1) > div > div > div > div > section > div > div:nth-child(1) > div > div:nth-child(3) > div > div > label:nth-child(1) > div.st-co.st-cs.st-ct.st-cu.st-cv.st-cw.st-az.st-b4.st-cx.st-cy.st-cz.st-d0.st-d1.st-d2.st-c4.st-d3.st-d4.st-d5.st-b2.st-bl {
|
32 |
-
background-color: black;
|
33 |
-
}
|
34 |
-
</style>''', unsafe_allow_html=True)
|
35 |
-
|
36 |
-
js_delete = '''window.parent.document.querySelector("#root > div:nth-child(1) > div > div > div > div > section > div > div:nth-child(1) > div > div:nth-child(2) > div > label").remove()'''
|
37 |
-
html(f'''<script>{js_delete}</script>''',
|
38 |
-
width=0,
|
39 |
-
height=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/995_streamlit_echarts.py
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : Python.
|
4 |
-
# @File : 995_streamlit_echarts
|
5 |
-
# @Time : 2022/10/17 下午12:11
|
6 |
-
# @Author : yuanjie
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description :
|
10 |
-
|
11 |
-
|
12 |
-
from streamlit_echarts import st_echarts
|
13 |
-
|
14 |
-
options = {
|
15 |
-
"xAxis": {
|
16 |
-
"type": "category",
|
17 |
-
"data": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
18 |
-
},
|
19 |
-
"yAxis": {"type": "value"},
|
20 |
-
"series": [
|
21 |
-
{"data": [820, 932, 901, 934, 1290, 1330, 1320], "type": "line"}
|
22 |
-
],
|
23 |
-
}
|
24 |
-
st_echarts(options=options)
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/996_streamlit_pyecharts.py
DELETED
@@ -1,73 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : Python.
|
4 |
-
# @File : 995_streamlit_echarts
|
5 |
-
# @Time : 2022/10/17 下午12:11
|
6 |
-
# @Author : yuanjie
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description :
|
10 |
-
|
11 |
-
from pyecharts import options as opts
|
12 |
-
from pyecharts.charts import Bar, WordCloud
|
13 |
-
from streamlit_echarts import st_pyecharts
|
14 |
-
import streamlit as st
|
15 |
-
|
16 |
-
|
17 |
-
# st.markdown(open('xx.html').read(), unsafe_allow_html=True)
|
18 |
-
|
19 |
-
tab1, tab2, tab3 = st.tabs(["Bar", "WordCloud", "Owl"])
|
20 |
-
|
21 |
-
with tab1:
|
22 |
-
b = (
|
23 |
-
Bar()
|
24 |
-
.add_xaxis(["Microsoft", "Amazon", "IBM", "Oracle", "Google", "Alibaba"])
|
25 |
-
.add_yaxis(
|
26 |
-
"2017-2018 Revenue in (billion $)", [21.2, 20.4, 10.3, 6.08, 4, 2.2]
|
27 |
-
)
|
28 |
-
.set_global_opts(
|
29 |
-
title_opts=opts.TitleOpts(
|
30 |
-
title="Top cloud providers 2018", subtitle="2017-2018 Revenue"
|
31 |
-
),
|
32 |
-
toolbox_opts=opts.ToolboxOpts(),
|
33 |
-
)
|
34 |
-
)
|
35 |
-
st_pyecharts(b)
|
36 |
-
|
37 |
-
with tab2:
|
38 |
-
pairs = [('中国', 33),
|
39 |
-
('苹果', 24),
|
40 |
-
('奚梦瑶', 20),
|
41 |
-
('美国', 16),
|
42 |
-
('特朗普', 16),
|
43 |
-
('何猷君', 15),
|
44 |
-
('戛纳', 13),
|
45 |
-
('红毯', 12),
|
46 |
-
('iPhone', 12),
|
47 |
-
('车队', 9),
|
48 |
-
('车祸', 9),
|
49 |
-
('优衣', 9),
|
50 |
-
('信息', 9),
|
51 |
-
('李亚鹏', 9),
|
52 |
-
('恋情', 9),
|
53 |
-
('任素', 9),
|
54 |
-
('男孩', 9),
|
55 |
-
('亚洲', 8),
|
56 |
-
('孩子', 8),
|
57 |
-
('大学生', 8)]
|
58 |
-
shapes = ['circle', 'cardioid', 'diamond', 'triangle-forward', 'triangle', 'pentagon', 'star']
|
59 |
-
|
60 |
-
wc = (
|
61 |
-
WordCloud()
|
62 |
-
.add("WordCloud", data_pair=pairs, shape=shapes[0], width='900px', height='500px')
|
63 |
-
|
64 |
-
.set_global_opts(
|
65 |
-
title_opts=opts.TitleOpts(
|
66 |
-
title="WordCloud", subtitle="WordCloud"
|
67 |
-
),
|
68 |
-
toolbox_opts=opts.ToolboxOpts(), )
|
69 |
-
)
|
70 |
-
|
71 |
-
st_pyecharts(wc)
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/997_streamlit_aggrid.py
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : Python.
|
4 |
-
# @File : 997_streamlit_aggrid
|
5 |
-
# @Time : 2022/10/17 下午1:14
|
6 |
-
# @Author : yuanjie
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description :
|
10 |
-
|
11 |
-
|
12 |
-
from st_aggrid import AgGrid
|
13 |
-
import pandas as pd
|
14 |
-
|
15 |
-
df = pd.read_csv('./data/airline-safety.csv')
|
16 |
-
AgGrid(df)
|
17 |
-
|
18 |
-
# from st_aggrid import AgGrid, DataReturnMode, GridUpdateMode, GridOptionsBuilder
|
19 |
-
# options_builder = GridOptionsBuilder.from_dataframe(df)
|
20 |
-
# options_builder.configure_default_column(groupable=True, value=True, enableRowGroup=True, aggFunc='sum', editable=True, wrapText=True, autoHeight=True)
|
21 |
-
# options_builder.configure_column('col1', pinned='left')
|
22 |
-
# options_builder.configure_column('col2', pinned='left')
|
23 |
-
# grid_options = options_builder.build()
|
24 |
-
# grid_return = AgGrid(df, grid_options, theme='blue')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/998_streamlit_agraph.py
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
from streamlit_agraph import agraph, Node, Edge, Config
|
3 |
-
|
4 |
-
|
5 |
-
c1, c2 = st.columns(2)
|
6 |
-
|
7 |
-
|
8 |
-
with c1:
|
9 |
-
|
10 |
-
nodes = []
|
11 |
-
edges = []
|
12 |
-
nodes.append(Node(id="Spiderman",
|
13 |
-
label="Peter Parker",
|
14 |
-
size=25,
|
15 |
-
shape="circularImage",
|
16 |
-
image="http://marvel-force-chart.surge.sh/marvel_force_chart_img/top_spiderman.png")
|
17 |
-
) # includes **kwargs
|
18 |
-
nodes.append(Node(id="Captain_Marvel",
|
19 |
-
size=25,
|
20 |
-
shape="circularImage",
|
21 |
-
image="http://marvel-force-chart.surge.sh/marvel_force_chart_img/top_captainmarvel.png")
|
22 |
-
)
|
23 |
-
edges.append(Edge(source="Captain_Marvel",
|
24 |
-
label="friend_of",
|
25 |
-
target="Spiderman",
|
26 |
-
# **kwargs
|
27 |
-
)
|
28 |
-
)
|
29 |
-
|
30 |
-
config = Config(width=500,
|
31 |
-
height=500,
|
32 |
-
# **kwargs
|
33 |
-
)
|
34 |
-
|
35 |
-
return_value = agraph(nodes=nodes, edges=edges, config=config)
|
36 |
-
|
37 |
-
with c2:
|
38 |
-
# Currently not workin since update to agraph 2.0 - work in progress
|
39 |
-
from rdflib import Graph
|
40 |
-
from streamlit_agraph import TripleStore, agraph
|
41 |
-
|
42 |
-
graph = Graph()
|
43 |
-
graph.parse("http://www.w3.org/People/Berners-Lee/card")
|
44 |
-
store = TripleStore()
|
45 |
-
|
46 |
-
for subj, pred, obj in graph:
|
47 |
-
store.add_triple(subj, pred, obj, "")
|
48 |
-
|
49 |
-
agraph(list(store.getNodes()), list(store.getEdges()), config)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/998_知识图谱.py
DELETED
@@ -1,39 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
from streamlit_agraph import agraph, Node, Edge, Config
|
3 |
-
|
4 |
-
from meutils.pipe import *
|
5 |
-
|
6 |
-
Node = lru_cache(100000)(Node)
|
7 |
-
Edge = lru_cache(100000)(Edge)
|
8 |
-
|
9 |
-
|
10 |
-
def df2nodes(df_nodes): # df.itertuples()
|
11 |
-
df_nodes.columns = ['k', 'v', 'r']
|
12 |
-
|
13 |
-
nodes = set()
|
14 |
-
edges = set()
|
15 |
-
|
16 |
-
for source, target, label in tqdm(df_nodes.values, 'Triplet'):
|
17 |
-
node_s = Node(source, label=source)
|
18 |
-
node_t = Node(target, label=target)
|
19 |
-
|
20 |
-
edge = Edge(source, target, label=label)
|
21 |
-
|
22 |
-
nodes.update([node_s, node_t])
|
23 |
-
edges.update([edge])
|
24 |
-
return nodes, edges
|
25 |
-
|
26 |
-
|
27 |
-
# df = pd.read_excel("~/Desktop/simple.xlsx", sheet_name="links")
|
28 |
-
df = pd.read_csv('~/Desktop/tt.csv').tail(500)
|
29 |
-
|
30 |
-
|
31 |
-
nodes, edges = df2nodes(df)
|
32 |
-
|
33 |
-
config = Config(width=1000, height=1000)
|
34 |
-
|
35 |
-
|
36 |
-
st.set_page_config(page_title="Knowledge Graph", page_icon="💗", layout="wide")
|
37 |
-
return_value = agraph(nodes=nodes, edges=edges, config=config)
|
38 |
-
|
39 |
-
del df, nodes, edges
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/999_draw_table.py
DELETED
@@ -1,129 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : Python.
|
4 |
-
# @File : 999_draw_table
|
5 |
-
# @Time : 2022/10/17 下午1:36
|
6 |
-
# @Author : yuanjie
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description :
|
10 |
-
|
11 |
-
|
12 |
-
import streamlit as st
|
13 |
-
import pandas as pd
|
14 |
-
import streamlit.components.v1 as components
|
15 |
-
|
16 |
-
st.set_page_config(page_icon="🌴", page_title="Tabulator表格", layout="wide")
|
17 |
-
|
18 |
-
file = st.file_uploader("请上传文件", type=["csv"])
|
19 |
-
|
20 |
-
if file is not None:
|
21 |
-
df = pd.read_csv(file, encoding="gbk")
|
22 |
-
|
23 |
-
|
24 |
-
def draw_table(df, height, width):
|
25 |
-
columns = df.columns
|
26 |
-
column_selection = []
|
27 |
-
column_selection.append(
|
28 |
-
"""<select id="filter-field" style="font-size:15px;background:white;color:black;border-radius:15%;border-color:grey;">""")
|
29 |
-
for i in range(len(columns)):
|
30 |
-
column_selection.append(
|
31 |
-
"""<option value='""" + str(columns[i]) + """'>""" + str(columns[i]) + """</option>""")
|
32 |
-
column_selection.append("""</select>""")
|
33 |
-
table_data = df.to_dict(orient="records")
|
34 |
-
column_setting = []
|
35 |
-
column_setting.append(
|
36 |
-
"""{rowHandle:true, formatter:"handle", headerSort:false, frozen:true, width:30, minWidth:30}""")
|
37 |
-
for y in range(df.shape[1]):
|
38 |
-
column_setting.append(
|
39 |
-
{"title": columns[y], "field": columns[y], "width": 200, "sorter": "string", "hozAlign": "center",
|
40 |
-
"headerFilter": "input", "editor": "input"})
|
41 |
-
|
42 |
-
components.html("""
|
43 |
-
<!DOCTYPE html>
|
44 |
-
<html lang="en">
|
45 |
-
<head>
|
46 |
-
<meta charset="UTF-8">
|
47 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
48 |
-
<title>Tabulator Example</title>
|
49 |
-
<link href="https://unpkg.com/[email protected]/dist/css/tabulator_modern.min.css" rel="stylesheet">
|
50 |
-
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/js/tabulator.min.js"></script>
|
51 |
-
<script type="text/javascript" src="https://moment.github.io/luxon/global/luxon.min.js"></script>
|
52 |
-
<script type="text/javascript" src="https://oss.sheetjs.com/sheetjs/xlsx.full.min.js"></script>
|
53 |
-
</head><body>
|
54 |
-
<div style="margin-left:30%;">""" + "".join(column_selection) +
|
55 |
-
"""<select id="filter-type" style="font-size:15px;background:#00ccff;color:white;border-radius:15%;border-color:white;">
|
56 |
-
<option value="like">like</option>
|
57 |
-
<option value="=">=</option>
|
58 |
-
<option value="<"><</option>
|
59 |
-
<option value="<="><=</option>
|
60 |
-
<option value=">">></option>
|
61 |
-
<option value=">=">>=</option>
|
62 |
-
<option value="!=">!=</option>
|
63 |
-
</select>
|
64 |
-
<input id="filter-value" type="text" placeholder="填写要筛选的内容" style="font-size:15px;border-color:grey;border-radius:5%">
|
65 |
-
<button id="filter-clear" style="font-size:15px;background:#00ccff;color:white;border-radius:15%;border-color:white;">清除筛选</button>
|
66 |
-
<button id="download-csv" style="font-size:15px;background:#00ccff;color:white;border-radius:15%;border-color:white;">下载CSV</button>
|
67 |
-
<button id="download-xlsx" style="font-size:15px;background:#00ccff;color:white;border-radius:15%;border-color:white;">下载XLSX</button>
|
68 |
-
<button id="download-html" style="font-size:15px;background:#00ccff;color:white;border-radius:15%;border-color:white;">下载HTML</button>
|
69 |
-
</div><script type="text/javascript">
|
70 |
-
var fieldEl = document.getElementById("filter-field");
|
71 |
-
var typeEl = document.getElementById("filter-type");
|
72 |
-
var valueEl = document.getElementById("filter-value");
|
73 |
-
function customFilter(data){
|
74 |
-
return data.car && data.rating < 3;
|
75 |
-
}function updateFilter(){
|
76 |
-
var filterVal = fieldEl.options[fieldEl.selectedIndex].value;
|
77 |
-
var typeVal = typeEl.options[typeEl.selectedIndex].value;
|
78 |
-
var filter = filterVal == "function" ? customFilter : filterVal;
|
79 |
-
if(filterVal == "function" ){
|
80 |
-
typeEl.disabled = true;
|
81 |
-
valueEl.disabled = true;
|
82 |
-
}else{
|
83 |
-
typeEl.disabled = false;
|
84 |
-
valueEl.disabled = false;
|
85 |
-
}
|
86 |
-
if(filterVal){
|
87 |
-
table.setFilter(filter,typeVal, valueEl.value);
|
88 |
-
}
|
89 |
-
}
|
90 |
-
document.getElementById("filter-field").addEventListener("change", updateFilter);
|
91 |
-
document.getElementById("filter-type").addEventListener("change", updateFilter);
|
92 |
-
document.getElementById("filter-value").addEventListener("keyup", updateFilter);
|
93 |
-
document.getElementById("filter-clear").addEventListener("click", function(){
|
94 |
-
fieldEl.value = "";
|
95 |
-
typeEl.value = "=";
|
96 |
-
valueEl.value = "";
|
97 |
-
table.clearFilter();
|
98 |
-
});
|
99 |
-
</script>
|
100 |
-
<script type="text/javascript">
|
101 |
-
var table = new Tabulator("#example-table", {
|
102 |
-
ajaxURL:"http://www.getmydata.com/now",
|
103 |
-
});
|
104 |
-
document.getElementById("download-csv").addEventListener("click", function(){
|
105 |
-
table.download("csv", "data.csv");
|
106 |
-
});
|
107 |
-
document.getElementById("download-xlsx").addEventListener("click", function(){
|
108 |
-
table.download("xlsx", "data.xlsx", {sheetName:"My Data"});
|
109 |
-
});
|
110 |
-
document.getElementById("download-html").addEventListener("click", function(){
|
111 |
-
table.download("html", "data.html", {style:true});
|
112 |
-
});
|
113 |
-
</script><div id="players" style="margin-left:16%;"></div>""" +
|
114 |
-
"""<script type="text/javascript">
|
115 |
-
var tabledata = [""" + ','.join(list(map(str, table_data))) + """];""" +
|
116 |
-
"""var table = new Tabulator("#players", {
|
117 |
-
height: 320,
|
118 |
-
data: tabledata,
|
119 |
-
layout: "fitDataTable",
|
120 |
-
movableRows:true,
|
121 |
-
resizableColumnFit:true,
|
122 |
-
pagination: "local",
|
123 |
-
paginationSize: 5,
|
124 |
-
tooltips: true,
|
125 |
-
columns: [""" + ','.join(list(map(str, column_setting))) + """],});</script></body></html>""",
|
126 |
-
height=height, width=width)
|
127 |
-
|
128 |
-
|
129 |
-
draw_table(df, 500, 1200)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/__init__.py
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : AI. @by PyCharm
|
4 |
-
# @File : __init__.py
|
5 |
-
# @Time : 2023/3/26 19:23
|
6 |
-
# @Author : betterme
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description :
|
10 |
-
|
11 |
-
from meutils.pipe import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/chart.py
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import graphviz as graphviz
|
3 |
-
|
4 |
-
# Create a graphlib graph object
|
5 |
-
graph = graphviz.Digraph()
|
6 |
-
graph.edge('run', 'intr')
|
7 |
-
graph.edge('intr', 'runbl')
|
8 |
-
graph.edge('runbl', 'run')
|
9 |
-
graph.edge('run', 'kernel')
|
10 |
-
graph.edge('kernel', 'zombie')
|
11 |
-
graph.edge('kernel', 'sleep')
|
12 |
-
graph.edge('kernel', 'runmem')
|
13 |
-
graph.edge('sleep', 'swap')
|
14 |
-
graph.edge('swap', 'runswap')
|
15 |
-
graph.edge('runswap', 'new')
|
16 |
-
graph.edge('runswap', 'runmem')
|
17 |
-
graph.edge('new', 'runmem')
|
18 |
-
graph.edge('sleep', 'runmem')
|
19 |
-
|
20 |
-
st.graphviz_chart(graph)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/demo-aggrid-width-center.py
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import pandas as pd
|
3 |
-
from st_aggrid import AgGrid
|
4 |
-
# from st_aggrid.grid_options_builder import GridOptionsBuilder
|
5 |
-
# from st_aggrid.shared import JsCode
|
6 |
-
# from st_aggrid.shared import GridUpdateMode
|
7 |
-
|
8 |
-
num=range(1,10)
|
9 |
-
data=pd.DataFrame({'A':num,'B':num,'C':num})
|
10 |
-
|
11 |
-
gridOptions = {
|
12 |
-
"columnDefs": [
|
13 |
-
{'headerName':'A列',"field": 'A','width':80,'cellStyle':{'color':'red','textAlign': 'center','font-weight':'bold'}},
|
14 |
-
#此外还可以设置minWidth 与maxWidth来控制宽度
|
15 |
-
{'headerName':'B列',"field": 'B','width':144,'cellStyle':{'color':'red','textAlign': 'center','font-weight':'bold'}},
|
16 |
-
{'headerName':'C列',"field": 'C','width':80,'cellStyle':{'color':'red','textAlign': 'center','font-weight':'bold'}}
|
17 |
-
],
|
18 |
-
"defaultColDef": {
|
19 |
-
"sortable": True,
|
20 |
-
"filter": False,
|
21 |
-
# "width":200 #可以设置各行的默认值
|
22 |
-
},
|
23 |
-
}
|
24 |
-
|
25 |
-
|
26 |
-
data_ag = AgGrid(data, # 数据
|
27 |
-
gridOptions=gridOptions, # 布局选项
|
28 |
-
# fit_columns_on_grid_load=True, #此参数会以列宽为比例自动铺满表格
|
29 |
-
allow_unsafe_jscode=True,
|
30 |
-
key=1,
|
31 |
-
custom_css={'.ag-header-cell-text':{'flex':'1','text-align':'center'}}) #此处是设置列名居中
|
32 |
-
|
33 |
-
#可配合st.columns来设置表格的整体宽度
|
34 |
-
c1,c2=st.columns(2)
|
35 |
-
with c1:
|
36 |
-
AgGrid(data, # 数据
|
37 |
-
gridOptions=gridOptions, # 布局选项
|
38 |
-
allow_unsafe_jscode=True,
|
39 |
-
key=2,
|
40 |
-
custom_css={'.ag-header-cell-text': {'flex': '1', 'text-align': 'center'}})
|
41 |
-
|
42 |
-
#铺满表格
|
43 |
-
c1,c2=st.columns(2)
|
44 |
-
with c1:
|
45 |
-
AgGrid(data, # 数据
|
46 |
-
gridOptions=gridOptions, # 布局选项
|
47 |
-
allow_unsafe_jscode=True,
|
48 |
-
fit_columns_on_grid_load=True,
|
49 |
-
key=3,
|
50 |
-
custom_css={'.ag-header-cell-text': {'flex': '1', 'text-align': 'center'}})
|
51 |
-
|
52 |
-
#铺满且居中
|
53 |
-
c1,c2,c3=st.columns([1,2,1])
|
54 |
-
with c2:
|
55 |
-
AgGrid(data, # 数据
|
56 |
-
gridOptions=gridOptions, # 布局选项
|
57 |
-
allow_unsafe_jscode=True,
|
58 |
-
fit_columns_on_grid_load=True,
|
59 |
-
key=4,
|
60 |
-
custom_css={'.ag-header-cell-text': {'flex': '1', 'text-align': 'center'}})
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/iframe.py
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : AI. @by PyCharm
|
4 |
-
# @File : iframe
|
5 |
-
# @Time : 2023/4/6 11:43
|
6 |
-
# @Author : betterme
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description :
|
10 |
-
|
11 |
-
from meutils.pipe import *
|
12 |
-
|
13 |
-
html = """
|
14 |
-
<!DOCTYPE html>
|
15 |
-
<html>
|
16 |
-
<head>
|
17 |
-
<title>My Website</title>
|
18 |
-
<style>
|
19 |
-
iframe {
|
20 |
-
width: 100%;
|
21 |
-
height: 100%;
|
22 |
-
border: none;
|
23 |
-
overflow: hidden;
|
24 |
-
}
|
25 |
-
</style>
|
26 |
-
</head>
|
27 |
-
<body>
|
28 |
-
<iframe src="http://www.hao123.com/"></iframe>
|
29 |
-
</body>
|
30 |
-
</html>
|
31 |
-
"""
|
32 |
-
|
33 |
-
import streamlit as st
|
34 |
-
|
35 |
-
|
36 |
-
st.write(html, unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/xxxx.py
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# @Project : Python.
|
4 |
-
# @File : xxxx
|
5 |
-
# @Time : 2022/12/7 上午9:04
|
6 |
-
# @Author : yuanjie
|
7 |
-
# @WeChat : meutils
|
8 |
-
# @Software : PyCharm
|
9 |
-
# @Description :
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/多轮对话.py
CHANGED
@@ -10,29 +10,7 @@
|
|
10 |
import streamlit as st
|
11 |
from streamlit_chat import message
|
12 |
|
13 |
-
|
14 |
-
def reply(input, history=None, reply_func=lambda input: f'{input}的答案', max_turns=3, container=None):
|
15 |
-
if history is None:
|
16 |
-
history = [] # [(query, response)]
|
17 |
-
|
18 |
-
if container is None:
|
19 |
-
container = st.container()
|
20 |
-
|
21 |
-
with container:
|
22 |
-
if len(history) > 0:
|
23 |
-
for i, (query, response) in enumerate(history[-max_turns + 1:]):
|
24 |
-
message(query, avatar_style="big-smile", is_user=True, key=str(i) + "_user")
|
25 |
-
message(response, avatar_style="bottts", is_user=False, key=str(i))
|
26 |
-
|
27 |
-
message(input, avatar_style="big-smile", is_user=True, key=str(len(history)) + "_user")
|
28 |
-
# st.write("AI正在回复:")
|
29 |
-
with st.empty():
|
30 |
-
response = reply_func(input)
|
31 |
-
message(response, avatar_style="bottts", is_user=False)
|
32 |
-
|
33 |
-
history.append((input, response))
|
34 |
-
return history
|
35 |
-
|
36 |
|
37 |
if __name__ == '__main__':
|
38 |
def display_previous_message(texts=None):
|
@@ -49,5 +27,4 @@ if __name__ == '__main__':
|
|
49 |
if st.button("发送", key="predict"):
|
50 |
with st.spinner("AI正在思考,请稍等........"):
|
51 |
history = st.session_state.get('state')
|
52 |
-
st.session_state["state"] =
|
53 |
-
print(st.session_state['state'])
|
|
|
10 |
import streamlit as st
|
11 |
from streamlit_chat import message
|
12 |
|
13 |
+
from appzoo.streamlit_app.utils import reply4input
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
if __name__ == '__main__':
|
16 |
def display_previous_message(texts=None):
|
|
|
27 |
if st.button("发送", key="predict"):
|
28 |
with st.spinner("AI正在思考,请稍等........"):
|
29 |
history = st.session_state.get('state')
|
30 |
+
st.session_state["state"] = reply4input(text, history, container=container)
|
|
requirements.txt
CHANGED
@@ -4,6 +4,9 @@ pyecharts
|
|
4 |
m2cgen
|
5 |
psutil
|
6 |
lac
|
|
|
|
|
|
|
7 |
|
8 |
# streamlit
|
9 |
streamlit=
|
|
|
4 |
m2cgen
|
5 |
psutil
|
6 |
lac
|
7 |
+
paddlepaddle
|
8 |
+
paddlenlp
|
9 |
+
torch
|
10 |
|
11 |
# streamlit
|
12 |
streamlit=
|