vimmoos@Thor commited on
Commit
4e7a203
·
1 Parent(s): 09a4b49

some minor changes

Browse files
Files changed (2) hide show
  1. app.py +34 -0
  2. udrl/app/sim.py +6 -3
app.py CHANGED
@@ -11,3 +11,37 @@ pg = st.navigation(nav)
11
 
12
  add_page_title(pg)
13
  pg.run()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  add_page_title(pg)
13
  pg.run()
14
+
15
+ hide_streamlit_style = """
16
+ <style>
17
+ div[data-testid="stToolbar"] {
18
+ visibility: hidden;
19
+ height: 0%;
20
+ position: fixed;
21
+ }
22
+ div[data-testid="stDecoration"] {
23
+ visibility: hidden;
24
+ height: 0%;
25
+ position: fixed;
26
+ }
27
+ div[data-testid="stStatusWidget"] {
28
+ visibility: hidden;
29
+ height: 0%;
30
+ position: fixed;
31
+ }
32
+ #MainMenu {
33
+ visibility: hidden;
34
+ height: 0%;
35
+ }
36
+ header {
37
+ visibility: hidden;
38
+ height: 0%;
39
+ }
40
+ footer {
41
+ visibility: hidden;
42
+ height: 0%;
43
+ }
44
+ </style>
45
+ """
46
+
47
+ st.markdown(hide_streamlit_style, unsafe_allow_html=True)
udrl/app/sim.py CHANGED
@@ -45,6 +45,7 @@ class State(BaseState):
45
  feature_importances: List[float] = field(init=False, default_factory=list)
46
  env: gym.Env = field(init=False)
47
  frame: np.array = field(init=False, default=None)
 
48
  obs: np.array = field(init=False)
49
 
50
  def __post_init__(self):
@@ -62,6 +63,8 @@ def next_epoch(state: State):
62
 
63
  def update_frame(state: State):
64
  state.frame = resize(state.env.render(), (400, 600, 3))
 
 
65
 
66
 
67
  def reset_env(state: State):
@@ -240,7 +243,7 @@ def make_viz(state):
240
  scale=alt.Scale(domain=[-10, 30]),
241
  ),
242
  y="index:O",
243
- color="index:N",
244
  )
245
  .properties(height=int(val))
246
  )
@@ -326,9 +329,9 @@ def make_metrics(state: State):
326
  with col1:
327
  st.metric("Epoch", state.epoch)
328
  with col2:
329
- st.metric("Cum Reward", state.reward)
330
  with col3:
331
- st.metric("Desired Return", state.desired_return)
332
  with col4:
333
  st.metric("Desired Horizon", state.desired_horizon)
334
 
 
45
  feature_importances: List[float] = field(init=False, default_factory=list)
46
  env: gym.Env = field(init=False)
47
  frame: np.array = field(init=False, default=None)
48
+ prev_frame: np.array = field(init=False, default=None)
49
  obs: np.array = field(init=False)
50
 
51
  def __post_init__(self):
 
63
 
64
  def update_frame(state: State):
65
  state.frame = resize(state.env.render(), (400, 600, 3))
66
+ while len(state.frame) < 1:
67
+ state.frame = resize(state.env.render(), (400, 600, 3))
68
 
69
 
70
  def reset_env(state: State):
 
243
  scale=alt.Scale(domain=[-10, 30]),
244
  ),
245
  y="index:O",
246
+ color=alt.Color("index:N", legend=None),
247
  )
248
  .properties(height=int(val))
249
  )
 
329
  with col1:
330
  st.metric("Epoch", state.epoch)
331
  with col2:
332
+ st.metric("Cum Reward", f"{state.reward:.2f}")
333
  with col3:
334
+ st.metric("Desired Return", f"{state.desired_return:.2f}")
335
  with col4:
336
  st.metric("Desired Horizon", state.desired_horizon)
337