Initial commit (squashed)

This commit is contained in:
2019-12-25 08:55:07 -05:00
commit 0bfac5fdc0
25 changed files with 694 additions and 0 deletions

BIN
bench/1000px Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

BIN
bench/100px Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
bench/2000px Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

BIN
bench/200px Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

BIN
bench/3000px Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 KiB

BIN
bench/300px Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

BIN
bench/4000px Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

BIN
bench/500px Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

BIN
bench/6000px Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 MiB

BIN
bench/8000px Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

38
bench/benchmark.py Normal file
View File

@@ -0,0 +1,38 @@
#!/usr/bin/env python
import timeit
import sys
IMAGE = sys.argv[1]
COUNT = 20
SIZE = 8
def print_result(method, time):
print("%s_%s,%d" % (IMAGE, method, time / COUNT * 1000000000))
print_result("phash", timeit.timeit(
setup="from imagehash import phash \n"
"from PIL import Image",
stmt="phash(Image.open('%s'), hash_size=%d)" % (IMAGE, SIZE),
number=COUNT
))
print_result("whash", timeit.timeit(
setup="from imagehash import whash \n"
"from PIL import Image",
stmt="whash(Image.open('%s'), hash_size=%d, remove_max_haar_ll=False)" % (IMAGE, SIZE),
number=COUNT
))
print_result("dhash", timeit.timeit(
setup="from imagehash import dhash \n"
"from PIL import Image",
stmt="dhash(Image.open('%s'), hash_size=%d)" % (IMAGE, SIZE),
number=COUNT
))
print_result("ahash", timeit.timeit(
setup="from imagehash import average_hash \n"
"from PIL import Image",
stmt="average_hash(Image.open('%s'), hash_size=%d)" % (IMAGE, SIZE),
number=COUNT
))

81
bench/results/bench.csv Normal file
View File

@@ -0,0 +1,81 @@
100px_phash,1501752
100px_whash,1191232
100px_dhash,627767
100px_ahash,559005
200px_phash,1890701
200px_whash,1705581
200px_dhash,764158
200px_ahash,773574
300px_phash,3349884
300px_whash,3585630
300px_dhash,2165022
300px_ahash,2138236
500px_phash,8181995
500px_whash,16893975
500px_dhash,6583327
500px_ahash,6129121
1000px_phash,33332575
1000px_whash,32719635
1000px_dhash,22770614
1000px_ahash,17089768
2000px_phash,66180354
2000px_whash,101643309
2000px_dhash,55663749
2000px_ahash,57924298
3000px_phash,125681339
3000px_whash,228129635
3000px_dhash,138621595
3000px_ahash,97757975
4000px_phash,275259074
4000px_whash,501619747
4000px_dhash,207196780
4000px_ahash,302886693
6000px_phash,509748444
6000px_whash,749504047
6000px_dhash,510110532
6000px_ahash,651134350
8000px_phash,804032051
8000px_whash,1561515488
8000px_dhash,935896765
8000px_ahash,797512191
100px_phash,156781
100px_whash,173199
100px_dhash,90662.8
100px_ahash,101213
200px_phash,700678
200px_whash,859678
200px_dhash,452687
200px_ahash,387735
300px_phash,1.25202e+06
300px_whash,1.8245e+06
300px_dhash,1.25765e+06
300px_ahash,973228
500px_phash,2.38869e+06
500px_whash,1.1267e+07
500px_dhash,2.17194e+06
500px_ahash,2.2334e+06
1000px_phash,5.74643e+06
1000px_whash,1.16069e+07
1000px_dhash,5.07346e+06
1000px_ahash,2.5366e+06
2000px_phash,2.65802e+07
2000px_whash,6.72166e+07
2000px_dhash,1.84348e+07
2000px_ahash,8.71788e+06
3000px_phash,4.03586e+07
3000px_whash,8.8327e+07
3000px_dhash,3.53093e+07
3000px_ahash,1.79755e+07
4000px_phash,8.40194e+07
4000px_whash,4.82593e+08
4000px_dhash,9.43476e+07
4000px_ahash,6.51547e+07
6000px_phash,2.28308e+08
6000px_whash,4.19073e+08
6000px_dhash,2.12647e+08
6000px_ahash,2.03283e+08
8000px_phash,2.38032e+08
8000px_whash,1.19931e+09
8000px_dhash,3.05067e+08
8000px_ahash,2.73826e+08
1 100px_phash 1501752
2 100px_whash 1191232
3 100px_dhash 627767
4 100px_ahash 559005
5 200px_phash 1890701
6 200px_whash 1705581
7 200px_dhash 764158
8 200px_ahash 773574
9 300px_phash 3349884
10 300px_whash 3585630
11 300px_dhash 2165022
12 300px_ahash 2138236
13 500px_phash 8181995
14 500px_whash 16893975
15 500px_dhash 6583327
16 500px_ahash 6129121
17 1000px_phash 33332575
18 1000px_whash 32719635
19 1000px_dhash 22770614
20 1000px_ahash 17089768
21 2000px_phash 66180354
22 2000px_whash 101643309
23 2000px_dhash 55663749
24 2000px_ahash 57924298
25 3000px_phash 125681339
26 3000px_whash 228129635
27 3000px_dhash 138621595
28 3000px_ahash 97757975
29 4000px_phash 275259074
30 4000px_whash 501619747
31 4000px_dhash 207196780
32 4000px_ahash 302886693
33 6000px_phash 509748444
34 6000px_whash 749504047
35 6000px_dhash 510110532
36 6000px_ahash 651134350
37 8000px_phash 804032051
38 8000px_whash 1561515488
39 8000px_dhash 935896765
40 8000px_ahash 797512191
41 100px_phash 156781
42 100px_whash 173199
43 100px_dhash 90662.8
44 100px_ahash 101213
45 200px_phash 700678
46 200px_whash 859678
47 200px_dhash 452687
48 200px_ahash 387735
49 300px_phash 1.25202e+06
50 300px_whash 1.8245e+06
51 300px_dhash 1.25765e+06
52 300px_ahash 973228
53 500px_phash 2.38869e+06
54 500px_whash 1.1267e+07
55 500px_dhash 2.17194e+06
56 500px_ahash 2.2334e+06
57 1000px_phash 5.74643e+06
58 1000px_whash 1.16069e+07
59 1000px_dhash 5.07346e+06
60 1000px_ahash 2.5366e+06
61 2000px_phash 2.65802e+07
62 2000px_whash 6.72166e+07
63 2000px_dhash 1.84348e+07
64 2000px_ahash 8.71788e+06
65 3000px_phash 4.03586e+07
66 3000px_whash 8.8327e+07
67 3000px_dhash 3.53093e+07
68 3000px_ahash 1.79755e+07
69 4000px_phash 8.40194e+07
70 4000px_whash 4.82593e+08
71 4000px_dhash 9.43476e+07
72 4000px_ahash 6.51547e+07
73 6000px_phash 2.28308e+08
74 6000px_whash 4.19073e+08
75 6000px_dhash 2.12647e+08
76 6000px_ahash 2.03283e+08
77 8000px_phash 2.38032e+08
78 8000px_whash 1.19931e+09
79 8000px_dhash 3.05067e+08
80 8000px_ahash 2.73826e+08

