Spaces:
Sleeping
Sleeping
separate data and visualization
Browse files- app.py +126 -112
- data/Fold_towels/motionCaptureData.csv +0 -0
- data/Fold_towels/video.mp4 +0 -3
- data/Pipette/motionCaptureData.csv +0 -3
- data/Pipette/video.mp4 +0 -3
- data/Take_the_item/motionCaptureData.csv +0 -0
- data/Take_the_item/video.mp4 +0 -3
- data/Twist_the_tube/motionCaptureData.csv +0 -0
- data/Twist_the_tube/video.mp4 +0 -3
- requirements.txt +2 -1
app.py
CHANGED
@@ -1,127 +1,141 @@
|
|
1 |
data_path = "./data/"
|
2 |
|
3 |
import pandas as pd
|
|
|
4 |
|
5 |
# load the csv into motion_capture_data
|
6 |
-
|
7 |
import streamlit as st
|
8 |
-
|
9 |
-
dataset_option = st.sidebar.selectbox(
|
10 |
-
'Select a dataset:',
|
11 |
-
['Fold_towels', 'Pipette', 'Take_the_item', 'Twist_the_tube']
|
12 |
-
)
|
13 |
-
motion_capture_path = data_path+dataset_option +"/motionCaptureData.csv"
|
14 |
-
video_path = data_path+dataset_option+"/video.mp4"
|
15 |
-
motion_capture_data = pd.read_csv(motion_capture_path)
|
16 |
-
# create a streamlit app that displays the motion capture data
|
17 |
-
# and the video data
|
18 |
-
st.video(video_path)
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
'Right Lower Leg',
|
29 |
-
'Right Shoulder',
|
30 |
-
'Left Hand',
|
31 |
-
'Left Upper Leg',
|
32 |
-
'Right Foot',
|
33 |
-
'Spine',
|
34 |
-
'Spine2',
|
35 |
-
'Left Lower Arm',
|
36 |
-
'Left Toe',
|
37 |
-
'Neck',
|
38 |
-
'Right Hand',
|
39 |
-
'Right Toe',
|
40 |
-
'Head',
|
41 |
-
'Left Upper Arm',
|
42 |
-
'Hips',]
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
-
|
49 |
-
|
|
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
data=[
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
)
|
|
|
|
|
|
|
66 |
|
67 |
-
# Create the initial scatter plot
|
68 |
-
initial_scatter = go.Scatter3d(
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
)
|
75 |
|
76 |
-
# Create the layout with slider
|
77 |
-
layout = go.Layout(
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
},
|
86 |
-
{
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
'type': 'buttons',
|
96 |
-
'x': 0.1,
|
97 |
-
'xanchor': 'right',
|
98 |
-
'y': 0,
|
99 |
-
'yanchor': 'top'
|
100 |
-
}],
|
101 |
-
sliders=[{
|
102 |
-
'active': 0,
|
103 |
-
'steps': [{
|
104 |
-
'label': str(k),
|
105 |
-
'method': 'animate',
|
106 |
-
'args': [
|
107 |
-
[str(k)],
|
108 |
-
{'mode': 'immediate', 'frame': {'duration': 300, 'redraw': True}, 'transition': {'duration': len(times)/30}}
|
109 |
-
]
|
110 |
-
} for k in range(len(times))],
|
111 |
-
'currentvalue': {
|
112 |
-
'prefix': 'Time: ',
|
113 |
-
'visible': True,
|
114 |
-
'xanchor': 'right'
|
115 |
-
},
|
116 |
-
'pad': {'b': 10},
|
117 |
-
'len': 0.9,
|
118 |
-
'x': 0.1,
|
119 |
-
'y': 0,
|
120 |
-
}]
|
121 |
-
)
|
122 |
|
123 |
-
#
|
124 |
-
|
125 |
|
126 |
-
|
127 |
-
st.
|
|
|
|
|
|
1 |
data_path = "./data/"
|
2 |
|
3 |
import pandas as pd
|
4 |
+
import datasets
|
5 |
|
6 |
# load the csv into motion_capture_data
|
|
|
7 |
import streamlit as st
|
8 |
+
dataset_names = ['Fold_towels', 'Pipette', 'Take_the_item', 'Twist_the_tube']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
def load_data():
|
11 |
+
print("Loading data")
|
12 |
+
# load the motion capture data
|
13 |
+
all_datasets = {}
|
14 |
+
for name in dataset_names:
|
15 |
+
print("Loading dataset: ", name)
|
16 |
+
all_datasets[name] = pd.DataFrame(datasets.load_dataset("cyberorigin/"+name)['train'])
|
17 |
+
return all_datasets
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
@st.fragment
|
20 |
+
def visualize(data):
|
21 |
+
dataset_option = st.selectbox(
|
22 |
+
'Select a dataset:',
|
23 |
+
dataset_names
|
24 |
+
)
|
25 |
+
# create a streamlit app that displays the motion capture data
|
26 |
+
# and the video data
|
27 |
+
st.video("https://huggingface.co/datasets/cyberorigin/"+dataset_option+"/resolve/main/Video/video.mp4")
|
28 |
+
motion_capture_data = data[dataset_option]
|
29 |
+
body_part_names = ['Left Shoulder',
|
30 |
+
'Right Upper Arm',
|
31 |
+
'Left Lower Leg',
|
32 |
+
'Spine1',
|
33 |
+
'Right Upper Leg',
|
34 |
+
'Spine3',
|
35 |
+
'Right Lower Arm',
|
36 |
+
'Left Foot',
|
37 |
+
'Right Lower Leg',
|
38 |
+
'Right Shoulder',
|
39 |
+
'Left Hand',
|
40 |
+
'Left Upper Leg',
|
41 |
+
'Right Foot',
|
42 |
+
'Spine',
|
43 |
+
'Spine2',
|
44 |
+
'Left Lower Arm',
|
45 |
+
'Left Toe',
|
46 |
+
'Neck',
|
47 |
+
'Right Hand',
|
48 |
+
'Right Toe',
|
49 |
+
'Head',
|
50 |
+
'Left Upper Arm',
|
51 |
+
'Hips',]
|
52 |
|
53 |
+
motion_capture_x = motion_capture_data[[body_part_name+"_x" for body_part_name in body_part_names]]
|
54 |
+
motion_capture_y = motion_capture_data[[body_part_name+"_y" for body_part_name in body_part_names]]
|
55 |
+
motion_capture_z = motion_capture_data[[body_part_name+"_z" for body_part_name in body_part_names]]
|
56 |
|
57 |
+
import plotly.graph_objects as go
|
58 |
+
import numpy as np
|
59 |
+
|
60 |
+
# Sample Data Preparation
|
61 |
+
data = []
|
62 |
+
times = motion_capture_data["timestamp"]
|
63 |
+
frames = [go.Frame(
|
64 |
+
data=[
|
65 |
+
go.Scatter3d(
|
66 |
+
x=motion_capture_x.iloc[k],
|
67 |
+
y=motion_capture_y.iloc[k],
|
68 |
+
z=motion_capture_z.iloc[k],
|
69 |
+
mode='markers',
|
70 |
+
marker=dict(size=5, color='blue')
|
71 |
+
)
|
72 |
+
],
|
73 |
+
name=str(k)
|
74 |
+
) for k in range(len(times))]
|
75 |
|
76 |
+
# Create the initial scatter plot
|
77 |
+
initial_scatter = go.Scatter3d(
|
78 |
+
x=motion_capture_x.iloc[0],
|
79 |
+
y=motion_capture_y.iloc[0],
|
80 |
+
z=motion_capture_z.iloc[0],
|
81 |
+
mode='markers',
|
82 |
+
marker=dict(size=5, color='blue')
|
83 |
+
)
|
84 |
|
85 |
+
# Create the layout with slider
|
86 |
+
layout = go.Layout(
|
87 |
+
title='Motion Capture Visualization',
|
88 |
+
updatemenus=[{
|
89 |
+
'buttons': [
|
90 |
+
{
|
91 |
+
'args': [None, {'frame': {'duration': 1, 'redraw': True}, 'fromcurrent': True}],
|
92 |
+
'label': 'Play',
|
93 |
+
'method': 'animate'
|
94 |
+
},
|
95 |
+
{
|
96 |
+
'args': [[None], {'frame': {'duration': 0, 'redraw': True}, 'mode': 'immediate', 'transition': {'duration': 0}}],
|
97 |
+
'label': 'Pause',
|
98 |
+
'method': 'animate'
|
99 |
+
}
|
100 |
+
],
|
101 |
+
'direction': 'left',
|
102 |
+
'pad': {'r': 10, 't': 87},
|
103 |
+
'showactive': True,
|
104 |
+
'type': 'buttons',
|
105 |
+
'x': 0.1,
|
106 |
+
'xanchor': 'right',
|
107 |
+
'y': 0,
|
108 |
+
'yanchor': 'top'
|
109 |
+
}],
|
110 |
+
sliders=[{
|
111 |
+
'active': 0,
|
112 |
+
'steps': [{
|
113 |
+
'label': str(k),
|
114 |
+
'method': 'animate',
|
115 |
+
'args': [
|
116 |
+
[str(k)],
|
117 |
+
{'mode': 'immediate', 'frame': {'duration': 300, 'redraw': True}, 'transition': {'duration': len(times)/30}}
|
118 |
+
]
|
119 |
+
} for k in range(len(times))],
|
120 |
+
'currentvalue': {
|
121 |
+
'prefix': 'Time: ',
|
122 |
+
'visible': True,
|
123 |
+
'xanchor': 'right'
|
124 |
},
|
125 |
+
'pad': {'b': 10},
|
126 |
+
'len': 0.9,
|
127 |
+
'x': 0.1,
|
128 |
+
'y': 0,
|
129 |
+
}]
|
130 |
+
)
|
131 |
+
|
132 |
+
# Create the figure
|
133 |
+
fig = go.Figure(data=[initial_scatter], frames=frames, layout=layout)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
+
# Display the figure in the streamlit app
|
136 |
+
st.plotly_chart(fig)
|
137 |
|
138 |
+
|
139 |
+
st.title("CyberOrigin Data Visualization")
|
140 |
+
data = load_data()
|
141 |
+
visualize(data)
|
data/Fold_towels/motionCaptureData.csv
DELETED
The diff for this file is too large to render.
See raw diff
|
|
data/Fold_towels/video.mp4
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:e9560ac4ab1b31cc64a6d0fe94d219762bd8d8a2d9b84f81ea47cdc21f6f1d7e
|
3 |
-
size 23094167
|
|
|
|
|
|
|
|
data/Pipette/motionCaptureData.csv
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:80e4cd197478028843d89d59682054e09c40bf5410390cacebbd0180620b1d4d
|
3 |
-
size 10682090
|
|
|
|
|
|
|
|
data/Pipette/video.mp4
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:ccb1ef4d825f1bba9e914b496bf815c03b7366dc307133a661437b96b85592d0
|
3 |
-
size 23941195
|
|
|
|
|
|
|
|
data/Take_the_item/motionCaptureData.csv
DELETED
The diff for this file is too large to render.
See raw diff
|
|
data/Take_the_item/video.mp4
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:9c3d2e92f0ff2773933e91015753af6098e8fabd9a89cfb1b1ca33e2bfa52974
|
3 |
-
size 6758822
|
|
|
|
|
|
|
|
data/Twist_the_tube/motionCaptureData.csv
DELETED
The diff for this file is too large to render.
See raw diff
|
|
data/Twist_the_tube/video.mp4
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:5a00a3108ba51f32cbccddfe198f5dd64b45b9bb0a9eb56cf93782fa16a828e3
|
3 |
-
size 13989984
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
streamlit
|
2 |
pandas
|
3 |
plotly
|
4 |
-
numpy
|
|
|
|
1 |
streamlit
|
2 |
pandas
|
3 |
plotly
|
4 |
+
numpy
|
5 |
+
datasets
|