NOBODY204 commited on
Commit
9db07cb
Β·
verified Β·
1 Parent(s): f50c4b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import gradio as gr
2
  import cv2
3
  import numpy as np
@@ -106,7 +107,7 @@ def test_fft(roi):
106
  outer_energy = mag[~mask].mean()
107
  if outer_energy == 0: return 0.5
108
  ratio = center_energy / outer_energy
109
- if ratio > 1.5: return 0.95 # AjustΓ© pour mobile
110
  elif ratio > 1.0: return 0.80
111
  else: return 0.30
112
 
@@ -118,7 +119,6 @@ def test_contours(roi):
118
  border = int(min(h, w) * 0.15)
119
  center = edges[border:-border, border:-border]
120
  center_den = center.mean() if center.size > 0 else 1
121
- # On est moins sévère sur le ratio de bordure pour les vidéos naturelles
122
  ratio = edges.mean() / (center_den + 1e-5)
123
  return 0.90 if ratio < 2.0 else 0.40
124
 
@@ -126,7 +126,7 @@ def test_contours(roi):
126
  # Γ‰TAPE 4 β€” SCORE ET VERDICT (FIX SEUILS)
127
  # ═══════════════════════════════════════════════════════════
128
  def get_verdict(score_pct):
129
- # AJUSTEMENT : 75.7% devient AUTHENTIQUE
130
  if score_pct >= 70:
131
  return "βœ… AUTHENTIQUE", "QualitΓ© validΓ©e conforme aux standards mobiles S2T."
132
  elif score_pct >= 50:
@@ -145,7 +145,7 @@ def analyze_deepfake(video_path):
145
  detail_logs = []
146
 
147
  for frame in frames:
148
- rois = detect_and_restore_faces(frame) # Utilise la dΓ©tection + restauration
149
  for roi in rois:
150
  s_b = test_noise(roi)
151
  s_f = test_fft(roi)
@@ -160,7 +160,6 @@ def analyze_deepfake(video_path):
160
  global_score_pct = round(np.mean(all_scores) * 100, 1)
161
  verdict, explication = get_verdict(global_score_pct)
162
 
163
- # CrΓ©ation du rapport final
164
  sep = "─" * 48
165
  rapport = (
166
  f"πŸ›‘οΈ VideoShield v3.0 β€” Rapport d'AuthenticitΓ©\n{sep}\n"
@@ -180,10 +179,9 @@ def analyze_deepfake(video_path):
180
  "restoration_active": True
181
  }
182
 
183
- # INDEXATION AUTOMATIQUE
184
  index_analysis(json_data)
185
 
186
- return rapport, json.dumps(json_data, indent=2)
187
 
188
  # ═══════════════════════════════════════════════════════════
189
  # INTERFACE
@@ -201,4 +199,4 @@ with gr.Blocks(title="VideoShield v3.0", theme=gr.themes.Soft()) as demo:
201
  btn.click(analyze_deepfake, inputs=[video_input], outputs=[rapport_out, json_out])
202
 
203
  if __name__ == "__main__":
204
- demo.launch(server_name="0.0.0.0")
 
1
+ import subprocess, sys
2
  import gradio as gr
3
  import cv2
4
  import numpy as np
 
107
  outer_energy = mag[~mask].mean()
108
  if outer_energy == 0: return 0.5
109
  ratio = center_energy / outer_energy
110
+ if ratio > 1.5: return 0.95
111
  elif ratio > 1.0: return 0.80
112
  else: return 0.30
113
 
 
119
  border = int(min(h, w) * 0.15)
120
  center = edges[border:-border, border:-border]
121
  center_den = center.mean() if center.size > 0 else 1
 
122
  ratio = edges.mean() / (center_den + 1e-5)
123
  return 0.90 if ratio < 2.0 else 0.40
124
 
 
126
  # Γ‰TAPE 4 β€” SCORE ET VERDICT (FIX SEUILS)
127
  # ═══════════════════════════════════════════════════════════
128
  def get_verdict(score_pct):
129
+ # AJUSTEMENT S2T : 75.7% devient βœ… AUTHENTIQUE
130
  if score_pct >= 70:
131
  return "βœ… AUTHENTIQUE", "QualitΓ© validΓ©e conforme aux standards mobiles S2T."
132
  elif score_pct >= 50:
 
145
  detail_logs = []
146
 
147
  for frame in frames:
148
+ rois = detect_and_restore_faces(frame)
149
  for roi in rois:
150
  s_b = test_noise(roi)
151
  s_f = test_fft(roi)
 
160
  global_score_pct = round(np.mean(all_scores) * 100, 1)
161
  verdict, explication = get_verdict(global_score_pct)
162
 
 
163
  sep = "─" * 48
164
  rapport = (
165
  f"πŸ›‘οΈ VideoShield v3.0 β€” Rapport d'AuthenticitΓ©\n{sep}\n"
 
179
  "restoration_active": True
180
  }
181
 
 
182
  index_analysis(json_data)
183
 
184
+ return rapport, json.dumps(json_data, indent=2, ensure_ascii=False)
185
 
186
  # ═══════════════════════════════════════════════════════════
187
  # INTERFACE
 
199
  btn.click(analyze_deepfake, inputs=[video_input], outputs=[rapport_out, json_out])
200
 
201
  if __name__ == "__main__":
202
+ demo.launch(server_name="0.0.0.0")