Fidestra commited on
Commit
fe8e910
·
verified ·
1 Parent(s): 7184bdf

Update app and verified guided capture together

Browse files
Files changed (2) hide show
  1. app.py +19 -8
  2. capture_overlay.json +1 -1
app.py CHANGED
@@ -1463,8 +1463,12 @@ def earned_trust_points(signals, api, liveness=None, registry=None, liveness_rou
1463
  # Deepfake, media-integrity and replay rows (incl. M7 screen replay, V1 video replay).
1464
  # Owner (7 Nov): a face-texture reading (D4) alone is not a deepfake verdict (sun or glare smooths skin),
1465
  # so D4 does not zero the deepfake block. Replay, media and model flags still do.
1466
- manipulation = [k for k in ids(1, (1, 2, 3)) if k not in liveness_rows and k not in pulse_rows and k != 'D4']
1467
- manipulation += [k for k, r in rows.items() if r.get('group') == 'Deepfake' and k != 'D4']
 
 
 
 
1468
  phone_pulse = api.get('device_pulse') if isinstance(api.get('device_pulse'), dict) else {}
1469
  pulse = ((phone_pulse.get('status') == 'detected' and not (liveness or {}).get('no_heartbeat'))
1470
  or (api.get('rppg_result') or {}).get('status') == 'research_measurement')
@@ -1492,7 +1496,7 @@ def earned_trust_points(signals, api, liveness=None, registry=None, liveness_rou
1492
  location = [k for k in location if k != 'N6']
1493
  identity, contact = ids(3, (8,)) + ['I6'], ids(3, (9,))
1494
  earned = {
1495
- 'deepfake': assessed('D1') and not flagged(manipulation) and scene.get('level') != 'warning',
1496
  'heartbeat': pulse and not flagged(pulse_rows),
1497
  'kinematics': pose and turned and not flagged(liveness_rows),
1498
  'device': assessed('B12') and camera.get('level') != 'warning', # points per check below
@@ -1505,6 +1509,7 @@ def earned_trust_points(signals, api, liveness=None, registry=None, liveness_rou
1505
  if reasons is not None:
1506
  found = {
1507
  'deepfake': ('Deepfake model did not run' if not assessed('D1') else
 
1508
  f"flagged {first_flag(manipulation)}" if flagged(manipulation) else
1509
  'face seen inside a phone or screen' if scene.get('level') == 'warning' else None),
1510
  'heartbeat': ('no pulse detected' if not pulse else
@@ -1591,6 +1596,8 @@ def install_earned_score(engine):
1591
  _lv_liveness_route.get(), reasons=block_reasons)
1592
  if not points['kinematics'] and 'kinematics' not in block_reasons:
1593
  block_reasons['kinematics'] = 'no head-movement instructions followed'
 
 
1594
  device_checks = points.pop('device_checks', {})
1595
  liveness_report = _lv_device_liveness.get() or {}
1596
  # A missed instruction costs its 2.5 points; it does not by itself force a step-up (owner rule).
@@ -1643,7 +1650,7 @@ def install_earned_score(engine):
1643
  trust_points={'tier_1': points['deepfake'] + points['heartbeat'] + points['kinematics'],
1644
  'tier_2': points['device'] + points['location'],
1645
  'tier_3': points['identity'] + points['contact'], **points},
1646
- device_checks=device_checks, block_reasons=block_reasons)
1647
  result['score'], result['decision'] = 100 - score, decision
1648
  payload = engine.verify_token(api.get('trust_token') or '') if callable(getattr(engine, 'verify_token', None)) else None
1649
  if payload:
@@ -1869,7 +1876,7 @@ def report_headline(rating, raised_flags=None):
1869
 
1870
 
1871
  def report_narrative(rating, tp, fatf=None, scam=False, groups=(), raised_flags=None, software_camera=False,
1872
- hard_stop=False, id_problem=False, automation=False):
1873
  """Plain-language executive summary: why the score, the risk to the firm, and the onboarding action.
1874
  No numbers or technical terms. It says what the checks found, never that identity is proven."""
1875
  groups = set(groups)
@@ -1877,7 +1884,9 @@ def report_narrative(rating, tp, fatf=None, scam=False, groups=(), raised_flags=
1877
  grey_country = not edd_country and 'jurisdiction' in groups # increased-monitoring links: risk-based policy
1878
  missing_only = rating == 'Not assessed' or (raised_flags is False and rating == 'High')
1879
  if tp:
1880
- areas = [('no sign of a deepfake or a replayed recording', tp['deepfake'] > 0 and not hard_stop),
 
 
1881
  ('a pulse-like signal from the face (unvalidated)', tp['heartbeat'] > 0),
1882
  ('head movements as instructed', tp['kinematics'] > 0),
1883
  ('no sign of a modified device or camera software', tp['device'] >= 15),
@@ -1889,7 +1898,7 @@ def report_narrative(rating, tp, fatf=None, scam=False, groups=(), raised_flags=
1889
  if fatf or scam or software_camera or id_problem or automation:
1890
  areas = areas[:3] # Tier 2 and Tier 3 are set aside, not failed: explained below
1891
  good = [a for a, ok in areas if ok]
1892
- gaps = {'no sign of a deepfake or a replayed recording': 'that the video is free of deepfake or replay signs',
1893
  'a pulse-like signal from the face (unvalidated)': 'a pulse-like signal from the face',
1894
  'head movements as instructed': 'that the head movements were completed',
1895
  'no sign of a modified device or camera software': ('that every device check passed' if tp['device'] > 0
@@ -2077,6 +2086,7 @@ def public_report_view(value):
2077
  reasons_in=value.get('block_reasons') if isinstance(value.get('block_reasons'),dict) else {}
2078
  blocks=('deepfake','heartbeat','kinematics','device','location','identity','contact')
2079
  result['block_reasons']={b:str(reasons_in[b])[:120] for b in blocks if isinstance(reasons_in.get(b),str)} if tp else {}
 
2080
  result['device_checks']={k:checks[k] for k,_,most in REPORT_DEVICE_CHECKS
2081
  if type(checks.get(k)) is int and checks[k] in (0,most)} if tp else {}
2082
  if result['device_checks']:
@@ -2090,7 +2100,7 @@ def public_report_view(value):
2090
  result['software_camera'] is True,result['hard_stop'] is True,
2091
  result['id_problem'] is True or (result['step_up_cap'] is True and result['software_camera'] is not True
2092
  and result['id_problem'] is None and result['automation'] is not True),
2093
- result['automation'] is True)
2094
  result['headline']=report_headline(result['risk_rating'],result['raised_flags'])
2095
  result['sanctions_note']=('Confirm any sanctions concern through current sanctions screening.' if 'SAN-01' in result['risk_codes'] else
2096
  'Sanctions-list screening is not included in this demo and must be completed separately.')
@@ -2213,6 +2223,7 @@ def install_report_restore(engine):
2213
  assessed=bool(api.get('signals_evaluated', 1)) and not api.get('verification_required')),
2214
  'trust_points': api.get('trust_points'),
2215
  'block_reasons': api.get('block_reasons'),
 
2216
  'fatf_blacklist_cap': api.get('fatf_blacklist_cap') is True,
2217
  'fatf_blacklist': api.get('fatf_blacklist'),
2218
  'raised_flags': bool(any(row.get('code') for row in rows) or api.get('shadow_signals')
 
1463
  # Deepfake, media-integrity and replay rows (incl. M7 screen replay, V1 video replay).
1464
  # Owner (7 Nov): a face-texture reading (D4) alone is not a deepfake verdict (sun or glare smooths skin),
1465
  # so D4 does not zero the deepfake block. Replay, media and model flags still do.
1466
+ manipulation = [k for k in ids(1, (1, 2, 3)) if k not in liveness_rows and k not in pulse_rows
1467
+ and k not in ('D1', 'D2', 'D3', 'D4')]
1468
+ manipulation += [k for k, r in rows.items() if r.get('group') == 'Deepfake' and k not in ('D1', 'D2', 'D3', 'D4')]
1469
+ # Owner (7 Nov): one model flag is not a verdict (uncalibrated; sun and glare trigger it). The deepfake block
1470
+ # is zeroed by the model only when its average (D1) and a second frame-level check (D2 or D3) both flag.
1471
+ model_confirmed = flagged(['D1']) and flagged(['D2', 'D3'])
1472
  phone_pulse = api.get('device_pulse') if isinstance(api.get('device_pulse'), dict) else {}
1473
  pulse = ((phone_pulse.get('status') == 'detected' and not (liveness or {}).get('no_heartbeat'))
1474
  or (api.get('rppg_result') or {}).get('status') == 'research_measurement')
 
1496
  location = [k for k in location if k != 'N6']
1497
  identity, contact = ids(3, (8,)) + ['I6'], ids(3, (9,))
1498
  earned = {
1499
+ 'deepfake': assessed('D1') and not flagged(manipulation) and scene.get('level') != 'warning' and not model_confirmed,
1500
  'heartbeat': pulse and not flagged(pulse_rows),
1501
  'kinematics': pose and turned and not flagged(liveness_rows),
1502
  'device': assessed('B12') and camera.get('level') != 'warning', # points per check below
 
1509
  if reasons is not None:
1510
  found = {
1511
  'deepfake': ('Deepfake model did not run' if not assessed('D1') else
1512
+ 'deepfake model flagged across frames (D1 with D2 or D3)' if model_confirmed else
1513
  f"flagged {first_flag(manipulation)}" if flagged(manipulation) else
1514
  'face seen inside a phone or screen' if scene.get('level') == 'warning' else None),
1515
  'heartbeat': ('no pulse detected' if not pulse else
 
1596
  _lv_liveness_route.get(), reasons=block_reasons)
1597
  if not points['kinematics'] and 'kinematics' not in block_reasons:
1598
  block_reasons['kinematics'] = 'no head-movement instructions followed'
1599
+ d_codes = {r.get('id'): r.get('code') for r in result['signals'] if isinstance(r, dict)}
1600
+ deepfake_concern = bool(d_codes.get('D1')) and not (d_codes.get('D2') or d_codes.get('D3'))
1601
  device_checks = points.pop('device_checks', {})
1602
  liveness_report = _lv_device_liveness.get() or {}
1603
  # A missed instruction costs its 2.5 points; it does not by itself force a step-up (owner rule).
 
1650
  trust_points={'tier_1': points['deepfake'] + points['heartbeat'] + points['kinematics'],
1651
  'tier_2': points['device'] + points['location'],
1652
  'tier_3': points['identity'] + points['contact'], **points},
1653
+ device_checks=device_checks, block_reasons=block_reasons, deepfake_concern=deepfake_concern)
1654
  result['score'], result['decision'] = 100 - score, decision
1655
  payload = engine.verify_token(api.get('trust_token') or '') if callable(getattr(engine, 'verify_token', None)) else None
1656
  if payload:
 
1876
 
1877
 
1878
  def report_narrative(rating, tp, fatf=None, scam=False, groups=(), raised_flags=None, software_camera=False,
1879
+ hard_stop=False, id_problem=False, automation=False, deepfake_concern=False):
1880
  """Plain-language executive summary: why the score, the risk to the firm, and the onboarding action.
1881
  No numbers or technical terms. It says what the checks found, never that identity is proven."""
1882
  groups = set(groups)
 
1884
  grey_country = not edd_country and 'jurisdiction' in groups # increased-monitoring links: risk-based policy
1885
  missing_only = rating == 'Not assessed' or (raised_flags is False and rating == 'High')
1886
  if tp:
1887
+ deep_label = ('no confirmed deepfake or replay signs (the model raised one unconfirmed concern)'
1888
+ if deepfake_concern else 'no sign of a deepfake or a replayed recording')
1889
+ areas = [(deep_label, tp['deepfake'] > 0 and not hard_stop),
1890
  ('a pulse-like signal from the face (unvalidated)', tp['heartbeat'] > 0),
1891
  ('head movements as instructed', tp['kinematics'] > 0),
1892
  ('no sign of a modified device or camera software', tp['device'] >= 15),
 
1898
  if fatf or scam or software_camera or id_problem or automation:
1899
  areas = areas[:3] # Tier 2 and Tier 3 are set aside, not failed: explained below
1900
  good = [a for a, ok in areas if ok]
1901
+ gaps = {deep_label: 'that the video is free of deepfake or replay signs',
1902
  'a pulse-like signal from the face (unvalidated)': 'a pulse-like signal from the face',
1903
  'head movements as instructed': 'that the head movements were completed',
1904
  'no sign of a modified device or camera software': ('that every device check passed' if tp['device'] > 0
 
2086
  reasons_in=value.get('block_reasons') if isinstance(value.get('block_reasons'),dict) else {}
2087
  blocks=('deepfake','heartbeat','kinematics','device','location','identity','contact')
2088
  result['block_reasons']={b:str(reasons_in[b])[:120] for b in blocks if isinstance(reasons_in.get(b),str)} if tp else {}
2089
+ result['deepfake_concern']=value.get('deepfake_concern') is True
2090
  result['device_checks']={k:checks[k] for k,_,most in REPORT_DEVICE_CHECKS
2091
  if type(checks.get(k)) is int and checks[k] in (0,most)} if tp else {}
2092
  if result['device_checks']:
 
2100
  result['software_camera'] is True,result['hard_stop'] is True,
2101
  result['id_problem'] is True or (result['step_up_cap'] is True and result['software_camera'] is not True
2102
  and result['id_problem'] is None and result['automation'] is not True),
2103
+ result['automation'] is True, result['deepfake_concern'] is True)
2104
  result['headline']=report_headline(result['risk_rating'],result['raised_flags'])
2105
  result['sanctions_note']=('Confirm any sanctions concern through current sanctions screening.' if 'SAN-01' in result['risk_codes'] else
2106
  'Sanctions-list screening is not included in this demo and must be completed separately.')
 
2223
  assessed=bool(api.get('signals_evaluated', 1)) and not api.get('verification_required')),
2224
  'trust_points': api.get('trust_points'),
2225
  'block_reasons': api.get('block_reasons'),
2226
+ 'deepfake_concern': api.get('deepfake_concern') is True,
2227
  'fatf_blacklist_cap': api.get('fatf_blacklist_cap') is True,
2228
  'fatf_blacklist': api.get('fatf_blacklist'),
2229
  'raised_flags': bool(any(row.get('code') for row in rows) or api.get('shadow_signals')
capture_overlay.json CHANGED
@@ -1 +1 @@
1
- {"revision": "c8619f71fedfc40f3cb4a13526b49a9dad3ca637", "sha256": {"liveness_sequence.py": "51db115d6718c7e4ddf5c2eab699b1bf51950e47028542a0dad00064e354759d", "speech_challenge.py": "1d2c452b8919ed610a23c35fd73d7aec68f58aa1706d9764f518091e0ef4f37d", "speech_challenge_worker.py": "2c89ed482853fd07906f5cfc100040c0617f1274ddf15300429117b7e779bc91", "capture_backend.py": "ebd54ef7defdaccd3ff2824679c9d0f1ad98bcf86dd57f8edb84e7e5a8e48c25", "fidestra.js": "741a240f9f24b80de2940d3ae5f51a9bd5af730bcddf1c04f815d2f4f2f461a8", "guided.html": "8f4ab3d299414472f4b72a2f8cc9c21ba1bc2375f28a4b46666f8cd3d10232bc", "guided_research.py": "4d705089827afa18ee28e57b87704ff42d2b0b3e4538ef515f7a0bed2bca83b3", "advanced_biometrics.py": "f3437d1adb1673fbbe2b76d88bcac3d563c82f63508d8e7054dd02a6d1ac8354", "face_landmarker.task": "64184e229b263107bc2b804c6625db1341ff2bb731874b0bcc2fe6544e0bc9ff", "capture_multimodal.py": "d85e539109d60a985363463046231e8563cc39a537f0597a8ed6275fda78bfbb", "tier1_visual_stack.py": "0b9235e382a3245e7c82cf7f123486e5935c075e2526e711038097c05935e473", "temporal_visual_transformer.py": "f01eff15c60337800b43e277bf4851bc1f0a3336d2a2a96ac3c7e57c954e00f4", "visual_model_runtime.py": "e65b73d160c23a2a00dc80fc9f79caebb4d78331db5a9449e27ca4f4f8acbc11"}}
 
1
+ {"revision": "57248bc2790170e1e4e88abb53b045e5032a7940", "sha256": {"liveness_sequence.py": "51db115d6718c7e4ddf5c2eab699b1bf51950e47028542a0dad00064e354759d", "speech_challenge.py": "1d2c452b8919ed610a23c35fd73d7aec68f58aa1706d9764f518091e0ef4f37d", "speech_challenge_worker.py": "2c89ed482853fd07906f5cfc100040c0617f1274ddf15300429117b7e779bc91", "capture_backend.py": "ebd54ef7defdaccd3ff2824679c9d0f1ad98bcf86dd57f8edb84e7e5a8e48c25", "fidestra.js": "741a240f9f24b80de2940d3ae5f51a9bd5af730bcddf1c04f815d2f4f2f461a8", "guided.html": "8f4ab3d299414472f4b72a2f8cc9c21ba1bc2375f28a4b46666f8cd3d10232bc", "guided_research.py": "4d705089827afa18ee28e57b87704ff42d2b0b3e4538ef515f7a0bed2bca83b3", "advanced_biometrics.py": "f3437d1adb1673fbbe2b76d88bcac3d563c82f63508d8e7054dd02a6d1ac8354", "face_landmarker.task": "64184e229b263107bc2b804c6625db1341ff2bb731874b0bcc2fe6544e0bc9ff", "capture_multimodal.py": "d85e539109d60a985363463046231e8563cc39a537f0597a8ed6275fda78bfbb", "tier1_visual_stack.py": "0b9235e382a3245e7c82cf7f123486e5935c075e2526e711038097c05935e473", "temporal_visual_transformer.py": "f01eff15c60337800b43e277bf4851bc1f0a3336d2a2a96ac3c7e57c954e00f4", "visual_model_runtime.py": "e65b73d160c23a2a00dc80fc9f79caebb4d78331db5a9449e27ca4f4f8acbc11"}}