LINCellularNeuroscience / VAME

Variational Animal Motion Embedding - A tool for time series embedding and clustering
GNU General Public License v3.0
176 stars 60 forks source link

Error with egocentric allignment function #64

Closed thomasjohnkelly closed 3 years ago

thomasjohnkelly commented 3 years ago

Hi Dr. Bauer,

I am having an issue where I get an error every time I try to call the egocentric alignment function. Here is my code and output:

vame.egocentric_alignment(config, pose_ref_index=[0,15], crop_size=(300,300), use_video=False, video_format='.MP4', check_video=False)

Aligning data Novel_object_recognition_Left_3DM0162_right_3DM01515mintest, Pose confidence value: 0.99 /home/th65000/VAME/vame/util/align_egocentrical.py:314: DtypeWarning: Columns (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90) have mixed types.Specify dtype option on import or set low_memory=False. confidence, use_video=use_video, check_video=check_video) ERROR:root:Internal Python error in the inspect module. Below is the traceback from this internal error.

ERROR:root:Internal Python error in the inspect module. Below is the traceback from this internal error.

ERROR:root:Internal Python error in the inspect module. Below is the traceback from this internal error.

Traceback (most recent call last): File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3437, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in vame.egocentric_alignment(config, pose_ref_index=[0,15], crop_size=(300,300), use_video=False, video_format='.MP4', check_video=False) File "/home/th65000/VAME/vame/util/align_egocentrical.py", line 314, in egocentric_alignment confidence, use_video=use_video, check_video=check_video) File "/home/th65000/VAME/vame/util/align_egocentrical.py", line 290, in alignment confidence, pose_flip_ref, bg, frame_count, use_video) File "/home/th65000/VAME/vame/util/align_egocentrical.py", line 150, in align_mouse if j[2] <= confidence: TypeError: '<=' not supported between instances of 'str' and 'ScalarFloat'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 2061, in showtraceback stb = value._rendertraceback() AttributeError: 'TypeError' object has no attribute '_rendertraceback'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 1101, in get_records return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 248, in wrapped return f(*args, **kwargs) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 281, in _fixed_getinnerframes records = fix_frame_records_filenames(inspect.getinnerframes(etb, context)) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/inspect.py", line 1502, in getinnerframes frameinfo = (tb.tb_frame,) + getframeinfo(tb, context) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/inspect.py", line 1460, in getframeinfo filename = getsourcefile(frame) or getfile(frame) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/inspect.py", line 696, in getsourcefile if getattr(getmodule(object, filename), 'loader', None) is not None: File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/inspect.py", line 733, in getmodule if ismodule(module) and hasattr(module, 'file'): File "/home/th65000/.local/lib/python3.7/site-packages/tensorflow/init.py", line 50, in getattr module = self._load() File "/home/th65000/.local/lib/python3.7/site-packages/tensorflow/init.py", line 44, in _load module = _importlib.import_module(self.name) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 953, in _find_and_load_unlocked File "", line 219, in _call_with_frames_removed File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File "/home/th65000/.local/lib/python3.7/site-packages/tensorflow_core/init.py", line 32, in from tensorflow._api.v1 import app File "/home/th65000/.local/lib/python3.7/site-packages/tensorflow_core/_api/v1/app/init.py", line 10, in from tensorflow.python.platform.app import run File "/home/th65000/.local/lib/python3.7/site-packages/tensorflow_core/python/platform/app.py", line 23, in from absl.app import run as _run ModuleNotFoundError: No module named 'absl' Traceback (most recent call last): File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3437, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in vame.egocentric_alignment(config, pose_ref_index=[0,15], crop_size=(300,300), use_video=False, video_format='.MP4', check_video=False) File "/home/th65000/VAME/vame/util/align_egocentrical.py", line 314, in egocentric_alignment confidence, use_video=use_video, check_video=check_video) File "/home/th65000/VAME/vame/util/align_egocentrical.py", line 290, in alignment confidence, pose_flip_ref, bg, frame_count, use_video) File "/home/th65000/VAME/vame/util/align_egocentrical.py", line 150, in align_mouse if j[2] <= confidence: TypeError: '<=' not supported between instances of 'str' and 'ScalarFloat'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 2061, in showtraceback stb = value._rendertraceback() AttributeError: 'TypeError' object has no attribute '_rendertraceback'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3357, in run_ast_nodes if (await self.runcode(code, result, async=asy)): File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3454, in run_code self.showtraceback(running_compiled_code=True) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 2064, in showtraceback value, tb, tb_offset=tb_offset) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 1368, in structured_traceback self, etype, value, tb, tb_offset, number_of_lines_of_context) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 1268, in structured_traceback self, etype, value, tb, tb_offset, number_of_lines_of_context File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 1125, in structured_traceback tb_offset) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 1082, in format_exception_as_a_whole last_unique, recursion_repeat = find_recursion(orig_etype, evalue, records) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 382, in find_recursion return len(records), 0 TypeError: object of type 'NoneType' has no len()

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 2061, in showtraceback stb = value._rendertraceback() AttributeError: 'TypeError' object has no attribute '_rendertraceback'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 1101, in get_records return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 248, in wrapped return f(*args, **kwargs) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 281, in _fixed_getinnerframes records = fix_frame_records_filenames(inspect.getinnerframes(etb, context)) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/inspect.py", line 1502, in getinnerframes frameinfo = (tb.tb_frame,) + getframeinfo(tb, context) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/inspect.py", line 1460, in getframeinfo filename = getsourcefile(frame) or getfile(frame) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/inspect.py", line 696, in getsourcefile if getattr(getmodule(object, filename), 'loader', None) is not None: File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/inspect.py", line 733, in getmodule if ismodule(module) and hasattr(module, 'file'): File "/home/th65000/.local/lib/python3.7/site-packages/tensorflow/init.py", line 50, in getattr module = self._load() File "/home/th65000/.local/lib/python3.7/site-packages/tensorflow/init.py", line 44, in _load module = _importlib.import_module(self.name) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 953, in _find_and_load_unlocked File "", line 219, in _call_with_frames_removed File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File "/home/th65000/.local/lib/python3.7/site-packages/tensorflow_core/init.py", line 32, in from tensorflow._api.v1 import app File "/home/th65000/.local/lib/python3.7/site-packages/tensorflow_core/_api/v1/app/init.py", line 10, in from tensorflow.python.platform.app import run File "/home/th65000/.local/lib/python3.7/site-packages/tensorflow_core/python/platform/app.py", line 23, in from absl.app import run as _run ModuleNotFoundError: No module named 'absl' Traceback (most recent call last): File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3437, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in vame.egocentric_alignment(config, pose_ref_index=[0,15], crop_size=(300,300), use_video=False, video_format='.MP4', check_video=False) File "/home/th65000/VAME/vame/util/align_egocentrical.py", line 314, in egocentric_alignment confidence, use_video=use_video, check_video=check_video) File "/home/th65000/VAME/vame/util/align_egocentrical.py", line 290, in alignment confidence, pose_flip_ref, bg, frame_count, use_video) File "/home/th65000/VAME/vame/util/align_egocentrical.py", line 150, in align_mouse if j[2] <= confidence: TypeError: '<=' not supported between instances of 'str' and 'ScalarFloat'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 2061, in showtraceback stb = value._rendertraceback() AttributeError: 'TypeError' object has no attribute '_rendertraceback'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3357, in run_ast_nodes if (await self.runcode(code, result, async=asy)): File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3454, in run_code self.showtraceback(running_compiled_code=True) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 2064, in showtraceback value, tb, tb_offset=tb_offset) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 1368, in structured_traceback self, etype, value, tb, tb_offset, number_of_lines_of_context) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 1268, in structured_traceback self, etype, value, tb, tb_offset, number_of_lines_of_context File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 1125, in structured_traceback tb_offset) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 1082, in format_exception_as_a_whole last_unique, recursion_repeat = find_recursion(orig_etype, evalue, records) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 382, in find_recursion return len(records), 0 TypeError: object of type 'NoneType' has no len()

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 2061, in showtraceback stb = value._rendertraceback() AttributeError: 'TypeError' object has no attribute '_rendertraceback'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 2940, in _run_cell return runner(coro) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/async_helpers.py", line 68, in _pseudo_sync_runner coro.send(None) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3166, in run_cell_async interactivity=interactivity, compiler=compiler, result=result) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3376, in run_ast_nodes self.showtraceback() File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 2064, in showtraceback value, tb, tb_offset=tb_offset) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 1368, in structured_traceback self, etype, value, tb, tb_offset, number_of_lines_of_context) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 1268, in structured_traceback self, etype, value, tb, tb_offset, number_of_lines_of_context File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 1143, in structured_traceback chained_exceptions_tb_offset) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 1082, in format_exception_as_a_whole last_unique, recursion_repeat = find_recursion(orig_etype, evalue, records) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 382, in find_recursion return len(records), 0 TypeError: object of type 'NoneType' has no len()

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 2061, in showtraceback stb = value._rendertraceback() AttributeError: 'TypeError' object has no attribute '_rendertraceback'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 1101, in get_records return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 248, in wrapped return f(*args, **kwargs) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/site-packages/IPython/core/ultratb.py", line 281, in _fixed_getinnerframes records = fix_frame_records_filenames(inspect.getinnerframes(etb, context)) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/inspect.py", line 1502, in getinnerframes frameinfo = (tb.tb_frame,) + getframeinfo(tb, context) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/inspect.py", line 1460, in getframeinfo filename = getsourcefile(frame) or getfile(frame) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/inspect.py", line 696, in getsourcefile if getattr(getmodule(object, filename), 'loader', None) is not None: File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/inspect.py", line 733, in getmodule if ismodule(module) and hasattr(module, 'file'): File "/home/th65000/.local/lib/python3.7/site-packages/tensorflow/init.py", line 50, in getattr module = self._load() File "/home/th65000/.local/lib/python3.7/site-packages/tensorflow/init.py", line 44, in _load module = _importlib.import_module(self.name) File "/home/th65000/anaconda3/envs/VAME/lib/python3.7/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 953, in _find_and_load_unlocked File "", line 219, in _call_with_frames_removed File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File "/home/th65000/.local/lib/python3.7/site-packages/tensorflow_core/init.py", line 32, in from tensorflow._api.v1 import app File "/home/th65000/.local/lib/python3.7/site-packages/tensorflow_core/_api/v1/app/init.py", line 10, in from tensorflow.python.platform.app import run File "/home/th65000/.local/lib/python3.7/site-packages/tensorflow_core/python/platform/app.py", line 23, in from absl.app import run as _run ModuleNotFoundError: No module named 'absl'

