Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,22 @@ import streamlit as st
|
|
2 |
import re
|
3 |
import pandas as pd
|
4 |
import plotly.graph_objects as go
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
def extract_data_from_log(file_content):
|
7 |
pattern = r"Iter:\s+(\d+)\s+\|\s+Avg Reward:\s+([-\d.]+)\s+\|\s+Avg Return:\s+([-\d.]+)\s+\|\s+Avg Value:\s+([-\d.]+)\s+\|\s+Avg Episode Length:\s+([-\d.]+)"
|
@@ -38,25 +54,30 @@ def plot_metric(df, metric, window_size):
|
|
38 |
# Streamlit app
|
39 |
st.title("UE5 Learning to Drive Data Visualizer")
|
40 |
|
|
|
|
|
|
|
41 |
# Sidebar for inputs
|
42 |
st.sidebar.header("Input Settings")
|
43 |
uploaded_file = st.sidebar.file_uploader("Upload your log file", type=["log"])
|
44 |
window_size = st.sidebar.slider("Select window size for moving average", min_value=1, max_value=500, value=10)
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
51 |
|
52 |
-
|
53 |
-
|
54 |
|
55 |
-
|
56 |
-
|
57 |
|
58 |
-
|
59 |
-
|
60 |
|
61 |
-
|
62 |
-
|
|
|
2 |
import re
|
3 |
import pandas as pd
|
4 |
import plotly.graph_objects as go
|
5 |
+
from PIL import Image
|
6 |
+
|
7 |
+
|
8 |
+
image = Image.open('./image/RLcar2.png')
|
9 |
+
st.set_page_config(
|
10 |
+
page_title="LAgent Visualizer",
|
11 |
+
page_icon=image,
|
12 |
+
layout="wide",
|
13 |
+
initial_sidebar_state="auto",
|
14 |
+
menu_items={
|
15 |
+
'Get Help': 'https://twitter.com/hAru_mAki_ch',
|
16 |
+
'Report a bug': "https://twitter.com/hAru_mAki_ch",
|
17 |
+
'About': """
|
18 |
+
# UE5 Learning to Drive Data Visualizer
|
19 |
+
"""
|
20 |
+
})
|
21 |
|
22 |
def extract_data_from_log(file_content):
|
23 |
pattern = r"Iter:\s+(\d+)\s+\|\s+Avg Reward:\s+([-\d.]+)\s+\|\s+Avg Return:\s+([-\d.]+)\s+\|\s+Avg Value:\s+([-\d.]+)\s+\|\s+Avg Episode Length:\s+([-\d.]+)"
|
|
|
54 |
# Streamlit app
|
55 |
st.title("UE5 Learning to Drive Data Visualizer")
|
56 |
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
# Sidebar for inputs
|
61 |
st.sidebar.header("Input Settings")
|
62 |
uploaded_file = st.sidebar.file_uploader("Upload your log file", type=["log"])
|
63 |
window_size = st.sidebar.slider("Select window size for moving average", min_value=1, max_value=500, value=10)
|
64 |
|
65 |
+
# メインコンテナを作成し、グラフをこのコンテナ内に表示します。
|
66 |
+
with st.container():
|
67 |
+
if uploaded_file is not None:
|
68 |
+
file_content = uploaded_file.readlines()
|
69 |
+
file_content = [line.decode("utf-8") for line in file_content]
|
70 |
+
|
71 |
+
df = extract_data_from_log(file_content)
|
72 |
|
73 |
+
st.header("Average Reward")
|
74 |
+
st.plotly_chart(plot_metric(df, 'Avg Reward', window_size), use_container_width=True)
|
75 |
|
76 |
+
st.header("Average Return")
|
77 |
+
st.plotly_chart(plot_metric(df, 'Avg Return', window_size), use_container_width=True)
|
78 |
|
79 |
+
st.header("Average Value")
|
80 |
+
st.plotly_chart(plot_metric(df, 'Avg Value', window_size), use_container_width=True)
|
81 |
|
82 |
+
st.header("Average Episode Length")
|
83 |
+
st.plotly_chart(plot_metric(df, 'Avg Episode Length', window_size), use_container_width=True)
|