mmaction2 icon indicating copy to clipboard operation
mmaction2 copied to clipboard

NameError: name 'args' is not defined

Open vasanth4224 opened this issue 2 years ago • 5 comments

(open-mmlab) C:\Users\admin\Desktop\mmaction2\mmaction2>python tools/data/build_rawframes.py C:\Users\admin\Desktop\mmaction2\mmaction2\data\mydataset\input_sample C:\Users\admin\Desktop\mmaction2\mmaction2\data\mydataset\output_sample --task both --level 1 --flow-type tvl1 --ext mp4 Reading videos from folder: C:\Users\admin\Desktop\mmaction2\mmaction2\data\mydataset\input_sample Extension of videos: mp4 Total number of videos found: 3 multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "C:\Users\admin\anaconda3\envs\open-mmlab\lib\multiprocessing\pool.py", line 121, in worker result = (True, func(*args, **kwds)) File "C:\Users\admin\anaconda3\envs\open-mmlab\lib\multiprocessing\pool.py", line 44, in mapstar return list(map(*args)) File "C:\Users\admin\Desktop\mmaction2\mmaction2\tools\data\build_rawframes.py", line 29, in extract_frame out_full_path = args.out_dir NameError: name 'args' is not defined """

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "tools/data/build_rawframes.py", line 276, in len(vid_list) * [args.report_file])) File "C:\Users\admin\anaconda3\envs\open-mmlab\lib\multiprocessing\pool.py", line 268, in map return self._map_async(func, iterable, mapstar, chunksize).get() File "C:\Users\admin\anaconda3\envs\open-mmlab\lib\multiprocessing\pool.py", line 657, in get raise self._value NameError: name 'args' is not defined

(open-mmlab) C:\Users\admin\Desktop\mmaction2\mmaction2>

Anyone can help me to fix this error?

vasanth4224 avatar Mar 18 '22 07:03 vasanth4224

For convenience, you can set args as a global variant.

dreamerlin avatar Mar 19 '22 11:03 dreamerlin

@dreamerlin , does this problem occur in the official script?

kennymckormick avatar Mar 20 '22 15:03 kennymckormick

I rerun it successfully. Based on my wild guess, it may cause by the version of Python

dreamerlin avatar Mar 21 '22 13:03 dreamerlin

I am having the same issue

FinAminToastCrunch avatar Mar 26 '22 07:03 FinAminToastCrunch

A workaround is to edit the build_rawframes.py file and hardcode wherever the args variable is used. For example,

before: out_full_path = args.out_dir #on line 29

after:

out_full_path = r'C:\path\to\mmaction2\data\ucf101'

FinAminToastCrunch avatar Mar 26 '22 07:03 FinAminToastCrunch

Saved here: https://github.com/open-mmlab/mmaction2/issues/1719

hukkai avatar Oct 23 '22 16:10 hukkai

you use windows so the behaviors of multiprocesses is spawn not like fork in linux . the program in other processes can not go through the main block,so they cant get the args . you can try to put args out of the main block ,or put the args as a argument into the subprocesses.

blackight avatar Oct 25 '22 15:10 blackight

you use windows so the behaviors of multiprocesses is spawn not like fork in linux . the program in other processes can not go through the main block,so they cant get the args . you can try to put args out of the main block ,or put the args as a argument into the subprocesses.

Thank you so much, it works!

dandyzzc avatar Nov 09 '22 12:11 dandyzzc