SketchyCOCO数据集进行前景图像、背景图像和全景图像的分类
 
import os
import shutil
def CopyFile(src, dst, filename):
    if not os.path.exists(dst):
        os.makedirs(dst)
        print('create dir:' + dst)
    try:
        shutil.copy(src+'\\'+filename, dst+'\\'+filename)
    except Exception as e:
        print('copy fail:' + e)
if __name__ == '__main__':
    current_path = os.getcwd()
    source_path = r"G:\SketchDiffusion\code\autodl-tmp\source"
    filename_list = os.listdir(source_path)
    for filename in filename_list:
        try:
            name1, name2 = filename.split('.')
            # foreground
            if name2 == 'png':
                foreground_path = os.path.join(current_path, 'foreground')
                CopyFile(source_path, foreground_path, filename)
            # Panorama
            elif name2 == 'jpg' and name1[:6] == "000000":
                panorama_path = os.path.join(current_path, 'panorama')
                CopyFile(source_path, panorama_path, filename)
            # background
            else:
                background_path = os.path.join(current_path, 'background')
                CopyFile(source_path, background_path, filename)
        except:
            pass
    print('over!')



















