mathildekappel commited on
Commit
5bfb237
·
1 Parent(s): b7ed086

fancy visual

Browse files
000_slider_0/000_slider_0_Gen175_Pop10000_baseline_MAP-Elite-Explore_APGen_initState_max_v0/Archive_size_Object_000_JointNature_slider_Item0_Generation_175_PopSize_10000_baseline_MAP-Elite-Explore_APGen_initState_max_v0.csv ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 0,9962
2
+ 2,17677,18,94,17677
3
+ 3,23849,48,222,23849
4
+ 4,29146,75,292,29146
5
+ 5,33711,91,344,33711
6
+ 6,37777,113,383,37777
7
+ 7,41270,133,434,41270
8
+ 8,44525,158,492,44525
9
+ 9,47573,189,535,47573
10
+ 10,50366,219,585,50366
11
+ 11,53023,243,616,53023
12
+ 12,55401,268,656,55401
13
+ 13,57698,286,685,57698
14
+ 14,59876,307,728,59876
15
+ 15,61965,336,763,61965
16
+ 16,63924,358,804,63924
17
+ 17,65819,375,834,65819
18
+ 18,67641,408,880,67641
19
+ 19,69359,424,911,69359
20
+ 20,70999,455,949,70999
21
+ 21,72565,484,994,72565
22
+ 22,74088,518,1036,74088
23
+ 23,75590,544,1083,75590
24
+ 24,76962,571,1118,76962
25
+ 25,78368,602,1162,78368
26
+ 26,79724,633,1211,79724
27
+ 27,81017,661,1244,81017
28
+ 28,82272,691,1276,82272
29
+ 29,83486,723,1318,83486
30
+ 30,84761,744,1346,84761
31
+ 31,85906,765,1377,85906
32
+ 32,87099,795,1413,87099
33
+ 33,88246,823,1453,88246
34
+ 34,89403,842,1485,89403
35
+ 35,90540,864,1509,90540
36
+ 36,91556,884,1545,91556
37
+ 37,92637,906,1575,92637
38
+ 38,93656,925,1599,93656
39
+ 39,94678,947,1630,94678
40
+ 40,95672,969,1647,95672
41
+ 41,96625,990,1674,96625
42
+ 42,97624,1008,1714,97624
43
+ 43,98589,1018,1730,98589
44
+ 44,99560,1040,1759,99560
45
+ 45,100488,1060,1789,100488
46
+ 46,101410,1081,1815,101410
47
+ 47,102338,1094,1838,102338
48
+ 48,103213,1116,1869,103213
49
+ 49,104046,1134,1897,104046
50
+ 50,104957,1158,1923,104957
51
+ 51,105815,1182,1954,105815
52
+ 52,106684,1201,1974,106684
53
+ 53,107458,1222,2000,107458
54
+ 54,108287,1250,2030,108287
55
+ 55,109081,1270,2060,109081
56
+ 56,109887,1305,2101,109887
57
+ 57,110711,1322,2122,110711
58
+ 58,111442,1340,2143,111442
59
+ 59,112251,1357,2174,112251
60
+ 60,112986,1374,2190,112986
61
+ 61,113746,1392,2207,113746
62
+ 62,114483,1406,2226,114483
63
+ 63,115211,1427,2247,115211
64
+ 64,115946,1448,2268,115946
65
+ 65,116657,1469,2294,116657
66
+ 66,117387,1482,2313,117387
67
+ 67,118027,1508,2343,118027
68
+ 68,118762,1526,2359,118762
69
+ 69,119399,1541,2378,119399
70
+ 70,120026,1559,2402,120026
71
+ 71,120711,1573,2420,120711
72
+ 72,121323,1597,2454,121323
73
+ 73,121950,1615,2471,121950
74
+ 74,122603,1631,2485,122603
75
+ 75,123216,1648,2509,123216
76
+ 76,123836,1666,2525,123836
77
+ 77,124446,1687,2543,124446
78
+ 78,125024,1709,2569,125024
79
+ 79,125625,1716,2580,125625
80
+ 80,126238,1735,2599,126238
81
+ 81,126837,1754,2627,126837
82
+ 82,127429,1769,2661,127429
83
+ 83,127973,1782,2683,127973
84
+ 84,128532,1795,2701,128532
85
+ 85,129101,1807,2717,129101
86
+ 86,129677,1828,2738,129677
87
+ 87,130213,1844,2752,130213
88
+ 88,130750,1863,2779,130750
89
+ 89,131262,1869,2790,131262
90
+ 90,131805,1889,2815,131805
91
+ 91,132338,1903,2835,132338
92
+ 92,132851,1915,2849,132851
93
+ 93,133383,1928,2864,133383
94
+ 94,133830,1955,2889,133830
95
+ 95,134326,1969,2901,134326
96
+ 96,134839,1991,2925,134839
97
+ 97,135333,2008,2947,135333
98
+ 98,135818,2029,2966,135818
99
+ 99,136319,2051,2991,136319
100
+ 100,136828,2073,3015,136828
101
+ 101,137340,2091,3039,137340
102
+ 102,137802,2113,3062,137802
103
+ 103,138241,2132,3082,138241
104
+ 104,138657,2154,3102,138657
105
+ 105,139096,2170,3133,139096
106
+ 106,139526,2195,3153,139526
107
+ 107,139935,2203,3167,139935
108
+ 108,140368,2215,3183,140368
109
+ 109,140803,2230,3202,140803
110
+ 110,141228,2247,3224,141228
111
+ 111,141672,2260,3242,141672
112
+ 112,142101,2280,3277,142101
113
+ 113,142508,2291,3292,142508
114
+ 114,142934,2307,3309,142934
115
+ 115,143342,2334,3334,143342
116
+ 116,143710,2342,3346,143710
117
+ 117,144100,2352,3359,144100
118
+ 118,144494,2375,3380,144494
119
+ 119,144894,2391,3402,144894
120
+ 120,145267,2415,3424,145267
121
+ 121,145652,2429,3441,145652
122
+ 122,145993,2449,3461,145993
123
+ 123,146371,2465,3493,146371
124
+ 124,146751,2474,3503,146751
125
+ 125,147105,2498,3534,147105
126
+ 126,147470,2515,3558,147470
127
+ 127,147828,2534,3578,147828
128
+ 128,148157,2547,3596,148157
129
+ 129,148485,2565,3623,148485
130
+ 130,148857,2573,3631,148857
131
+ 131,149179,2593,3657,149179
132
+ 132,149538,2612,3680,149538
133
+ 133,149864,2630,3705,149864
134
+ 134,150207,2645,3727,150207
135
+ 135,150546,2665,3751,150546
136
+ 136,150896,2684,3772,150896
137
+ 137,151214,2708,3791,151214
138
+ 138,151504,2726,3812,151504
139
+ 139,151814,2739,3830,151814
140
+ 140,152112,2759,3859,152112
141
+ 141,152439,2778,3880,152439
142
+ 142,152732,2799,3904,152732
143
+ 143,153004,2809,3922,153004
144
+ 144,153322,2829,3945,153322
145
+ 145,153642,2837,3962,153642
146
+ 146,153915,2841,3975,153915
147
+ 147,154216,2856,3996,154216
148
+ 148,154504,2870,4014,154504
149
+ 149,154788,2888,4038,154788
150
+ 150,155097,2903,4053,155097
151
+ 151,155351,2924,4081,155351
152
+ 152,155617,2938,4097,155617
153
+ 153,155904,2956,4116,155904
154
+ 154,156196,2974,4141,156196
155
+ 155,156466,2990,4162,156466
156
+ 156,156726,3016,4191,156726
157
+ 157,156990,3036,4210,156990
158
+ 158,157266,3050,4239,157266
159
+ 159,157512,3070,4260,157512
160
+ 160,157799,3087,4281,157799
161
+ 161,158065,3104,4304,158065
162
+ 162,158280,3121,4320,158280
163
+ 163,158550,3144,4341,158550
164
+ 164,158801,3159,4366,158801
165
+ 165,159036,3175,4386,159036
166
+ 166,159286,3190,4403,159286
167
+ 167,159546,3209,4430,159546
168
+ 168,159767,3228,4454,159767
169
+ 169,160010,3253,4479,160010
170
+ 170,160251,3277,4510,160251
171
+ 171,160488,3295,4527,160488
172
+ 172,160738,3313,4555,160738
173
+ 173,160972,3340,4590,160972
174
+ 174,161225,3369,4613,161225
175
+ 175,161456,3379,4633,161456
000_slider_0/000_slider_0_Gen175_Pop10000_baseline_MAP-Elite-Explore_APGen_initState_max_v0/Archive_size_Object_000_JointNature_slider_Item0_Generation_175_PopSize_10000_baseline_MAP-Elite-Explore_APGen_initState_max_v0.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7075fc6638e9a4aa1425118ecdde503cbf2b8218aead75c5d7cc236d4d0a41fc
3
+ size 25495
000_slider_0/000_slider_0_Gen175_Pop10000_baseline_MAP-Elite-Explore_APGen_initState_max_v0/Archive_space_Object_000_JointNature_slider_Item0_Generation_175_PopSize_10000_baseline_MAP-Elite-Explore_APGen_initState_max_v0.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ee6cb6a62756fc5682b4a53c46b33627234f1df7d2bd0d5ed59eb69812cd5be6
3
+ size 104381956
000_slider_0/000_slider_0_Gen175_Pop10000_baseline_MAP-Elite-Explore_APGen_initState_max_v0/Archive_space_Object_000_JointNature_slider_Item0_Generation_175_PopSize_10000_baseline_MAP-Elite-Explore_APGen_initState_max_v0_time.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "object_to_grasp": "000",
3
+ "joint_nature": "slider",
4
+ "item_joint_to_activate": 0,
5
+ "nb_generations": 175,
6
+ "pop_size": 10000,
7
+ "nbr_succes_traj_in_archive": 3379,
8
+ "nbr_succes_grasp_in_archive": 4633,
9
+ "total_execution_time": "13:06:47",
10
+ "nb_cell_in_archive_max": 305993,
11
+ "nb_cell_discovered": 161456,
12
+ "object_frame_in_world_frame": [
13
+ 0.6,
14
+ 0.5,
15
+ 0.0,
16
+ 1.0,
17
+ 0.0,
18
+ 0.0,
19
+ 0.0
20
+ ],
21
+ "scale_object": 1.0,
22
+ "dict_dof_limits_val": {
23
+ "3": {
24
+ "type_joint": "PRISMATIC",
25
+ "joint_item": 0,
26
+ "joint_obj_nbr": 3,
27
+ "link_associated_mystery_box": "tirroir",
28
+ "associated_link": "tirroir",
29
+ "min_val": 0.0,
30
+ "max_val": 0.19
31
+ }
32
+ },
33
+ "init_articulation_state": "max",
34
+ "base_line_grasp": "MAP-Elite-Explore",
35
+ "baseline_trajectory": "APGen",
36
+ "version": 0
37
+ }
app.py CHANGED
@@ -13,23 +13,22 @@ DATA_PATH = "000_hinge_0/000_hinge_0_Gen175_Pop10000_baseline_MAP-Elite-Explore_
13
  # -----------------------------
