Spaces:
Runtime error
Runtime error
yuanjie
commited on
Commit
ยท
144a16c
1
Parent(s):
a63435d
update
Browse files- pages/0_๐น_Animation_Demo.py +0 -84
- pages/1__๏ฃฟ_็ๆง.py +0 -6
- pages/1_๐_Plotting_Demo.py +0 -56
- pages/1_๐ฅ_้ฃๅๅฎๅ จๆฏ่ตๆไบค.py +24 -0
- pages/2_๐_Mapping_Demo.py +0 -119
- pages/3_๐_DataFrame_Demo.py +0 -78
- pages/{4_๐ฅ_Torch.py โ 66_๐ฅ_Torch.py} +0 -0
- requirements.txt +1 -0
- result.txt +0 -0
pages/0_๐น_Animation_Demo.py
DELETED
@@ -1,84 +0,0 @@
|
|
1 |
-
# Copyright 2018-2022 Streamlit Inc.
|
2 |
-
#
|
3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
-
# you may not use this file except in compliance with the License.
|
5 |
-
# You may obtain a copy of the License at
|
6 |
-
#
|
7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
-
#
|
9 |
-
# Unless required by applicable law or agreed to in writing, software
|
10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
-
# See the License for the specific language governing permissions and
|
13 |
-
# limitations under the License.
|
14 |
-
|
15 |
-
import streamlit as st
|
16 |
-
import inspect
|
17 |
-
import textwrap
|
18 |
-
import numpy as np
|
19 |
-
from typing import Any
|
20 |
-
from streamlit.hello.utils import show_code
|
21 |
-
|
22 |
-
|
23 |
-
def animation_demo():
|
24 |
-
|
25 |
-
# Interactive Streamlit elements, like these sliders, return their value.
|
26 |
-
# This gives you an extremely simple interaction model.
|
27 |
-
iterations = st.sidebar.slider("Level of detail", 2, 20, 10, 1)
|
28 |
-
separation = st.sidebar.slider("Separation", 0.7, 2.0, 0.7885)
|
29 |
-
|
30 |
-
# Non-interactive elements return a placeholder to their location
|
31 |
-
# in the app. Here we're storing progress_bar to update it later.
|
32 |
-
progress_bar = st.sidebar.progress(0)
|
33 |
-
|
34 |
-
# These two elements will be filled in later, so we create a placeholder
|
35 |
-
# for them using st.empty()
|
36 |
-
frame_text = st.sidebar.empty()
|
37 |
-
image = st.empty()
|
38 |
-
|
39 |
-
m, n, s = 960, 640, 400
|
40 |
-
x = np.linspace(-m / s, m / s, num=m).reshape((1, m))
|
41 |
-
y = np.linspace(-n / s, n / s, num=n).reshape((n, 1))
|
42 |
-
|
43 |
-
for frame_num, a in enumerate(np.linspace(0.0, 4 * np.pi, 100)):
|
44 |
-
# Here were setting value for these two elements.
|
45 |
-
progress_bar.progress(frame_num)
|
46 |
-
frame_text.text("Frame %i/100" % (frame_num + 1))
|
47 |
-
|
48 |
-
# Performing some fractal wizardry.
|
49 |
-
c = separation * np.exp(1j * a)
|
50 |
-
Z = np.tile(x, (n, 1)) + 1j * np.tile(y, (1, m))
|
51 |
-
C = np.full((n, m), c)
|
52 |
-
M: Any = np.full((n, m), True, dtype=bool)
|
53 |
-
N = np.zeros((n, m))
|
54 |
-
|
55 |
-
for i in range(iterations):
|
56 |
-
Z[M] = Z[M] * Z[M] + C[M]
|
57 |
-
M[np.abs(Z) > 2] = False
|
58 |
-
N[M] = i
|
59 |
-
|
60 |
-
# Update the image placeholder by calling the image() function on it.
|
61 |
-
image.image(1.0 - (N / N.max()), use_column_width=True)
|
62 |
-
|
63 |
-
# We clear elements by calling empty on them.
|
64 |
-
progress_bar.empty()
|
65 |
-
frame_text.empty()
|
66 |
-
|
67 |
-
# Streamlit widgets automatically run the script from top to bottom. Since
|
68 |
-
# this button is not connected to any other logic, it just causes a plain
|
69 |
-
# rerun.
|
70 |
-
st.button("Re-run")
|
71 |
-
|
72 |
-
|
73 |
-
st.set_page_config(page_title="Animation Demo", page_icon="๐น")
|
74 |
-
st.markdown("# Animation Demo")
|
75 |
-
st.sidebar.header("Animation Demo")
|
76 |
-
st.write(
|
77 |
-
"""This app shows how you can use Streamlit to build cool animations.
|
78 |
-
It displays an animated fractal based on the the Julia Set. Use the slider
|
79 |
-
to tune different parameters."""
|
80 |
-
)
|
81 |
-
|
82 |
-
animation_demo()
|
83 |
-
|
84 |
-
show_code(animation_demo)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/1__๏ฃฟ_็ๆง.py
DELETED
@@ -1,6 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
|
3 |
-
col1, col2, col3 = st.columns(3)
|
4 |
-
col1.metric("Temperature", "70 ยฐF", "1.2 ยฐF")
|
5 |
-
col2.metric("Wind", "9 mph", "-8%")
|
6 |
-
col3.metric("Humidity", "86%", "4%")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/1_๐_Plotting_Demo.py
DELETED
@@ -1,56 +0,0 @@
|
|
1 |
-
# Copyright 2018-2022 Streamlit Inc.
|
2 |
-
#
|
3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
-
# you may not use this file except in compliance with the License.
|
5 |
-
# You may obtain a copy of the License at
|
6 |
-
#
|
7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
-
#
|
9 |
-
# Unless required by applicable law or agreed to in writing, software
|
10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
-
# See the License for the specific language governing permissions and
|
13 |
-
# limitations under the License.
|
14 |
-
|
15 |
-
import streamlit as st
|
16 |
-
import inspect
|
17 |
-
import textwrap
|
18 |
-
import time
|
19 |
-
import numpy as np
|
20 |
-
from streamlit.hello.utils import show_code
|
21 |
-
|
22 |
-
|
23 |
-
def plotting_demo():
|
24 |
-
progress_bar = st.sidebar.progress(0)
|
25 |
-
status_text = st.sidebar.empty()
|
26 |
-
last_rows = np.random.randn(1, 1)
|
27 |
-
chart = st.line_chart(last_rows)
|
28 |
-
|
29 |
-
for i in range(1, 101):
|
30 |
-
new_rows = last_rows[-1, :] + np.random.randn(5, 1).cumsum(axis=0)
|
31 |
-
status_text.text("%i%% Complete" % i)
|
32 |
-
chart.add_rows(new_rows)
|
33 |
-
progress_bar.progress(i)
|
34 |
-
last_rows = new_rows
|
35 |
-
time.sleep(0.05)
|
36 |
-
|
37 |
-
progress_bar.empty()
|
38 |
-
|
39 |
-
# Streamlit widgets automatically run the script from top to bottom. Since
|
40 |
-
# this button is not connected to any other logic, it just causes a plain
|
41 |
-
# rerun.
|
42 |
-
st.button("Re-run")
|
43 |
-
|
44 |
-
|
45 |
-
st.set_page_config(page_title="Plotting Demo", page_icon="๐")
|
46 |
-
st.markdown("# Plotting Demo")
|
47 |
-
st.sidebar.header("Plotting Demo")
|
48 |
-
st.write(
|
49 |
-
"""This demo illustrates a combination of plotting and animation with
|
50 |
-
Streamlit. We're generating a bunch of random numbers in a loop for around
|
51 |
-
5 seconds. Enjoy!"""
|
52 |
-
)
|
53 |
-
|
54 |
-
plotting_demo()
|
55 |
-
|
56 |
-
show_code(plotting_demo)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/1_๐ฅ_้ฃๅๅฎๅ
จๆฏ่ตๆไบค.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import paramiko
|
2 |
+
from meutils.pipe import *
|
3 |
+
import streamlit as st
|
4 |
+
|
5 |
+
host = '222.76.203.180' # ไธปๆบ
|
6 |
+
port = 57891 # ็ซฏๅฃ
|
7 |
+
sf = paramiko.Transport((host, port))
|
8 |
+
|
9 |
+
username = st.text_input('username', 'comp_5154') # ็จๆทๅ
|
10 |
+
password = st.text_input('password') # ๅฏ็
|
11 |
+
|
12 |
+
|
13 |
+
uploaded_file = st.file_uploader("ไธไผ ๆไปถ")
|
14 |
+
if uploaded_file is not None and password:
|
15 |
+
df = pd.read_csv(uploaded_file, '|', header=0)
|
16 |
+
df.to_csv('result.txt', index=False)
|
17 |
+
|
18 |
+
sf.connect(username=username, password=password)
|
19 |
+
sftp = paramiko.SFTPClient.from_transport(sf)
|
20 |
+
|
21 |
+
_ = sftp.put('result.txt', '/result/result.txt')
|
22 |
+
st.write(_)
|
23 |
+
|
24 |
+
st.write(df)
|
pages/2_๐_Mapping_Demo.py
DELETED
@@ -1,119 +0,0 @@
|
|
1 |
-
# Copyright 2018-2022 Streamlit Inc.
|
2 |
-
#
|
3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
-
# you may not use this file except in compliance with the License.
|
5 |
-
# You may obtain a copy of the License at
|
6 |
-
#
|
7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
-
#
|
9 |
-
# Unless required by applicable law or agreed to in writing, software
|
10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
-
# See the License for the specific language governing permissions and
|
13 |
-
# limitations under the License.
|
14 |
-
|
15 |
-
import streamlit as st
|
16 |
-
import inspect
|
17 |
-
import textwrap
|
18 |
-
import pandas as pd
|
19 |
-
import pydeck as pdk
|
20 |
-
from streamlit.hello.utils import show_code
|
21 |
-
|
22 |
-
|
23 |
-
from urllib.error import URLError
|
24 |
-
|
25 |
-
|
26 |
-
def mapping_demo():
|
27 |
-
@st.cache
|
28 |
-
def from_data_file(filename):
|
29 |
-
url = (
|
30 |
-
"http://raw.githubusercontent.com/streamlit/"
|
31 |
-
"example-data/master/hello/v1/%s" % filename
|
32 |
-
)
|
33 |
-
return pd.read_json(url)
|
34 |
-
|
35 |
-
try:
|
36 |
-
ALL_LAYERS = {
|
37 |
-
"Bike Rentals": pdk.Layer(
|
38 |
-
"HexagonLayer",
|
39 |
-
data=from_data_file("bike_rental_stats.json"),
|
40 |
-
get_position=["lon", "lat"],
|
41 |
-
radius=200,
|
42 |
-
elevation_scale=4,
|
43 |
-
elevation_range=[0, 1000],
|
44 |
-
extruded=True,
|
45 |
-
),
|
46 |
-
"Bart Stop Exits": pdk.Layer(
|
47 |
-
"ScatterplotLayer",
|
48 |
-
data=from_data_file("bart_stop_stats.json"),
|
49 |
-
get_position=["lon", "lat"],
|
50 |
-
get_color=[200, 30, 0, 160],
|
51 |
-
get_radius="[exits]",
|
52 |
-
radius_scale=0.05,
|
53 |
-
),
|
54 |
-
"Bart Stop Names": pdk.Layer(
|
55 |
-
"TextLayer",
|
56 |
-
data=from_data_file("bart_stop_stats.json"),
|
57 |
-
get_position=["lon", "lat"],
|
58 |
-
get_text="name",
|
59 |
-
get_color=[0, 0, 0, 200],
|
60 |
-
get_size=15,
|
61 |
-
get_alignment_baseline="'bottom'",
|
62 |
-
),
|
63 |
-
"Outbound Flow": pdk.Layer(
|
64 |
-
"ArcLayer",
|
65 |
-
data=from_data_file("bart_path_stats.json"),
|
66 |
-
get_source_position=["lon", "lat"],
|
67 |
-
get_target_position=["lon2", "lat2"],
|
68 |
-
get_source_color=[200, 30, 0, 160],
|
69 |
-
get_target_color=[200, 30, 0, 160],
|
70 |
-
auto_highlight=True,
|
71 |
-
width_scale=0.0001,
|
72 |
-
get_width="outbound",
|
73 |
-
width_min_pixels=3,
|
74 |
-
width_max_pixels=30,
|
75 |
-
),
|
76 |
-
}
|
77 |
-
st.sidebar.markdown("### Map Layers")
|
78 |
-
selected_layers = [
|
79 |
-
layer
|
80 |
-
for layer_name, layer in ALL_LAYERS.items()
|
81 |
-
if st.sidebar.checkbox(layer_name, True)
|
82 |
-
]
|
83 |
-
if selected_layers:
|
84 |
-
st.pydeck_chart(
|
85 |
-
pdk.Deck(
|
86 |
-
map_style="mapbox://styles/mapbox/light-v9",
|
87 |
-
initial_view_state={
|
88 |
-
"latitude": 37.76,
|
89 |
-
"longitude": -122.4,
|
90 |
-
"zoom": 11,
|
91 |
-
"pitch": 50,
|
92 |
-
},
|
93 |
-
layers=selected_layers,
|
94 |
-
)
|
95 |
-
)
|
96 |
-
else:
|
97 |
-
st.error("Please choose at least one layer above.")
|
98 |
-
except URLError as e:
|
99 |
-
st.error(
|
100 |
-
"""
|
101 |
-
**This demo requires internet access.**
|
102 |
-
Connection error: %s
|
103 |
-
"""
|
104 |
-
% e.reason
|
105 |
-
)
|
106 |
-
|
107 |
-
|
108 |
-
st.set_page_config(page_title="Mapping Demo", page_icon="๐")
|
109 |
-
st.markdown("# Mapping Demo")
|
110 |
-
st.sidebar.header("Mapping Demo")
|
111 |
-
st.write(
|
112 |
-
"""This demo shows how to use
|
113 |
-
[`st.pydeck_chart`](https://docs.streamlit.io/library/api-reference/charts/st.pydeck_chart)
|
114 |
-
to display geospatial data."""
|
115 |
-
)
|
116 |
-
|
117 |
-
mapping_demo()
|
118 |
-
|
119 |
-
show_code(mapping_demo)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/3_๐_DataFrame_Demo.py
DELETED
@@ -1,78 +0,0 @@
|
|
1 |
-
# Copyright 2018-2022 Streamlit Inc.
|
2 |
-
#
|
3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
-
# you may not use this file except in compliance with the License.
|
5 |
-
# You may obtain a copy of the License at
|
6 |
-
#
|
7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
-
#
|
9 |
-
# Unless required by applicable law or agreed to in writing, software
|
10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
-
# See the License for the specific language governing permissions and
|
13 |
-
# limitations under the License.
|
14 |
-
|
15 |
-
import streamlit as st
|
16 |
-
import inspect
|
17 |
-
import textwrap
|
18 |
-
import pandas as pd
|
19 |
-
import altair as alt
|
20 |
-
from streamlit.hello.utils import show_code
|
21 |
-
|
22 |
-
from urllib.error import URLError
|
23 |
-
|
24 |
-
|
25 |
-
def data_frame_demo():
|
26 |
-
@st.cache
|
27 |
-
def get_UN_data():
|
28 |
-
AWS_BUCKET_URL = "http://streamlit-demo-data.s3-us-west-2.amazonaws.com"
|
29 |
-
df = pd.read_csv(AWS_BUCKET_URL + "/agri.csv.gz")
|
30 |
-
return df.set_index("Region")
|
31 |
-
|
32 |
-
try:
|
33 |
-
df = get_UN_data()
|
34 |
-
countries = st.multiselect(
|
35 |
-
"Choose countries", list(df.index), ["China", "United States of America"]
|
36 |
-
)
|
37 |
-
if not countries:
|
38 |
-
st.error("Please select at least one country.")
|
39 |
-
else:
|
40 |
-
data = df.loc[countries]
|
41 |
-
data /= 1000000.0
|
42 |
-
st.write("### Gross Agricultural Production ($B)", data.sort_index())
|
43 |
-
|
44 |
-
data = data.T.reset_index()
|
45 |
-
data = pd.melt(data, id_vars=["index"]).rename(
|
46 |
-
columns={"index": "year", "value": "Gross Agricultural Product ($B)"}
|
47 |
-
)
|
48 |
-
chart = (
|
49 |
-
alt.Chart(data)
|
50 |
-
.mark_area(opacity=0.3)
|
51 |
-
.encode(
|
52 |
-
x="year:T",
|
53 |
-
y=alt.Y("Gross Agricultural Product ($B):Q", stack=None),
|
54 |
-
color="Region:N",
|
55 |
-
)
|
56 |
-
)
|
57 |
-
st.altair_chart(chart, use_container_width=True)
|
58 |
-
except URLError as e:
|
59 |
-
st.error(
|
60 |
-
"""
|
61 |
-
**This demo requires internet access.**
|
62 |
-
Connection error: %s
|
63 |
-
"""
|
64 |
-
% e.reason
|
65 |
-
)
|
66 |
-
|
67 |
-
|
68 |
-
st.set_page_config(page_title="DataFrame Demo", page_icon="๐")
|
69 |
-
st.markdown("# DataFrame Demo")
|
70 |
-
st.sidebar.header("DataFrame Demo")
|
71 |
-
st.write(
|
72 |
-
"""This demo shows how to use `st.write` to visualize Pandas DataFrames.
|
73 |
-
(Data courtesy of the [UN Data Explorer](http://data.un.org/Explorer.aspx).)"""
|
74 |
-
)
|
75 |
-
|
76 |
-
data_frame_demo()
|
77 |
-
|
78 |
-
show_code(data_frame_demo)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/{4_๐ฅ_Torch.py โ 66_๐ฅ_Torch.py}
RENAMED
File without changes
|
requirements.txt
CHANGED
@@ -1 +1,2 @@
|
|
1 |
meutils
|
|
|
|
1 |
meutils
|
2 |
+
paramiko
|
result.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|