alexcwsmith commented 3 years ago

I believe this is happening because for some reason your pose_estimation CSV files are stored in string or object format instead of as floats. You can check by loading one with pandas as below and checking dtypes:

df = pd.read_csv(~/vame/videos/pose_estimation/PathToFile.csv, header=[0,1,2], index_col=0) #an example, use a real path
df.dtypes

That should return that all columns are float32 (or maybe float64) format. Some might be strings or objects. If that's the case I would use this code, again substituting your videos/pose_estimation directory for the one here:

import os
import pandas as pd

directory = ~/vame/videos/pose_estimation/
files = os.listdir(directory)
for f in files:
    fullpath=os.path.join(directory, f)
    df = pd.read_csv(fullpath, header=[0,1,2], index_col=0)
    if not os.path.exists(os.path.join(directory, 'original'):
        os.mkdir(os.path.join(directory, 'original')
    df.to_csv(os.path.join(directory, 'original', f) #just to back-up the original just in case you need to revert to it
    cols = df.columns
    for col in cols:
         df[col]=df[col].astype('float32')
         df.to_csv(fullpath) #will overwrite the original, hence making the backup above.
thomasjohnkelly commented 3 years ago

Hi, Thank you so much for your response! I actually got this working months ago and have some great data! -Tommy


From: Alexander CW Smith @.> Sent: Tuesday, October 12, 2021 12:40 PM To: LINCellularNeuroscience/VAME @.> Cc: Kelly, Thomas @.>; Author @.> Subject: Re: [LINCellularNeuroscience/VAME] Error with egocentric allignment function (#64)

ATTENTION: This email originated from a sender outside of MCW. Use caution when clicking on links or opening attachments.


I would use this code, substituting your videos/pose_estimation directory for the one here:

directory = ~/vame/videos/pose_estimation/ files = os.listdir(directory) for f in files: fullpath=os.path.join(directory, f) df = pd.read_csv(fullpath, index_col=0) if not os.path.exists(os.path.join(directory, 'original'): os.mkdir(os.path.join(directory, 'original') df.to_csv(os.path.join(directory, 'original', f) #just to back-up the original just in case you need to revert to it cols = df.columns for col in cols: df[col]=df[col].astype(float32) df.to_csv(fullpath)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/LINCellularNeuroscience/VAME/issues/64*issuecomment-941228511__;Iw!!H8mHWRdzp34!tHRmepaiT3y565xEAUCG5hmkm42WYuVZ8RoccMK1TiUTmJ4TZF7BebT1d32MnH1M$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AVDSPJ3BLPBUL7NMBH4SR2TUGRXIZANCNFSM5BWFGJOA__;!!H8mHWRdzp34!tHRmepaiT3y565xEAUCG5hmkm42WYuVZ8RoccMK1TiUTmJ4TZF7BebT1d4akQNLA$. Triage notifications on the go with GitHub Mobile for iOShttps://urldefense.com/v3/__https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675__;!!H8mHWRdzp34!tHRmepaiT3y565xEAUCG5hmkm42WYuVZ8RoccMK1TiUTmJ4TZF7BebT1d3wkoeXT$ or Androidhttps://urldefense.com/v3/__https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign*3Dnotification-email*26utm_medium*3Demail*26utm_source*3Dgithub__;JSUlJSU!!H8mHWRdzp34!tHRmepaiT3y565xEAUCG5hmkm42WYuVZ8RoccMK1TiUTmJ4TZF7BebT1d_fLAw8R$.

cassandrarbk commented 11 months ago

hi there, i am running into the exact same problem right now, and was wondering if you could share the solution that you had?