File size: 1,094 Bytes
4854e2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
content = open('app/core/config.py', 'r', newline='').read()

old = (
    '    FACE_RECOGNITION_THRESHOLD: float = 0.5\r\n'
    '    FACE_EMBEDDING_DIM: int = int(os.getenv("FACE_EMBEDDING_DIM", "512"))\r\n'
)
new = (
    '    FACE_RECOGNITION_THRESHOLD: float = 0.5\r\n'
    '    FACE_EMBEDDING_DIM: int = int(os.getenv("FACE_EMBEDDING_DIM", "512"))\r\n'
    '\r\n'
    '    # Face angle thresholds (yaw degrees)\r\n'
    '    FACE_ANGLE_FRONTAL_MAX_YAW: float = float(os.getenv("FACE_ANGLE_FRONTAL_MAX_YAW", "20"))\r\n'
    '    FACE_ANGLE_HALF_PROFILE_MAX_YAW: float = float(os.getenv("FACE_ANGLE_HALF_PROFILE_MAX_YAW", "55"))\r\n'
    '    # When False, registration skips the 3-angle requirement\r\n'
    '    FACE_ANGLE_REQUIRE_VALIDATION: bool = os.getenv("FACE_ANGLE_REQUIRE_VALIDATION", "True").lower() == "true"\r\n'
)

if old in content:
    content = content.replace(old, new, 1)
    open('app/core/config.py', 'w', newline='').write(content)
    print('PATCHED OK')
else:
    print('NOT FOUND')
    idx = content.find('FACE_EMBEDDING_DIM')
    print(repr(content[idx-50:idx+120]))