louiscklaw commited on
Commit
e646f73
·
1 Parent(s): a20a098

update beach_512,

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
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/000001.jpg ADDED

Git LFS Details

  • SHA256: 44693f230a98c886e399ca1307a10925e7171204e9b5b818bc48e016e07b941f
  • Pointer size: 130 Bytes
  • Size of remote file: 26.2 kB
data/train/000002.jpg ADDED

Git LFS Details

  • SHA256: 5f0262cdc24e1df756742e86113b924ade1f58786e2121f486ea4c4ab63589c2
  • Pointer size: 130 Bytes
  • Size of remote file: 37.6 kB
data/train/000005.jpg ADDED

Git LFS Details

  • SHA256: 8ae9657a7929f02c91a610cfc240b73576c2a33eec74ae0c2663798b49975106
  • Pointer size: 130 Bytes
  • Size of remote file: 41.9 kB
data/train/000010.jpg ADDED

Git LFS Details

  • SHA256: 343fa1f32893144eccb8bd371c31f59174d7d3987c58adc3dc8f3587349b4081
  • Pointer size: 130 Bytes
  • Size of remote file: 38 kB
data/train/000011.jpg ADDED

Git LFS Details

  • SHA256: 84a29eb36a0bff46762f6739181631591d904250e082d2487cb258b6bd220c80
  • Pointer size: 130 Bytes
  • Size of remote file: 53.4 kB
data/train/000013.jpg ADDED

Git LFS Details

  • SHA256: dc577e4d5ddf40831a8cd98dbf3dd6339649ec616d6158ea513aeebe1e409962
  • Pointer size: 130 Bytes
  • Size of remote file: 59.5 kB
data/train/000015.jpg ADDED

Git LFS Details

  • SHA256: 75db09bdd939a0aa2658bffce6bbc01464ac987e69bdde538d1954e955f47ca0
  • Pointer size: 130 Bytes
  • Size of remote file: 44.5 kB
data/train/000017.jpg ADDED

Git LFS Details

  • SHA256: 934fd25e83f61afb0d280c5b2bf2f55b412dadfdbfe2c8d02db343d8961d9886
  • Pointer size: 130 Bytes
  • Size of remote file: 54.3 kB
data/train/000020.jpg ADDED

Git LFS Details

  • SHA256: fa6f9ef5dc50439d2f6d9373afce96195b0ef61c338d88136872b2d2bedb54e6
  • Pointer size: 130 Bytes
  • Size of remote file: 46 kB
data/train/000029.jpg ADDED

Git LFS Details

  • SHA256: f3d330ba729051933d72eff63dbb529ae46fae2846ba7efb4c97af374660ff8e
  • Pointer size: 130 Bytes
  • Size of remote file: 53.5 kB
data/train/000038.jpg ADDED

Git LFS Details

  • SHA256: d127831faab33defc782385b563a43493815689bf184b4e8ba89b4ede2858315
  • Pointer size: 130 Bytes
  • Size of remote file: 50 kB
data/train/000042.jpg ADDED

Git LFS Details

  • SHA256: ec6094dd9ce5a83bd2c8d26c42852afd48fc18db94642648a177df690856cc52
  • Pointer size: 130 Bytes
  • Size of remote file: 34.7 kB
data/train/000046.jpg ADDED

Git LFS Details

  • SHA256: 6cdf01a5f80095b922bd6ee9dcd3720749a2008373ff9507a5b23d737e45d458
  • Pointer size: 130 Bytes
  • Size of remote file: 39.6 kB
data/train/000053.jpg ADDED

Git LFS Details

  • SHA256: 1cd9c0eb9a07a1e807fc0e227d727b1bdd3bd7efbe8d573029950709dc49baaa
  • Pointer size: 130 Bytes
  • Size of remote file: 76.1 kB
data/train/000056.jpg ADDED

Git LFS Details

  • SHA256: 18d8a618a0e1f38c1702d0886500b4d9ed696fb2f4ce5196b2475066e956a39e
  • Pointer size: 130 Bytes
  • Size of remote file: 28.5 kB
data/train/000061.jpg ADDED

Git LFS Details

  • SHA256: 3293985e030f3879dcdb88af8abf847d6920488bb3727b82237c78df9114dd3f
  • Pointer size: 130 Bytes
  • Size of remote file: 33.1 kB
data/train/000063.jpg ADDED

