youcook2/vid2img.py
def class_process(dir_path, dst_dir_path, class_name=None):
    """
    class_name: if specific, use specific dir for each class for src / dst; else, don't create such specific dir
    """
    print('*' * 20, class_name, '*'*20)
    if class_name is not None:
        dir_path = os.path.join(dir_path, class_name)
        dst_dir_path = os.path.join(dst_dir_path, class_name)

    if not os.path.exists(dst_dir_path):
        os.mkdir(dst_dir_path)
    if not os.path.isdir(dir_path):
        raise FileNotFoundError(f"There's not a dir {dir_path}")
    
    vid_list = os.listdir(dir_path)
    vid_list.sort()
    p = Pool(n_thread)
    from functools import partial
    worker = partial(vid2jpg, dir_path=dir_path, dst_dir_path=dst_dir_path)
    for _ in tqdm(p.imap_unordered(worker, vid_list), total=len(vid_list)):
        pass
    # p.map(worker, vid_list)
    p.close()
    p.join()

    print('\n')

    class_name: if specific, use specific dir for each class for src / dst; else, don't create such specific dir
    
if specific, use specific dir for each class for src / dst; else, don't create such specific dir
if specific use specific dir for each class for src / dst ; else don ' t create such specific dir
def class_process(dir_path, dst_dir_path, class_name=None):
    print('*' * 20, class_name, '*'*20)
    if class_name is not None:
        dir_path = os.path.join(dir_path, class_name)
        dst_dir_path = os.path.join(dst_dir_path, class_name)
    if not os.path.exists(dst_dir_path):
        os.mkdir(dst_dir_path)
    if not os.path.isdir(dir_path):
        raise FileNotFoundError(f"There's not a dir {dir_path}")
    vid_list = os.listdir(dir_path)
    vid_list.sort()
    p = Pool(n_thread)
    from functools import partial
    worker = partial(vid2jpg, dir_path=dir_path, dst_dir_path=dst_dir_path)
    for _ in tqdm(p.imap_unordered(worker, vid_list), total=len(vid_list)):
        pass
    p.close()
    p.join()
    print('\n')
def class_process ( dir_path , dst_dir_path , class_name = None ) : print ( '*' * 20 , class_name , '*' * 20 ) if class_name is not None : dir_path = os . path . join ( dir_path , class_name ) dst_dir_path = os . path . join ( dst_dir_path , class_name ) if not os . path . exists ( dst_dir_path ) : os . mkdir ( dst_dir_path ) if not os . path . isdir ( dir_path ) : raise FileNotFoundError ( f"There's not a dir {dir_path}" ) vid_list = os . listdir ( dir_path ) vid_list . sort ( ) p = Pool ( n_thread ) from functools import partial worker = partial ( vid2jpg , dir_path = dir_path , dst_dir_path = dst_dir_path ) for _ in tqdm ( p . imap_unordered ( worker , vid_list ) , total = len ( vid_list ) ) : pass p . close ( ) p . join ( ) print ( '\n' )
class_name: if specific, use specific dir for each class for src / dst; else, don't create such specific dir
class_name : if specific use specific dir for each class for src / dst ; else don ' t create such specific dir
"""
    class_name: if specific, use specific dir for each class for src / dst; else, don't create such specific dir
    """ # p.map(worker, vid_list)
dir_path
dst_dir_path
class_name