temporal-shift-module icon indicating copy to clipboard operation
temporal-shift-module copied to clipboard

IndexError: list index out of range???

Open rgzn-aiyun opened this issue 5 years ago • 3 comments

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 main()

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

rgzn-aiyun avatar Dec 27 '19 08:12 rgzn-aiyun

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]

irvingzhang0512 avatar Jan 02 '20 08:01 irvingzhang0512

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

highvight avatar Jan 12 '20 14:01 highvight

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 ... .. . .

Nauman007 avatar Jul 30 '20 13:07 Nauman007