LINCellularNeuroscience/VAME

vame.egocentic alignment specifying video path - UnboundLocalError

EdH66 opened this issue · 2 comments

I am having trouble specifying the path to the vame.egocentric aligment function using the example data suggested and I get UnboundLocalError: local variable 'data' referenced before assignment"

I would really appreciate the help to see what I am getting wrong here. Is there there something more fundamental with project initialisation?

Here are the things I have tried

  1. If I specify the video path exactly in the config file as below I get the "UnboundLocalError: local variable 'data' referenced before assignment"
  2. if I specify as VAME_Example_120224-Jan16-2024/videos/video-1 I also get the same error
  3. I can trick it into running if I specify VAME_Example_120224-Jan16-2024/videos/video-1.csv and put the file in this folder but I think this causes me problems later.

config paths

project_path: /content/drive/MyDrive/Colab Notebooks/VAME/VAME_Example/VAME_Example_120224-Jan16-2024
video_sets: ['/content/drive/MyDrive/Colab Notebooks/VAME/VAME_Example/VAME_Example_120224-Jan16-2024/videos/video-1.mp4']

current folder structure

Folders

vame.egocentic alignment

Aligning data /content/drive/MyDrive/Colab Notebooks/VAME/VAME_Example/VAME_Example_120224-Jan16-2024/videos/video-1.mp4, Pose confidence value: 0.99

UnboundLocalError Traceback (most recent call last)
in <cell line: 1>()
----> 1 vame.egocentric_alignment(config, pose_ref_index=[0,5], crop_size=(300,300), use_video=False, video_format='.mp4', check_video=False) # transform for egocentric aligment
2 #uses path to video specified in the config file video sets

1 frames
/content/VAME/vame/util/align_egocentrical.py in alignment(path_to_file, filename, pose_ref_index, video_format, crop_size, confidence, use_video, check_video)
264 elif dataFile.endswith('.h5'):
265 data = pd.read_hdf(dataFile)
--> 266 data_mat = pd.DataFrame.to_numpy(data)
267 # data_mat = data_mat[:,1:]
268

UnboundLocalError: local variable 'data' referenced before assignment

As a follow up,

1. If I run a vame.egocentic alignment with the path as content/drive/MyDrive/Colab Notebooks/VAME/VAME_Example/VAME_Example_120224-Jan16-2024/videos/video-1.csv I can then also successfully run
vame.train_model(config) and vame.evaluate_model(config)

but then I have errors presumably because of the incorrect path:

1 vame.pose_segmentation(config) gives me as follows
[Errno 20] Not a directory: '/content/drive/MyDrive/Colab Notebooks/VAME/VAME_Example/VAME_Example_120224-Jan16-2024/videos/video-1.mp4/VAME/'

or changing the path

2 vame.pose_segmentation(config) gives me as follows
[Errno 2] No such file or directory: '/content/drive/MyDrive/Colab Notebooks/VAME/VAME_Example/VAME_Example_120224-Jan16-2024/videos/VAME/hmm-15/15_km_label_/content/drive/MyDrive/Colab Notebooks/VAME/VAME_Example/VAME_Example_120224-Jan16-2024/videos/.npy'

In all cases I think the incorrect path near the beginning for vame.egocentic alignment is causing me problems downstream

Full traceback

Using CUDA
GPU active: True
GPU used: Tesla T4
Embedding of latent vector for file /content/drive/MyDrive/Colab Notebooks/VAME/VAME_Example/VAME_Example_120224-Jan16-2024/videos/
100%|██████████| 29967/29967 [00:59<00:00, 507.12it/s]
For all animals the same parameterization of latent vectors is applied for 15 cluster
Using a HMM as parameterization!
/content/drive/MyDrive/Colab Notebooks/VAME/VAME_Example/VAME_Example_120224-Jan16-2024/videos/VAME/hmm-15/

FileNotFoundError Traceback (most recent call last)
in <cell line: 1>()
----> 1 vame.pose_segmentation(config)

2 frames
/content/VAME/vame/analysis/pose_segmentation.py in pose_segmentation(config)
302
303 save_data = os.path.join(cfg['project_path'],"results",file,model_name,parameterization+'-'+str(n_cluster),"")
--> 304 np.save(os.path.join(save_data,str(n_cluster)+'km_label'+file), labels[idx])
305 if parameterization=="kmeans":
306 np.save(os.path.join(save_data,'cluster_center_'+file), cluster_center[idx])

/usr/local/lib/python3.10/dist-packages/numpy/core/overrides.py in save(*args, **kwargs)

/usr/local/lib/python3.10/dist-packages/numpy/lib/npyio.py in save(file, arr, allow_pickle, fix_imports)
516 if not file.endswith('.npy'):
517 file = file + '.npy'
--> 518 file_ctx = open(file, "wb")
519
520 with file_ctx as fid:

FileNotFoundError: [Errno 2] No such file or directory: '/content/drive/MyDrive/Colab Notebooks/VAME/VAME_Example/VAME_Example_120224-Jan16-2024/videos/VAME/hmm-15/15_km_label_/content/drive/MyDrive/Colab Notebooks/VAME/VAME_Example/VAME_Example_120224-Jan16-2024/videos/.npy'

And finally, my current work around is to use - not sure why this works so far but it allows video import
videos = ['/content/drive/MyDrive/Colab Notebooks/VAME/videos/video-1.mp4']

I have also now commented out #figManager.window.showMaximized()' in the treehierarchy.py file