Full face stack that runs entirely in the browser. Detection, 576-point 3D mesh, recognition, anti-spoof, smile — all WebAssembly, zero server. Apache 2.0.
C avx-512avx2biometricsc99computer-visioncpu-inferencedeep-learningedge-aiembedded-aiface-embeddingface-recognitionface-verificationlow-latencyonnx-runtimeproduction-readysimdzero-dependencies
"""Run the original 54 checks and reproduce the additional 100 examples."""
import math
from pathlib import Path
import re
import numpy as np
from verify_54_math_examples import verify
def additional():
def check(n, condition):
assert n == len(checked) + 55 and condition, n
checked.append(n)
checked = []
close = np.isclose
check(55, close(1200*.16/40, 4.8))
check(56, close(2*3/(1000*1.5), .004))
check(57, round(math.degrees(math.acos(32/48)),2)==48.19)
c,s = math.cos(math.pi/6),.5
corners = np.array([[0,0],[0,100],[80,0],[80,100]]) @ [[c,s],[-s,c]]
check(58, np.allclose(np.round(np.ptp(corners,axis=0),2),[119.28,126.60]))
check(59, close((212-2)*1000/700,300))
check(60, round(900-900/1.01,2)==8.91)
A = np.array([[0,-2],[2,0]])
check(61,np.array_equal(A@np.diag([4,1])@A.T,np.diag([4,16])))
check(62,round(2*math.sqrt(-2*math.log(.05)),2)==4.90)
d=np.array([1,2,2,3,80])
check(63,np.argmin([sum(abs(d-x)) for x in range(81)])==2 and close(d.mean(),17.6))
check(64,math.comb(3,2)/math.comb(5,2)==.3 and .7**13<=.01<.7**12)
check(65,close(math.sqrt(.8*.6125),.7))
check(66,math.sqrt(.55)<.75 and .75**2==.5625)
check(67,round(72*90/(16000-72*90),3)==.681)
check(68,round(1/math.sqrt(.4),3)==1.581)
check(69,close((7/8)**2,.765625) and round((79/80)**2,4)==.9752)
check(70,832*(480-468)==9984)
check(71,6/14>.4 and 2/18<.4 and 1.6>.9)
check(72,round((9*100+4*106)/13,2)==101.85 and close(1/(1/4+1/9),36/13))
check(73,round(100*.009/(.009+.0099),2)==47.62)
check(74,close(.85+.8-.72,.93))
check(75,round((9*32*64)/(9*32+32*64),2)==7.89)
receptive = {2*j+k for j in range(3) for k in range(3)}
check(76,len(receptive)==7)
check(77,9*64*96//8==6912)
check(78,(1+(3-1)*2)*640*16*4==204800)
check(79,8*50==4*100 and 8*49<4*100)
check(80,round(1000*128/(32*1024),3)==3.906)
W=np.array([2,-1]);m=np.array([3,4]);x=np.array([5,8])
check(81,5-W@m==3 and W@(x-m)+5==W@x+3)
a=math.log(2)/2
check(82,abs(math.exp(a)-sum(a**i/math.factorial(i) for i in range(6)))<=math.exp(a)*a**6/720<3.41e-6)
u=(np.arange(10000)+.5)/10000
check(83,close(np.mean(u*u)/np.mean((np.round(u)-u)**2),4))
check(84,np.spacing(np.float32(1e10))==1024 and close(np.var([1e5-.01,1e5+.01]),1e-4))
x=np.array([2.,0.]); y=x+[0,.01]
check(85,np.linalg.norm(y/np.linalg.norm(y)-x/2)<=.01)
check(86,close(np.dot([2,1],[2,-1])/5,.6))
L=np.diag([2,3])
check(87,np.allclose(np.linalg.inv(L)@np.diag([4,9])@np.linalg.inv(L).T,np.eye(2)))
check(88,round(100*13/14,2)==92.86 and 14-13==1)
x=np.array([1.,.2]);y=np.array([2.,.1])
check(89,close(x@y-x[0]*y[0],.02))
check(90,close(np.mean([.1,.3,.2]),.2))
Y=np.array([[0.,1.],[-1.,0.]])
U,_,Vt=np.linalg.svd(np.eye(2).T@Y)
check(91,np.allclose(U@Vt,Y))
check(92,close(.12/6,.02))
check(93,round(math.degrees(math.atan2(1,9)),2)==6.34)
x=np.array([1.,0]);y=np.array([-.5,math.sqrt(.75)])
check(94,close((x+y)@x/np.linalg.norm(x+y),.5))
groups=[[1,4,7,10],[9,6,3,0]]
check(95,sorted([x for g in groups for x in sorted(g)[-2:]])[-2:]==[9,10])
import heapq
check(96,heapq.nlargest(5,range(1000))==list(range(999,994,-1)))
ranked=list(range(30))
check(97,all([x for x in ranked[:6] if x!=j][:5]==[x for x in ranked if x!=j][:5] for j in ranked))
check(98,heapq.nlargest(5,ranked+[-2,40])==heapq.nlargest(5,ranked[-5:]+[-2,40]))
q=np.array([3,-1])
check(99,sum((q-np.clip(q,0,2))**2)==2)
check(100,abs(.2-1.1)>.8)
check(101,sum(x>.5 for x in [.1,.4,.7,.9])==2)
check(102,close(3+.7*10,10))
check(103,round(100*(2/3)**8,2)==3.90)
check(104,.8**14<=.05<.8**13)
check(105,close(50000*.12*.002,12))
check(106,close((15+45)/1000,.06))
check(107,close(np.dot([.1,-.1],[.05,.01]),.004))
check(108,round(100*.8*.95/(.8*.96+.2*.02),2)==98.45)
check(109,close((.9/.1)*(.1/.9),1))
check(110,all(.5<min(10*(1-p),2*p) for p in (.26,.5,.94)))
check(111,round(math.sqrt((.01*.99+.03*.97)/1000),5)==.00624)
check(112,close(.2*.04+.8*.01,.016))
check(113,close(.75*.1,.25*.3))
check(114,round(100*(1-.999**5),3)==.499)
check(115,close(200*.2**2/2,4))
check(116,round(math.sqrt(2*4/.1**2),2)==28.28)
times=np.arange(4)
check(117,close(4/sum((times-times.mean())**2),.8))
check(118,close(math.exp(-.02/.2)**2,math.exp(-.04/.2)))
e=np.array([4,3])
check(119,close(e@np.linalg.solve(np.diag([4,9]),e),5) and round(100*math.exp(-2.5),2)==8.21)
check(120,round(-1000*math.log(.99)/.2,2)==50.25)
check(121,close(30/80,.375))
r,v=np.array([10,2]),np.array([-5,0])
t=np.clip(-(r@v)/(v@v),0,3)
check(122,t==2 and np.linalg.norm(r+t*v)==2)
check(123,45>300*.1)
check(124,close(100*(.06-.02)-3,1))
check(125,40*.2==8)
check(126,1/(50-30)==.05 and 1/(50-45)==.2)
check(127,round(1000*20*.02**2/(2*(1-.4)),2)==6.67)
check(128,(80-50)*2/(50-20)==2)
check(129,sum(.5**i for i in range(3))==1.75 and .5**3==.125)
check(130,round(8000/.0003/1e6,2)==26.67)
check(131,close(.8/.002,400))
check(132,(256<<20)//(3840*2160*3)==10)
check(133,[round(1000*((b-1)/(2*50)+t)) for b,t in [(2,.028),(4,.040)]]==[38,70])
check(134,round(.95**4,4)==.8145 and round(.95**.25,4)==.9873)
check(135,math.sqrt(2*.5)==1)
check(136,round(100*(1-(.9*68+.1*148)/(.9*70+.1*160)),2)==3.80)
check(137,.05*100==5 and .0005*100==.05)
check(138,close(.1*10+.9*90,82) and close(.9*12+.1*100,20.8))
check(139,16*.5**5==.5)
check(140,1000/200==5)
check(141,round(2*(1+10)/2**10,5)==.02148)
check(142,math.ceil(100/(.8*40))==4 and round(100*(100/(3*.8*40)-1),2)==4.17)
check(143,sorted([5]*96+[500]*4)[94]==5 and np.percentile([500]*4,95)==500)
check(144,round(100*(1-math.comb(18,5)/math.comb(20,5)),2)==44.74)
check(145,close(.9*.96,.864))
check(146,close(.82*.95-.8*.95,.019) and close(.8*.97-.8*.95,.016))
check(147,min(t for t,err in [(10,.05),(14,.02),(18,.03)] if err<=.025)==14)
check(148,close(.75*.01+.25*.05,.02) and .75*30+.25*10==25)
check(149,4+20*.4==12)
check(150,close(.3+(1-.1)*3,3))
check(151,close((14+15)/1000,.029))
check(152,32*(112**2*3+100)==1207424 and 1920*1080*3==6220800)
check(153,.02**3<1e-4<.02**2)
check(154,12*(1-1/2)<40*(1-1/1.2))
assert checked == list(range(55,155))
if __name__ == "__main__":
verify()
additional()
source=Path(__file__).resolve().parents[1]/"docs/research/154_math_solutions_ru.md"
numbers=re.findall(r"^\*\*(\d+)\.",source.read_text(),re.MULTILINE)
assert list(map(int,numbers))==list(range(1,155))
print("Verified examples and numbering for all 154 problems")