Spaces:
Running
Running
Update src/streamlit_app.py
Browse files- 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 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
st.
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 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") # 생성된 이미지 보여주기
|