0

I am getting this error when I try processing a video with openpose inside an app. Please help. The input video is a .webm that is supposed to be processed to get key points After this is a function that finds x and y corridnates and return two lists from array of average of points in a single 'pose_keypoints_2d' array. The error,

[2022-01-11 08:05:15,764] ERROR in app: Exception on /video [POST]
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py", line 1952, in 
full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py", line 1821, in 
handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\ProgramData\Anaconda3\lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py", line 1950, in 
full_dispatch_request
rv = self.dispatch_request()
File "C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\Admin\Desktop\physiorollball\code\aligned\app\routes.py", line 147, in video
labels, values = warrior2_label_csv(df)
File "C:\Users\Admin\Desktop\physiorollball\code\aligned\modeling.py", line 307, in 
warrior2_label_csv
x, y = x_y_points(np.array(mean_ten_still_frames(pose_df)))
File "C:\Users\Admin\Desktop\physiorollball\code\aligned\modeling.py", line 21, in 
mean_ten_still_frames
stillest_ten = pose_df.loc[still_point:still_point.append('9'), :]
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 925, in 
__getitem__
return self._getitem_tuple(key)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 1109, in 
_getitem_tuple
return self._getitem_tuple_same_dim(tup)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 806, in 
_getitem_tuple_same_dim
retval = getattr(retval, self.name)._getitem_axis(key, axis=i)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 1142, in 
_getitem_axis
return self._get_slice_axis(key, axis=axis)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 1176, in 
_get_slice_axis
indexer = labels.slice_indexer(slice_obj.start, slice_obj.stop, slice_obj.step)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 5685, in 
slice_indexer
start_slice, end_slice = self.slice_locs(start, end, step=step)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 5887, in 
slice_locs
start_slice = self.get_slice_bound(start, "left")
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 5801, in 
get_slice_bound
slc = self.get_loc(label)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 3361, in 
get_loc
return self._engine.get_loc(casted_key)
File "pandas\_libs\index.pyx", line 76, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\index.pyx", line 82, in pandas._libs.index.IndexEngine.get_loc
TypeError: '['9']' is an invalid key

Can someone help me understand what exactly is the problem and how I can solve it? Let me provide the snippet of code with the value.

 def mean_ten_still_frames(pose_df):
This function find the ten stillest frames in the pose's df.
It returns the mean for each point
"""
# pose_df = pose_csv
pose_diff = pose_df.diff()
rows_total_diff = pose_diff.sum(axis=1)
rows_total_diff = [abs(i) for i in rows_total_diff]
ten_rows_diff= []
for i in range(len(rows_total_diff)-9):
    ten_rows_diff.append((i, sum(rows_total_diff[i:(i+9)])))
best_ten = sorted(ten_rows_diff, key=lambda x: x[1], reverse=False)
still_point = best_ten
print(still_point)
stillest_ten = pose_df.loc[still_point:still_point.append('9'), :]
print(stillest_ten)
mean = np.mean(stillest_ten, axis=0)
return mean

line 307 is here

x, y = x_y_points(np.array(mean_ten_still_frames(pose_df)))
  • The line `stillest_ten = pose_df.loc[still_point:still_point.append('9'), :]` is extremely fishy. The `append` function appends a value to an array and returns `None`. That is almost certainly not what you want. What are you trying to do here? – Frank Yellin Jan 11 '22 at 07:06
  • When I remove the append it throws the error of typeerror ['9'] is an invalid key. I added spend function to solve that – Diana Oguda Jan 12 '22 at 09:44
  • I don't really understand what your code is doing, so I can't really help you. What are you trying to do? – Frank Yellin Jan 12 '22 at 17:50

0 Answers0