zipfile 实验

给你一囗甜甜゛ 提交于 2019-12-02 18:59:23
import os
import  glob
from typing import Optional
import cv2
import numpy as np
import torch
import yaml
import zipfile
zip_path=r"./bmp_test_cmp2.zip"
img_pattern=r'/media/nv/7174c323-375e-4334-b15e-019bd2c8af08/denoising/DnCNN-tensorflow/BK_DeblurGANv2/Finger_test/*/auth/*/*/bmp/*.bmp'
img_pattern=r'/media/nv/7174c323-375e-4334-b15e-019bd2c8af08/Finger/1029Finger/image/20190813_xiaomiCMOS1.9.2-0812_小米用例(洗手)/*/auth/*/*/bmp/*.bmp'
img_pattern=r'/media/nv/7174c323-375e-4334-b15e-019bd2c8af08/Finger/1029Finger/image/20190813_xiaomiCMOS1.9.2-0812_小米用例(洗手)/*/enroll/*/*/bmp_test_cmp/*.bmp'
img_pattern=r'/media/nv/7174c323-375e-4334-b15e-019bd2c8af08/Finger/1029Finger/image/20190813_xiaomiCMOS1.9.2-0812_小米用例(洗手)/*/*/*/*/bmp_test/*.bmp'   
img_pattern1=r'/media/nv/7174c323-375e-4334-b15e-019bd2c8af08/Finger/1029Finger/image/20190813_xiaomiCMOS1.9.2-0812_小米用例(洗手)/*/*/*/*/bmp_test/*.bmp'  
#img_pattern=r'/media/nv/7174c323-375e-4334-b15e-019bd2c8af08/Finger/1029Finger/image/20190813_xiaomiCMOS1.9.2-0812_小米用例(洗手)/*/*/*/*/bmp/*.bmp'
#img_pattern=r"/media/nv/7174c323-375e-4334-b15e-019bd2c8af08/Finger/1029Finger/image/20190814_xiamiCMOS_低温/*/*/*/bmp/*.bmp"
#img_pattern=r"/media/nv/7174c323-375e-4334-b15e-019bd2c8af08/Finger/1029Finger/image/20190814_xiaomiCMOS_0.1airgap遮黑与不遮黑FRR对比/*/*/*/*/bmp/*.bmp"
#img_pattern=r'/media/nv/7174c323-375e-4334-b15e-019bd2c8af08/Finger/1029Finger/image/20190813_xiaomiCMOS1.9.2-0812_小米用例(洗手)/0.2airgap遮黑自校准/auth/*/*/bmp/*.bmp'
#img_pattern=r'/media/nv/7174c323-375e-4334-b15e-019bd2c8af08/denoising/DnCNN-tensorflow/BK_DeblurGANv2/bmp_mix_want/bmp/*.bmp'
#img_pattern=r'/media/nv/7174c323-375e-4334-b15e-019bd2c8af08/Finger/1029Finger/image/20190813_xiaomiCMOS1.9.2-0812_小米用例(洗手)/*/*/*/*/bmp/*.bmp'
img_pattern2=r"/media/nv/7174c323-375e-4334-b15e-019bd2c8af08/Finger/1029Finger/image/20190814_xiamiCMOS_低温/*/*/*/bmp_test/*.bmp"
img_pattern3=r"/media/nv/7174c323-375e-4334-b15e-019bd2c8af08/Finger/1029Finger/image/20190814_xiaomiCMOS_0.1airgap遮黑与不遮黑FRR对比/*/*/*/*/bmp_test/*.bmp"
img_pattern4=r'/media/nv/7174c323-375e-4334-b15e-019bd2c8af08/Finger/1029Finger/image/20190813_xiaomiCMOS1.9.2-0812_小米用例(洗手)/*/*/*/*/*/bmp_test/*.bmp' 
#img_pattern=r'/media/nv/7174c323-375e-4334-b15e-019bd2c8af08/Finger/1029Finger/image/20190813_xiaomiCMOS1.9.2-0812_小米用例(洗手)/0.2airgap遮黑自校准/auth/*/*/bmp_test/*.bmp'
img_pattern1=r'/media/nv/7174c323-375e-4334-b15e-019bd2c8af08/Finger/1029Finger_part2/image1/*/*/*/*/bmp_test/*.bmp'  
# imgs1 = glob.glob(img_pattern1)
# imgs2 = glob.glob(img_pattern2)
# imgs3 = glob.glob(img_pattern3)
# imgs4 = glob.glob(img_pattern4)
# imgs=imgs1+imgs2+imgs3+imgs4
imgs=glob.glob(img_pattern1)
myZip = zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED)
for name in imgs:
    basedirname=name.replace("/media/nv/7174c323-375e-4334-b15e-019bd2c8af08/Finger/","")
    print(basedirname)
    myZip.write(name, basedirname, zipfile.ZIP_DEFLATED)
myZip.close()
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!