Git LFS Details

  • SHA256: 32e371fd657404e57776eadcf6c07e02164d2752c99bd66a04187b8b69a51145
  • Pointer size: 130 Bytes
  • Size of remote file: 53.9 kB
data/train/000069.jpg ADDED

Git LFS Details

  • SHA256: de21082c8a5bd3cec91af9c3ec2f3528f1d165e4f6557877876e01e00786cebd
  • Pointer size: 130 Bytes
  • Size of remote file: 30.8 kB
data/train/000073.jpg ADDED

Git LFS Details

  • SHA256: a95ff9c28628e49cae97f26c8800e9ddf5df377cd13c45afb4154108e3b372e4
  • Pointer size: 130 Bytes
  • Size of remote file: 32.5 kB
data/train/000074.jpg ADDED

Git LFS Details

  • SHA256: 6c4d4d469148c22eac024706de3f926c3bc217008e23fb04379c044479384da4
  • Pointer size: 130 Bytes
  • Size of remote file: 31.5 kB
data/train/000077.jpg ADDED

Git LFS Details

  • SHA256: ea1ad1fcc9d9db3366ef5e15d86b9fe11f3d77e1a8963475f810c2aba80060e1
  • Pointer size: 130 Bytes
  • Size of remote file: 42.2 kB
data/train/000079.jpg ADDED

Git LFS Details

  • SHA256: 2d22f53be5fb65cd376993f816cafe50f024b3363a872a84c69c914f5ef48b94
  • Pointer size: 130 Bytes
  • Size of remote file: 28.5 kB
data/train/000083.jpg ADDED

Git LFS Details

  • SHA256: 6ee1abcd1af374b5e837154125d236853685bcfe75cedecbf7ea2fb86f3f5f82
  • Pointer size: 130 Bytes
  • Size of remote file: 43.2 kB
data/train/000085.jpg ADDED

Git LFS Details

  • SHA256: 64f2b2afe51f7f7ab84221407d0fac586b2ce4813e69b844e94f507feb93774f
  • Pointer size: 130 Bytes
  • Size of remote file: 25.8 kB
data/train/000088.jpg ADDED

Git LFS Details

  • SHA256: 15c32c07b649eba2df96c1ed63afb2e1a0cb22280f7378e3450d7353ecc4170b
  • Pointer size: 130 Bytes
  • Size of remote file: 22 kB
data/train/000091.jpg ADDED

Git LFS Details

  • SHA256: dbc0c431bcc00b516e74ad6f049fd9eec34f863cd18a2ff98c02b077e06d7d0b
  • Pointer size: 130 Bytes
  • Size of remote file: 49.5 kB
data/train/000093.jpg ADDED

Git LFS Details

  • SHA256: c56672a8ede97b72281705b40e90ab0c11e44451994b88d45bddb7467b2cb26c
  • Pointer size: 130 Bytes
  • Size of remote file: 54.9 kB
data/train/000095.jpg ADDED

Git LFS Details

  • SHA256: 8c36763045d12ab42bdcb35a36fee9ed2a5da9b605b5095c73054754b78ce346
  • Pointer size: 130 Bytes
  • Size of remote file: 39.2 kB
data/train/000099.jpg ADDED

Git LFS Details

  • SHA256: f14ba656ce9e334e5c789c53dc3e94c97bd3b02e3438ffb5b64baf2b79cae83e
  • Pointer size: 130 Bytes
  • Size of remote file: 44.1 kB
data/train/000100.jpg ADDED

Git LFS Details

  • SHA256: 9841c51ff7ea50b3e1eaa03262d1c3f4c86d7bb4f60016a9c308e3bcefdd3a77
  • Pointer size: 130 Bytes
  • Size of remote file: 29.2 kB
data/train/000101.jpg ADDED

Git LFS Details

  • SHA256: 0b07acf1bb1765f7339293aa3d742902186c040eb4c44401e50fb4823f3630a7
  • Pointer size: 130 Bytes
  • Size of remote file: 66.2 kB
data/train/000104.jpg ADDED

Git LFS Details

  • SHA256: e7315d24bb841956b14e7d8f3c5ef19dc70e696b90b6ac43a3d76236fb90ef7f
  • Pointer size: 130 Bytes
  • Size of remote file: 36.9 kB
data/train/000107.jpg ADDED

