pranay-ar commited on
Commit
60212c0
·
verified ·
1 Parent(s): 08ec46c

Upload 3 files

Browse files
shane_models/i2c_s_i_t_t_ie_mw2_w_2.5_master_imu_encoder.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:644b1899f538a4068b4a31549876ca66d08427368f1f02af8bc735cc2b34704d
3
+ size 3406852
shane_models/i2c_s_i_t_v_ie_mw2_w_5.0_master_imu_encoder.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9787fd787649633616d19716ed81ad442cde1bb6c2fdd93a041d9db2c0d4e2e7
3
+ size 3406852
shane_models/run_load_imu2clip_encoder.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import sys
3
+ sys.path.append("/home/pranayr_umass_edu/imu2clip")
4
+ from lib.imu_models import MW2StackRNNPooling
5
+
6
+ if __name__ == "__main__":
7
+
8
+ # Generate random IMU-like motions as examples
9
+ # imu_motions: array <n_samples x 6 x 1000>
10
+ imu_motions = torch.rand(1, 6, 1000)
11
+ print(imu_motions.dtype)
12
+ print("Generated random IMU-like motions:", imu_motions)
13
+
14
+ # Load the IMU encoder
15
+ """
16
+ The following example .pt model is configured as
17
+ - i2c: IMU2CLIP
18
+ - s_i: source modality = IMU
19
+ - t_v: target modality for alignment = Video
20
+ - t_t: target modality for alignment = Text
21
+ - mw2: MW2StackRNNPooling as the encoder
22
+ - w_5.0: window size of 2.5 x 2 seconds
23
+ """
24
+ #path_imu_encoder = "./i2c_s_i_t_v_ie_mw2_w_5.0_master_imu_encoder.pt"
25
+ # path_imu_encoder = "./i2c_s_i_t_t_ie_mw2_w_2.5_master_imu_encoder.pt"
26
+ path_imu_encoder = "/home/pranayr_umass_edu/imu2clip/shane_models/i2c_s_i_t_v_ie_mw2_w_5.0_master_imu_encoder.pt"
27
+ path_imu_encoder = '/home/pranayr_umass_edu/imu2clip/saved/mw2/i2c/i2c_s_i_t_v_se_mw2_w_5.0_master-epoch=12-val_loss=3.14.ckpt'
28
+
29
+ loaded_imu_encoder = MW2StackRNNPooling(size_embeddings=512)
30
+ loaded_imu_encoder.load_state_dict(torch.load(path_imu_encoder))
31
+ print("Loaded IMU Encoder:", loaded_imu_encoder)
32
+ loaded_imu_encoder.eval()
33
+ print("Done loading the IMU Encoder")
34
+
35
+ # Inference time
36
+ imu2clip_embeddings = loaded_imu_encoder(imu_motions)
37
+ print('Raw IMU Signals (random)', imu_motions.shape)
38
+ print('Encoded IMU2CLIP embeddings', imu2clip_embeddings.shape)
39
+
40
+ # # check if raw and encoded are the same
41
+ # print('Are the raw and encoded the same?', torch.allclose(imu_motions, imu2clip_embeddings))