14
  def load_all_trajectories(path):
15
  traj_list = []
16
-
 
17
  with open(path, "r") as f:
18
  for line in f:
19
- obj = json.loads(line)
20
- traj = obj.get("traj_list")
21
-
22
- if traj is None:
23
- continue
24
-
25
- traj = [x[:3] for x in traj]
26
- traj_list.append(traj)
27
-
 
28
  return traj_list
29
 
30
- # -----------------------------
31
- # Build dict
32
- # -----------------------------
33
  def generate_trajectories():
34
  trajs = load_all_trajectories(DATA_PATH)
35
  return {f"Trajectory {i}": traj for i, traj in enumerate(trajs)}
@@ -39,46 +38,44 @@ TRAJECTORIES = generate_trajectories()
39
  # -----------------------------
40
  # Plot function
41
  # -----------------------------
42
- def plot_trajectory(choice):
43
  fig = go.Figure()
44
 
45
  for name, traj in TRAJECTORIES.items():
46
  traj = np.array(traj)
47
 
48
- if traj.shape[0] == 0:
49
  continue
50
 
51
- # -------------------------
52
- # Highlight selected traj
53
- # -------------------------
54
- if name == choice:
55
  fig.add_trace(go.Scatter3d(
56
  x=traj[:, 0],
57
  y=traj[:, 1],
58
  z=traj[:, 2],
59
- mode='lines',
60
- name=name,
61
- line=dict(
62
- width=8,
63
- color='red' # 🔴 highlighted color
64
- )
65
  ))
 
 
