-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_cleaning.py
More file actions
43 lines (31 loc) · 986 Bytes
/
Copy pathdata_cleaning.py
File metadata and controls
43 lines (31 loc) · 986 Bytes
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
import os
import cv2
import numpy as np
import time
import json
import argparse
def parse_args():
parser = argparse.ArgumentParser(description='Class separating script')
parser.add_argument('--dataset_folder', default='LouisVuitton', help='root folder of dataset')
return parser.parse_args()
params=parse_args()
data=params.dataset_folder
folders=os.listdir(data)
count=0
t1=time.time()
for f in folders:
path = os.path.join(data,f)
if(os.path.isdir(path)):
images=os.listdir(path)
for im in images:
count +=1
impath = os.path.join(path,im)
x=cv2.imread(impath)
if(type(x) is not np.ndarray):
print(impath)
os.remove(impath)
if(count%1000==0):
t2=time.time()
print("Total time taken to read : {} images = {}".format(count,t2-t1))
t1=time.time()
count=0