louiscklaw
commited on
Commit
·
98faac3
1
Parent(s):
f5c2de6
update beach_512,
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- check_valid_image.py +51 -0
- data/train/c_0000000003.jpg +3 -0
- data/train/c_0000000004.jpg +3 -0
- data/train/c_0000000005.jpg +3 -0
- data/train/c_0000000006.jpg +3 -0
- data/train/c_0000000007.jpg +3 -0
- data/train/c_0000000008.jpg +3 -0
- data/train/c_0000000009.jpg +3 -0
- data/train/c_0000000010.jpg +3 -0
- data/train/c_0000000011.jpg +3 -0
- data/train/c_0000000012.jpg +3 -0
- data/train/c_0000000013.jpg +3 -0
- data/train/c_0000000014.jpg +3 -0
- data/train/c_0000000015.jpg +3 -0
- data/train/c_0000000016.jpg +3 -0
- data/train/c_0000000018.jpg +3 -0
- data/train/c_0000000019.jpg +3 -0
- data/train/c_0000000021.jpg +3 -0
- data/train/c_0000000022.jpg +3 -0
- data/train/c_0000000024.jpg +3 -0
- data/train/c_0000000025.jpg +3 -0
- data/train/c_0000000026.jpg +3 -0
- data/train/c_0000000028.jpg +3 -0
- data/train/c_0000000029.jpg +3 -0
- data/train/c_0000000031.jpg +3 -0
- data/train/c_0000000032.jpg +3 -0
- data/train/c_0000000033.jpg +3 -0
- data/train/c_0000000035.jpg +3 -0
- data/train/c_0000000036.jpg +3 -0
- data/train/c_0000000037.jpg +3 -0
- data/train/c_0000000039.jpg +3 -0
- data/train/c_0000000040.jpg +3 -0
- data/train/c_0000000041.jpg +3 -0
- data/train/c_0000000042.jpg +3 -0
- data/train/c_0000000043.jpg +3 -0
- data/train/c_0000000044.jpg +3 -0
- data/train/c_0000000047.jpg +3 -0
- data/train/c_0000000048.jpg +3 -0
- data/train/c_0000000051.jpg +3 -0
- data/train/c_0000000052.jpg +3 -0
- data/train/c_0000000053.jpg +3 -0
- data/train/c_0000000054.jpg +3 -0
- data/train/c_0000000055.jpg +3 -0
- data/train/c_0000000056.jpg +3 -0
- data/train/c_0000000057.jpg +3 -0
- data/train/c_0000000058.jpg +3 -0
- data/train/c_0000000059.jpg +3 -0
- data/train/c_0000000060.jpg +3 -0
- data/train/c_0000000061.jpg +3 -0
- data/train/c_0000000062.jpg +3 -0
check_valid_image.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# iterate files over subdirectories in `00_store`, store image files in hash table, delete files with same hash
|
2 |
+
import os
|
3 |
+
import hashlib
|
4 |
+
import imghdr
|
5 |
+
|
6 |
+
deleted = 0
|
7 |
+
|
8 |
+
|
9 |
+
def is_image(filename, verbose=False):
|
10 |
+
|
11 |
+
data = open(filename, "rb").read(10)
|
12 |
+
|
13 |
+
# check if file is JPG or JPEG
|
14 |
+
if data[:3] == b"\xff\xd8\xff":
|
15 |
+
if verbose == True:
|
16 |
+
print(filename + " is: JPG/JPEG.")
|
17 |
+
return True
|
18 |
+
|
19 |
+
# check if file is PNG
|
20 |
+
if data[:8] == b"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a":
|
21 |
+
if verbose == True:
|
22 |
+
print(filename + " is: PNG.")
|
23 |
+
return True
|
24 |
+
|
25 |
+
# check if file is GIF
|
26 |
+
if data[:6] in [b"\x47\x49\x46\x38\x37\x61", b"\x47\x49\x46\x38\x39\x61"]:
|
27 |
+
if verbose == True:
|
28 |
+
print(filename + " is: GIF.")
|
29 |
+
return True
|
30 |
+
|
31 |
+
return False
|
32 |
+
|
33 |
+
|
34 |
+
def action(in_path):
|
35 |
+
for root, _, files in os.walk(in_path):
|
36 |
+
for file in files:
|
37 |
+
file_path = os.path.join(root, file)
|
38 |
+
print(file_path)
|
39 |
+
|
40 |
+
with open(file_path, "rb") as f:
|
41 |
+
if is_image(file_path):
|
42 |
+
# it's a jpeg
|
43 |
+
pass
|
44 |
+
else:
|
45 |
+
# print(file_path, "is not valid jpeg")
|
46 |
+
os.remove(file_path)
|
47 |
+
|
48 |
+
|
49 |
+
CURR_DIR = os.path.dirname(os.path.abspath(__file__))
|
50 |
+
action(CURR_DIR + "/data/train")
|
51 |
+
action(CURR_DIR + "/data/validate")
|
data/train/c_0000000003.jpg
ADDED
Git LFS Details
|
data/train/c_0000000004.jpg
ADDED
Git LFS Details
|
data/train/c_0000000005.jpg
ADDED
Git LFS Details
|
data/train/c_0000000006.jpg
ADDED
Git LFS Details
|
data/train/c_0000000007.jpg
ADDED
Git LFS Details
|
data/train/c_0000000008.jpg
ADDED
Git LFS Details
|
data/train/c_0000000009.jpg
ADDED
Git LFS Details
|
data/train/c_0000000010.jpg
ADDED
Git LFS Details
|
data/train/c_0000000011.jpg
ADDED
Git LFS Details
|
data/train/c_0000000012.jpg
ADDED
Git LFS Details
|
data/train/c_0000000013.jpg
ADDED
Git LFS Details
|
data/train/c_0000000014.jpg
ADDED
Git LFS Details
|
data/train/c_0000000015.jpg
ADDED
Git LFS Details
|
data/train/c_0000000016.jpg
ADDED
Git LFS Details
|
data/train/c_0000000018.jpg
ADDED
Git LFS Details
|
data/train/c_0000000019.jpg
ADDED
Git LFS Details
|
data/train/c_0000000021.jpg
ADDED
Git LFS Details
|
data/train/c_0000000022.jpg
ADDED
Git LFS Details
|
data/train/c_0000000024.jpg
ADDED
Git LFS Details
|
data/train/c_0000000025.jpg
ADDED
Git LFS Details
|
data/train/c_0000000026.jpg
ADDED
Git LFS Details
|
data/train/c_0000000028.jpg
ADDED
Git LFS Details
|
data/train/c_0000000029.jpg
ADDED
Git LFS Details
|
data/train/c_0000000031.jpg
ADDED
Git LFS Details
|
data/train/c_0000000032.jpg
ADDED
Git LFS Details
|
data/train/c_0000000033.jpg
ADDED
Git LFS Details
|
data/train/c_0000000035.jpg
ADDED
Git LFS Details
|
data/train/c_0000000036.jpg
ADDED
Git LFS Details
|
data/train/c_0000000037.jpg
ADDED
Git LFS Details
|
data/train/c_0000000039.jpg
ADDED
Git LFS Details
|
data/train/c_0000000040.jpg
ADDED
Git LFS Details
|
data/train/c_0000000041.jpg
ADDED
Git LFS Details
|
data/train/c_0000000042.jpg
ADDED
Git LFS Details
|
data/train/c_0000000043.jpg
ADDED
Git LFS Details
|
data/train/c_0000000044.jpg
ADDED
Git LFS Details
|
data/train/c_0000000047.jpg
ADDED
Git LFS Details
|
data/train/c_0000000048.jpg
ADDED
Git LFS Details
|
data/train/c_0000000051.jpg
ADDED
Git LFS Details
|
data/train/c_0000000052.jpg
ADDED
Git LFS Details
|
data/train/c_0000000053.jpg
ADDED
Git LFS Details
|
data/train/c_0000000054.jpg
ADDED
Git LFS Details
|
data/train/c_0000000055.jpg
ADDED
Git LFS Details
|
data/train/c_0000000056.jpg
ADDED
Git LFS Details
|
data/train/c_0000000057.jpg
ADDED
Git LFS Details
|
data/train/c_0000000058.jpg
ADDED
Git LFS Details
|
data/train/c_0000000059.jpg
ADDED
Git LFS Details
|
data/train/c_0000000060.jpg
ADDED
Git LFS Details
|
data/train/c_0000000061.jpg
ADDED
Git LFS Details
|
data/train/c_0000000062.jpg
ADDED
Git LFS Details
|