81
bench/results/bench2.csv Normal file
View File

@@ -0,0 +1,81 @@
100px_phash,1546245
100px_whash,1142629
100px_dhash,422119
100px_ahash,459319
200px_phash,2289901
200px_whash,1982601
200px_dhash,877761
200px_ahash,893851
300px_phash,5754956
300px_whash,4130921
300px_dhash,2337779
300px_ahash,3306587
500px_phash,16423604
500px_whash,25278172
500px_dhash,13543857
500px_ahash,12730359
1000px_phash,38916426
1000px_whash,43298265
1000px_dhash,22826313
1000px_ahash,23075597
2000px_phash,108740058
2000px_whash,130074288
2000px_dhash,86906159
2000px_ahash,82882133
3000px_phash,157641043
3000px_whash,194007627
3000px_dhash,115356997
3000px_ahash,167002746
4000px_phash,320478682
4000px_whash,611399093
4000px_dhash,258676239
4000px_ahash,278319008
6000px_phash,663131052
6000px_whash,968925343
6000px_dhash,603457884
6000px_ahash,590223791
8000px_phash,968315239
8000px_whash,2128619381
8000px_dhash,810395862
8000px_ahash,825277357
100px_phash,172159
100px_whash,289971
100px_dhash,114212
100px_ahash,98125.5
200px_phash,367338
200px_whash,656732
200px_dhash,249119
200px_ahash,343462
300px_phash,1.28685e+06
300px_whash,1.39146e+06
300px_dhash,1.14464e+06
300px_ahash,900021
500px_phash,2.22673e+06
500px_whash,7.74973e+06
500px_dhash,2.12625e+06
500px_ahash,2.89128e+06
1000px_phash,7.79976e+06
1000px_whash,1.70092e+07
1000px_dhash,7.78873e+06
1000px_ahash,2.82737e+06
2000px_phash,2.49954e+07
2000px_whash,1.24924e+08
2000px_dhash,4.11592e+07
2000px_ahash,2.0187e+07
3000px_phash,3.89911e+07
3000px_whash,9.88339e+07
3000px_dhash,3.39018e+07
3000px_ahash,2.53518e+07
4000px_phash,8.36112e+07
4000px_whash,2.41845e+08
4000px_dhash,4.09667e+07
4000px_ahash,4.06429e+07
6000px_phash,1.79905e+08
6000px_whash,3.62966e+08
6000px_dhash,1.73798e+08
6000px_ahash,1.19691e+08
8000px_phash,2.35173e+08
8000px_whash,1.18053e+09
8000px_dhash,2.61731e+08
8000px_ahash,2.33739e+08
1 100px_phash 1546245
2 100px_whash 1142629
3 100px_dhash 422119
4 100px_ahash 459319
5 200px_phash 2289901
6 200px_whash 1982601
7 200px_dhash 877761
8 200px_ahash 893851
9 300px_phash 5754956
10 300px_whash 4130921
11 300px_dhash 2337779
12 300px_ahash 3306587
13 500px_phash 16423604
14 500px_whash 25278172
15 500px_dhash 13543857
16 500px_ahash 12730359
17 1000px_phash 38916426
18 1000px_whash 43298265
19 1000px_dhash 22826313
20 1000px_ahash 23075597
21 2000px_phash 108740058
22 2000px_whash 130074288
23 2000px_dhash 86906159
24 2000px_ahash 82882133
25 3000px_phash 157641043
26 3000px_whash 194007627
27 3000px_dhash 115356997
28 3000px_ahash 167002746
29 4000px_phash 320478682
30 4000px_whash 611399093
31 4000px_dhash 258676239
32 4000px_ahash 278319008
33 6000px_phash 663131052
34 6000px_whash 968925343
35 6000px_dhash 603457884
36 6000px_ahash 590223791
37 8000px_phash 968315239
38 8000px_whash 2128619381
39 8000px_dhash 810395862
40 8000px_ahash 825277357
41 100px_phash 172159
42 100px_whash 289971
43 100px_dhash 114212
44 100px_ahash 98125.5
45 200px_phash 367338
46 200px_whash 656732
47 200px_dhash 249119
48 200px_ahash 343462
49 300px_phash 1.28685e+06
50 300px_whash 1.39146e+06
51 300px_dhash 1.14464e+06
52 300px_ahash 900021
53 500px_phash 2.22673e+06
54 500px_whash 7.74973e+06
55 500px_dhash 2.12625e+06
56 500px_ahash 2.89128e+06
57 1000px_phash 7.79976e+06
58 1000px_whash 1.70092e+07
59 1000px_dhash 7.78873e+06
60 1000px_ahash 2.82737e+06
61 2000px_phash 2.49954e+07
62 2000px_whash 1.24924e+08
63 2000px_dhash 4.11592e+07
64 2000px_ahash 2.0187e+07
65 3000px_phash 3.89911e+07
66 3000px_whash 9.88339e+07
67 3000px_dhash 3.39018e+07
68 3000px_ahash 2.53518e+07
69 4000px_phash 8.36112e+07
70 4000px_whash 2.41845e+08
71 4000px_dhash 4.09667e+07
72 4000px_ahash 4.06429e+07
73 6000px_phash 1.79905e+08
74 6000px_whash 3.62966e+08
75 6000px_dhash 1.73798e+08
76 6000px_ahash 1.19691e+08
77 8000px_phash 2.35173e+08
78 8000px_whash 1.18053e+09
79 8000px_dhash 2.61731e+08
80 8000px_ahash 2.33739e+08

