HALU-HAL commited on
Commit
f9bbbde
·
1 Parent(s): 85902c8

add base code

Browse files
Files changed (3) hide show
  1. .github/workflows/run.yaml +20 -0
  2. README.md +14 -1
  3. app.py +60 -0
.github/workflows/run.yaml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Sync to Hugging Face hub
2
+ on:
3
+ push:
4
+ branches: [main]
5
+
6
+ # to run this workflow manually from the Actions tab
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ sync-to-hub:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v3
14
+ with:
15
+ fetch-depth: 0
16
+ lfs: true
17
+ - name: Push to hub
18
+ env:
19
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
20
+ run: git push --force https://MakiAi:$HF_TOKEN@huggingface.co/spaces/MakiAi/UE5_LAgentVisual main
README.md CHANGED
@@ -1 +1,14 @@
1
- # UE5_LAgentVisual
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: UE5 LAgentVisual
3
+ emoji: 🔥
4
+ colorFrom: pink
5
+ colorTo: yellow
6
+ sdk: streamlit
7
+ sdk_version: 1.28.2
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
+ # UE5_LAgentVisual
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 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.]+)"
8
+ data = {'Iteration': [], 'Avg Reward': [], 'Avg Return': [], 'Avg Value': [], 'Avg Episode Length': []}
9
+
10
+ for line in file_content:
11
+ match = re.search(pattern, line)
12
+ if match:
13
+ data['Iteration'].append(int(match.group(1)))
14
+ data['Avg Reward'].append(float(match.group(2)))
15
+ data['Avg Return'].append(float(match.group(3)))
16
+ data['Avg Value'].append(float(match.group(4)))
17
+ data['Avg Episode Length'].append(float(match.group(5)))
18
+
19
+ return pd.DataFrame(data)
20
+
21
+ def moving_average(data, window_size):
22
+ return data.rolling(window=window_size).mean()
23
+
24
+ def plot_metric(df, metric, window_size):
25
+ ma_df = moving_average(df, window_size)
26
+ fig = go.Figure()
27
+
28
+ # Add traces for raw data and moving average
29
+ fig.add_trace(go.Scatter(x=df['Iteration'], y=df[metric], mode='lines', name=metric))
30
+ fig.add_trace(go.Scatter(x=df['Iteration'], y=ma_df[metric], mode='lines', name=f'{metric} (MA)'))
31
+
32
+ # Update layout
33
+ fig.update_layout(title=f'{metric} and Moving Average',
34
+ xaxis_title='Iteration',
35
+ yaxis_title=metric)
36
+ return fig
37
+
38
+ # Streamlit app
39
+ st.title("UE5 Learning to Drive Data Visualizer")
40
+
41
+ uploaded_file = st.file_uploader("Upload your log file", type=["log"])
42
+ window_size = st.slider("Select window size for moving average", min_value=1, max_value=100, value=10)
43
+
44
+ if uploaded_file is not None:
45
+ file_content = uploaded_file.readlines()
46
+ file_content = [line.decode("utf-8") for line in file_content]
47
+
48
+ df = extract_data_from_log(file_content)
49
+
50
+ st.header("Average Reward")
51
+ st.plotly_chart(plot_metric(df, 'Avg Reward', window_size), use_container_width=True)
52
+
53
+ st.header("Average Return")
54
+ st.plotly_chart(plot_metric(df, 'Avg Return', window_size), use_container_width=True)
55
+
56
+ st.header("Average Value")
57
+ st.plotly_chart(plot_metric(df, 'Avg Value', window_size), use_container_width=True)
58
+
59
+ st.header("Average Episode Length")
60
+ st.plotly_chart(plot_metric(df, 'Avg Episode Length', window_size), use_container_width=True)