Git LFS Details

  • SHA256: eb89885ce42b926449018c0bb1f34176465c1cc79fa4bed5b993bce98af1c63e
  • Pointer size: 130 Bytes
  • Size of remote file: 35.2 kB
data/train/000111.jpg ADDED

Git LFS Details

  • SHA256: 3a87d34544181fd1ef47ed30c75a565bcfad1465a8449df8fdcd1e2f20322248
  • Pointer size: 130 Bytes
  • Size of remote file: 44.2 kB
data/train/000118.jpg ADDED

Git LFS Details

  • SHA256: ce69bf9325101e9aadd741fc5f13b620ee2aff6d2b4a3455426bd87fdef0ec23
  • Pointer size: 130 Bytes
  • Size of remote file: 42 kB
data/train/000119.jpg ADDED

Git LFS Details

  • SHA256: bc7eecbb297beaa1067a87c105d98a65f60af79c3a226fa36b6bf6d6f11913b9
  • Pointer size: 130 Bytes
  • Size of remote file: 41.6 kB
data/train/000123.jpg ADDED

Git LFS Details

  • SHA256: 731aa3a4184482252831fbb828c5514416625a5c785a3aabfc2e034ec0ec06a2
  • Pointer size: 130 Bytes
  • Size of remote file: 41.9 kB
data/train/000125.jpg ADDED

Git LFS Details

  • SHA256: e21adc274cfa211b0568ca9198f8b1aefeda2840f7e57061c06f3e1c7a6b0fca
  • Pointer size: 130 Bytes
  • Size of remote file: 41.6 kB
data/train/000128.jpg ADDED

Git LFS Details

  • SHA256: e3c5c7f73c6041cc8751d05d6fb69e8bab116df1c22583f869d65cc45425631f
  • Pointer size: 130 Bytes
  • Size of remote file: 30.1 kB
data/train/000133.jpg ADDED

Git LFS Details

  • SHA256: d59de3d444fe4f4437d547d2914ab23663d48f2306b24cfce55a3a82b60e96a8
  • Pointer size: 130 Bytes
  • Size of remote file: 45.3 kB
data/train/000134.jpg ADDED

Git LFS Details

  • SHA256: 7f9d249f37d7634a8505801c590d2a36bc2350be954f6f1e28e7db3c5cfa0e08
  • Pointer size: 130 Bytes
  • Size of remote file: 30.6 kB
data/train/000139.jpg ADDED

Git LFS Details

  • SHA256: 049d2645b65c0404fa5c6a6de64639f680e0874b2bbf757480167182abada33d
  • Pointer size: 130 Bytes
  • Size of remote file: 52.2 kB
data/train/000140.jpg ADDED

Git LFS Details

  • SHA256: e9f70bd6be72667c6db74b509b0d38d38e5395357c00b3ea7ef4e373eca79e4d
  • Pointer size: 130 Bytes
  • Size of remote file: 38 kB
data/train/000141.jpg ADDED

Git LFS Details

  • SHA256: 4650e7d5b5cf015986c290bf7adc457d44cffe8c73866c40387f42d57e7f57fe
  • Pointer size: 130 Bytes
  • Size of remote file: 47.3 kB
data/train/000150.jpg ADDED

Git LFS Details

  • SHA256: b504bc35bb387218c011ab6a4c029f4b387d5d57f6a7cf5756361eaf17280c08
  • Pointer size: 130 Bytes
  • Size of remote file: 37.9 kB
data/train/000156.jpg ADDED

Git LFS Details

  • SHA256: 24e62abcf7bfa0f59e66156aba929933184a0554d2167c2932bc35e04037e336
  • Pointer size: 130 Bytes
  • Size of remote file: 45.2 kB
data/train/000157.jpg ADDED

Git LFS Details

  • SHA256: 48241521b32bd03c40ec0223051a239de82419678c101e97597ce3c6c267b853
  • Pointer size: 130 Bytes
  • Size of remote file: 45.2 kB
data/train/000159.jpg ADDED

Git LFS Details

  • SHA256: 63df5bac40aa3e0b3caa2a3b5bcc230ca54ebb111a64c682d1559c966e84131e
  • Pointer size: 130 Bytes
  • Size of remote file: 37.7 kB
data/train/000172.jpg ADDED

Git LFS Details

  • SHA256: e71b004cf5b8fb0a7a1130533df6614b811a0de2961866ceed5eab14541d6b0f
  • Pointer size: 130 Bytes
  • Size of remote file: 50.1 kB