EndeavoringYoon commited on
Commit
5eecb3f
·
verified ·
1 Parent(s): f7b5f85

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +29 -26
src/streamlit_app.py CHANGED
@@ -12,29 +12,32 @@ forums](https://discuss.streamlit.io).
12
 
13
  In the meantime, below is an example of what you can do with just a few lines of code:
14
  """
15
-
16
- num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
17
- num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
18
-
19
- indices = np.linspace(0, 1, num_points)
20
- theta = 2 * np.pi * num_turns * indices
21
- radius = indices
22
-
23
- x = radius * np.cos(theta)
24
- y = radius * np.sin(theta)
25
-
26
- df = pd.DataFrame({
27
- "x": x,
28
- "y": y,
29
- "idx": indices,
30
- "rand": np.random.randn(num_points),
31
- })
32
-
33
- st.altair_chart(alt.Chart(df, height=700, width=700)
34
- .mark_point(filled=True)
35
- .encode(
36
- x=alt.X("x", axis=None),
37
- y=alt.Y("y", axis=None),
38
- color=alt.Color("idx", legend=None, scale=alt.Scale()),
39
- size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
40
- ))
 
 
 
 
12
 
13
  In the meantime, below is an example of what you can do with just a few lines of code:
14
  """
15
+ @st.cache_resource
16
+ def init_robot_system():
17
+ model_name='h64_32_z2_isoTrue_actvTanh_isoreg1e-07_nepoch1000_bs10'
18
+ ae, config = load_saved_model(model_name=model_name, device="cpu")
19
+ robot_chars = RobotCharacteristics()
20
+ label_data = np.load('./data/label.npy')
21
+ njnt_data = np.load('.data/njnt.npy')
22
+ indices_data = np.load('.data/indices.npy')
23
+ robot_chars.max_joints_per_group=njnt_data
24
+ return ae, robot_chars
25
+ motion_level = 'easy'
26
+ x_1 = np.load(f'./{motion_level}_motion/X1.npy')
27
+ x_2 = np.load(f'./{motion_level}_motion/X2.npy')
28
+ z_1 = np.load(f'./{motion_level}_motion/Z1.npy')
29
+
30
+
31
+
32
+ st.title("LEGO Latent Space Explorer")
33
+ z1 = st.slider("X", -10.0, 10.0)
34
+ z2 = st.slider("Y", -10.0, 10.0)
35
+
36
+ if st.button("Generate Design"):
37
+ ae, robot_chars = init_robot_system()
38
+ decode = ae.decode(th.tensor(easy_optimal,device=next(ae.parameters()).device,dtype=th.float32)).detach().numpy()
39
+ full_decode=robot_chars.build_full_interp_from_symmetric(interp_data_sym=decode,threshold=0.5)
40
+ data_to_visualize = robot_chars.convert_flat_interp_to_dict(full_decode)
41
+ clip = robot_chars.visualize_data_to_classify(data_to_visualize, save_video=True,vis=True, test = True, xml=True)
42
+ st.success("디자인 생성 완료!")
43
+ st.image("result.png") # 생성된 이미지 보여주기