temporal-shift-module
temporal-shift-module copied to clipboard
IndexError: list index out of range???
Hi, thanks for sharing this work
I'm having a fault when running online_demo code. Here is the error:
Traceback (most recent call last):
File "main.py", line 349, in
File "main.py", line 323, in main idx, history = process_output(idx_, history)
File "main.py", line 249, in process_output if not (history[-1] == history[-2]): # and history[-2] == history[-3]):
IndexError: list index out of range
i'm not familiar with tsm and don't know how it works, but i fix the issue by the following codes.
if len(history) > 1 and idx_ != history[-1]: # add new condition here
if not (history[-1] == history[-2]): # and history[-2] == history[-3]):
idx_ = history[-1]
Just fill the initial history with with more values. So instead of history = [2]
do history = [2,2,2]
This is indeed a small bug in main.py
def process_output(idx_, history): # idx_: the output of current frame # history: a list containing the history of predictions
history.append(idx_)
if not REFINE_OUTPUT:
return idx_, history
max_hist_len = 20 # max history buffer
# mask out illegal action
if idx_ in [7, 8, 21, 22, 3]:
idx_ = history[-1]
# use only single no action class
if idx_ == 0:
idx_ = 2
# history smoothing
print(len(history))
if idx_ != history[-1]:
if not (history[-1] == history[-2]): #and history[-2] == history[-3]):
idx_ = history[-1]
#history.append(idx_)
history = history[-max_hist_len:]
return history[-1], history
copy paste this function with the provided one.. idk, but it works this way ... .. . .