-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
40 lines (30 loc) · 1.13 KB
/
test.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import zipfile
import config
# unzip file
def unzip_file(zip_file_path, extract_to):
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
zip_ref.extractall(extract_to)
# unzip_file("LOLdataset.zip", config.DATASET_DIR)
import os
def remove_non_image_files(directory):
print("Processing directory:", directory)
for root, dirs, files in os.walk(directory):
for file in files:
file_path = os.path.join(root, file)
if not (file.endswith(".jpg") or file.endswith(".png")):
print("Removing:", file_path)
os.remove(file_path)
def print_non_image_files(directory):
print("Processing directory:", directory)
for root, dirs, files in os.walk(directory):
for file in files:
file_path = os.path.join(root, file)
if not (file.endswith(".jpg") or file.endswith(".png")):
print("Non-image file:", file_path)
# Example usage:
print_non_image_files(config.DATASET_DIR)
# Example usage:
remove_non_image_files(config.DATASET_DIR)
# Example usage:
print("After")
print_non_image_files(config.DATASET_DIR)