-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzip_data_sets.py
26 lines (23 loc) · 878 Bytes
/
zip_data_sets.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from zipfile import ZipFile
import os
from os.path import basename
'''
Script used to zip files from traininf test and validation directories.
Use split.py to split images into mentdioned directories.
Those files should be put in 1 directory and upload to Google Colab environment.
'''
# Pathes to the particular folders
PATHS=('\traning',
'\validation',
'\test')
for dir in PATHS:
# create a ZipFile object
with ZipFile('traning.zip', 'w') as zipObj:
# Iterate over all the files in directory
for folderName, subfolders, filenames in os.walk(dir):
for filename in filenames:
#create complete filepath of file in directory
filePath = os.path.join(folderName, filename)
# Add file to zip
print(filePath)
zipObj.write(filePath, basename(filePath))