zipfile 实验
Posted skydaddy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zipfile 实验相关的知识,希望对你有一定的参考价值。
import os
import glob
from typing import Optional
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()
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()
以上是关于zipfile 实验的主要内容,如果未能解决你的问题,请参考以下文章
Python zipfile 模块:zipfile.ZIP_DEFLATED 和 zipfile.ZIP_STORED 之间的区别