1 Star 1 Fork 0

Orisland/DeepMosaics

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
clean_cache.py 1.33 KB
一键复制 编辑 原始数据 按行查看 历史
Hypo 提交于 2019-08-07 16:59 . Optimized ROI locations in video
import os
import shutil
def findalldir(rootdir):
dir_list = []
for root,dirs,files in os.walk(rootdir):
for dir in dirs:
dir_list.append(os.path.join(root,dir))
return(dir_list)
def Traversal(filedir):
file_list=[]
dir_list = []
for root,dirs,files in os.walk(filedir):
for file in files:
file_list.append(os.path.join(root,file))
for dir in dirs:
dir_list.append(os.path.join(root,dir))
Traversal(dir)
return file_list,dir_list
def is_img(path):
ext = os.path.splitext(path)[1]
ext = ext.lower()
if ext in ['.jpg','.png','.jpeg','.bmp']:
return True
else:
return False
def is_video(path):
ext = os.path.splitext(path)[1]
ext = ext.lower()
if ext in ['.mp4','.flv','.avi','.mov','.mkv','.wmv','.rmvb']:
return True
else:
return False
file_list,dir_list = Traversal('./')
for file in file_list:
if ('tmp' in file) | ('pth' in file)|('pycache' in file) | is_video(file) | is_img(file):
if os.path.exists(file):
if 'imgs' not in file:
os.remove(file)
print('remove file:',file)
for dir in dir_list:
if ('tmp'in dir)|('pycache'in dir):
if os.path.exists(dir):
shutil.rmtree(dir)
print('remove dir:',dir)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Orisland/DeepMosaics.git
git@gitee.com:Orisland/DeepMosaics.git
Orisland
DeepMosaics
DeepMosaics
master

搜索帮助