81
bench/results/bench3.csv Normal file
View File

@@ -0,0 +1,81 @@
100px_phash,2382869
100px_whash,1521012
100px_dhash,580412
100px_ahash,603286
200px_phash,1926447
200px_whash,1768162
200px_dhash,774964
200px_ahash,771083
300px_phash,3790657
300px_whash,3626704
300px_dhash,2067537
300px_ahash,2069114
500px_phash,10906352
500px_whash,22738215
500px_dhash,10272449
500px_ahash,9595167
1000px_phash,23141506
1000px_whash,25170109
1000px_dhash,14824129
1000px_ahash,15091460
2000px_phash,57189668
2000px_whash,108344237
2000px_dhash,62995725
2000px_ahash,62746881
3000px_phash,138799963
3000px_whash,217013121
3000px_dhash,106064767
3000px_ahash,161430438
4000px_phash,242516033
4000px_whash,513381749
4000px_dhash,244478546
4000px_ahash,334389817
6000px_phash,541641403
6000px_whash,825888963
6000px_dhash,458842570
6000px_ahash,487875492
8000px_phash,882104246
8000px_whash,1805513081
8000px_dhash,763400049
8000px_ahash,717820524
100px_phash,216477
100px_whash,242169
100px_dhash,105712
100px_ahash,115431
200px_phash,473393
200px_whash,599663
200px_dhash,184172
200px_ahash,206734
300px_phash,886085
300px_whash,1.17681e+06
300px_dhash,758226
300px_ahash,825329
500px_phash,1.92917e+06
500px_whash,7.30992e+06
500px_dhash,2.67147e+06
500px_ahash,2.45408e+06
1000px_phash,5.96402e+06
1000px_whash,9.16642e+06
1000px_dhash,5.30646e+06
1000px_ahash,2.40083e+06
2000px_phash,1.54843e+07
2000px_whash,4.93767e+07
2000px_dhash,1.98073e+07
2000px_ahash,1.07622e+07
3000px_phash,3.11459e+07
3000px_whash,6.19604e+07
3000px_dhash,3.0431e+07
3000px_ahash,1.78016e+07
4000px_phash,7.47504e+07
4000px_whash,2.19254e+08
4000px_dhash,5.78558e+07
4000px_ahash,4.9799e+07
6000px_phash,1.67584e+08
6000px_whash,3.67142e+08
6000px_dhash,1.94565e+08
6000px_ahash,1.40676e+08
8000px_phash,2.0177e+08
8000px_whash,1.36282e+09
8000px_dhash,2.27323e+08
8000px_ahash,2.25973e+08
1 100px_phash 2382869
2 100px_whash 1521012
3 100px_dhash 580412
4 100px_ahash 603286
5 200px_phash 1926447
6 200px_whash 1768162
7 200px_dhash 774964
8 200px_ahash 771083
9 300px_phash 3790657
10 300px_whash 3626704
11 300px_dhash 2067537
12 300px_ahash 2069114
13 500px_phash 10906352
14 500px_whash 22738215
15 500px_dhash 10272449
16 500px_ahash 9595167
17 1000px_phash 23141506
18 1000px_whash 25170109
19 1000px_dhash 14824129
20 1000px_ahash 15091460
21 2000px_phash 57189668
22 2000px_whash 108344237
23 2000px_dhash 62995725
24 2000px_ahash 62746881
25 3000px_phash 138799963
26 3000px_whash 217013121
27 3000px_dhash 106064767
28 3000px_ahash 161430438
29 4000px_phash 242516033
30 4000px_whash 513381749
31 4000px_dhash 244478546
32 4000px_ahash 334389817
33 6000px_phash 541641403
34 6000px_whash 825888963
35 6000px_dhash 458842570
36 6000px_ahash 487875492
37 8000px_phash 882104246
38 8000px_whash 1805513081
39 8000px_dhash 763400049
40 8000px_ahash 717820524
41 100px_phash 216477
42 100px_whash 242169
43 100px_dhash 105712
44 100px_ahash 115431
45 200px_phash 473393
46 200px_whash 599663
47 200px_dhash 184172
48 200px_ahash 206734
49 300px_phash 886085
50 300px_whash 1.17681e+06
51 300px_dhash 758226
52 300px_ahash 825329
53 500px_phash 1.92917e+06
54 500px_whash 7.30992e+06
55 500px_dhash 2.67147e+06
56 500px_ahash 2.45408e+06
57 1000px_phash 5.96402e+06
58 1000px_whash 9.16642e+06
59 1000px_dhash 5.30646e+06
60 1000px_ahash 2.40083e+06
61 2000px_phash 1.54843e+07
62 2000px_whash 4.93767e+07
63 2000px_dhash 1.98073e+07
64 2000px_ahash 1.07622e+07
65 3000px_phash 3.11459e+07
66 3000px_whash 6.19604e+07
67 3000px_dhash 3.0431e+07
68 3000px_ahash 1.78016e+07
69 4000px_phash 7.47504e+07
70 4000px_whash 2.19254e+08
71 4000px_dhash 5.78558e+07
72 4000px_ahash 4.9799e+07
73 6000px_phash 1.67584e+08
74 6000px_whash 3.67142e+08
75 6000px_dhash 1.94565e+08
76 6000px_ahash 1.40676e+08
77 8000px_phash 2.0177e+08
78 8000px_whash 1.36282e+09
79 8000px_dhash 2.27323e+08
80 8000px_ahash 2.25973e+08

37
bench/run.py Normal file
View File

@@ -0,0 +1,37 @@
from subprocess import check_output, DEVNULL
import csv
files = (
"100px",
"200px",
"300px",
"500px",
"1000px",
"2000px",
"3000px",
"4000px",
"6000px",
"8000px",
)
for f in files:
out = check_output(["python", "benchmark.py", f])
print(out.decode(), end="")
print()
for f in files:
out = check_output(["./bm", f, "--benchmark_format=csv"], stderr=DEVNULL)
for line in out.decode().splitlines(keepends=False):
if line.startswith("\"BM_"):
m, _, t, *_ = line.split(",")
if "phash" in m:
method = "phash"
if "dhash" in m:
method = "dhash"
if "ahash" in m:
method = "ahash"
if "whash" in m:
method = "whash"
print("%s_%s,%s" % (f, method, t))