66
  else:
 
 
 
 
67
  fig.add_trace(go.Scatter3d(
68
- x=traj[:, 0],
69
- y=traj[:, 1],
70
- z=traj[:, 2],
71
- mode='lines',
72
- line=dict(
73
- width=2,
74
- color='lightgray'
75
- ),
76
- opacity=0.15,
77
- showlegend=False
78
  ))
79
 
80
  fig.update_layout(
81
- title=f"Selected: {choice}",
82
  scene=dict(
83
  xaxis_title="X",
84
  yaxis_title="Y",
@@ -90,17 +87,29 @@ def plot_trajectory(choice):
90
  return fig
91
 
92
  # -----------------------------
93
- # Gradio UI
94
  # -----------------------------
95
  choices = list(TRAJECTORIES.keys())
96
 
97
- demo = gr.Interface(
98
- fn=plot_trajectory,
99
- inputs=gr.Dropdown(choices, label="Choose trajectory"),
100
- outputs=gr.Plot(label="3D Trajectories (interactive)"),
101
- title="3D Trajectory Viewer",
102
- description="All trajectories are shown in grey. Selected one is highlighted in red and thicker."
103
- )
 
 
 
 
 
 
 
 
 
 
 
 
104
 
105
  if __name__ == "__main__":
106
  demo.launch()
 
13
  # -----------------------------
14
  def load_all_trajectories(path):
15
  traj_list = []
16
+ count =0
17
+ nb_traj_stored = 0
18
  with open(path, "r") as f:
19
  for line in f:
20
+ if count %50==0:
21
+ obj = json.loads(line)
22
+ traj = obj.get("traj_list")
23
+ if traj is None:
24
+ continue
25
+ traj = [x[:3] for x in traj]
26
+ traj_list.append(traj)
27
+ nb_traj_stored += 1
28
+ count += 1
29
+ print(f"Number of trajectories stored: {nb_traj_stored}")
30
  return traj_list
31
 
 
 
 
32
  def generate_trajectories():
33
  trajs = load_all_trajectories(DATA_PATH)
34
  return {f"Trajectory {i}": traj for i, traj in enumerate(trajs)}
 
38
  # -----------------------------
39
  # Plot function
40
  # -----------------------------
41
+ def update_plot(choice, progress):
42
  fig = go.Figure()
43
 
44
  for name, traj in TRAJECTORIES.items():
45
  traj = np.array(traj)
46
 
47
+ if len(traj) == 0:
48
  continue
49
 
50
+ # other trajectories
51
+ if name != choice:
 
 
52
  fig.add_trace(go.Scatter3d(
53
  x=traj[:, 0],
54
  y=traj[:, 1],
55
  z=traj[:, 2],
56
+ mode="lines",
57
+ line=dict(width=4, color="red"),
58
+ opacity=0.1,
59
+ showlegend=False
 
 
60
  ))
61
+
62
+ # selected trajectory (animated by slider)
63
  else:
64
+ n = len(traj)
65
+ k = max(2, int(n * progress))
66
+ traj_partial = traj[:k]
67
+
68
  fig.add_trace(go.Scatter3d(
69
+ x=traj_partial[:, 0],
70
+ y=traj_partial[:, 1],
71
+ z=traj_partial[:, 2],
72
+ mode="lines",
73
+ line=dict(width=6, color="green"),
74
+ name=name
 
 
 
 
75
  ))
76
 
77
  fig.update_layout(
78
+ title=f"{choice} | progress={progress:.2f}",
79
  scene=dict(
80
  xaxis_title="X",
81
  yaxis_title="Y",
 
87
  return fig
88
 
89
  # -----------------------------
90
+ # Gradio Blocks UI (LIVE)
91
  # -----------------------------
92
  choices = list(TRAJECTORIES.keys())
93
 
94
+ with gr.Blocks() as demo:
95
+
96
+ gr.Markdown("# 🔴 3D Trajectory Viewer (LIVE SLIDER)")
97
+
98
+ with gr.Row():
99
+ traj_dropdown = gr.Dropdown(choices, label="Choose trajectory")
100
+ slider = gr.Slider(0, 1, value=1, step=0.01, label="Progress")
101
+
102
+ plot = gr.Plot()
103
+
104
+ # live binding (IMPORTANT)
105
+ def refresh(choice, progress):
106
+ return update_plot(choice, progress)
107
+
108
+ traj_dropdown.change(refresh, [traj_dropdown, slider], plot)
109
+ slider.change(refresh, [traj_dropdown, slider], plot)
110
+
111
+ # initial render
112
+ demo.load(refresh, [traj_dropdown, slider], plot)
113
 
114
  if __name__ == "__main__":
115
  demo.launch()